NewTotalsService
internal.internal.NewTotalsService
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredAccessors
activeManager_
Protected get activeManager_(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
getGiftCardTotals
getGiftCardTotals(giftCardableAmount, «destructured»): Promise<{ tax_total: number ; total: number }>
Calculate and return the gift cards totals
Parameters
giftCardableAmountnumberRequired__namedParametersobjectRequired__namedParameters.giftCardTransactionsGiftCardTransaction[]__namedParameters.giftCardsGiftCard[]Returns
Promise<{ tax_total: number ; total: number }>
PromisePromise<{ tax_total: number ; total: number }>Required
PromisePromise<{ tax_total: number ; total: number }>RequiredgetGiftCardTransactionsTotals
getGiftCardTransactionsTotals(«destructured»): { tax_total: number ; total: number }
Calculate and return the gift cards totals based on their transactions
Parameters
__namedParametersobjectRequired__namedParameters.regionobjectRequired__namedParameters.region.gift_cards_taxablebooleanRequired__namedParameters.region.tax_ratenumberRequiredReturns
object
`object`objecttax_totalnumberRequiredtotalnumberRequiredgetGiftCardableAmount
getGiftCardableAmount(«destructured»): number
Parameters
__namedParametersobjectRequired__namedParameters.discount_totalnumberRequired__namedParameters.gift_cards_taxableboolean__namedParameters.shipping_totalnumberRequired__namedParameters.subtotalnumberRequired__namedParameters.tax_totalnumberRequiredReturns
number
numbernumbergetLineItemRefund
getLineItemRefund(lineItem, «destructured»): number
Return the amount that can be refund on a line item
Parameters
lineItemobjectRequiredlineItem.idstringRequiredlineItem.includes_taxbooleanRequiredlineItem.quantitynumberRequiredlineItem.unit_pricenumberRequired__namedParametersobjectRequired__namedParameters.taxRatenull | numberReturns
number
numbernumbergetLineItemRefundLegacy
Protected getLineItemRefundLegacy(lineItem, «destructured»): number
Parameters
lineItemobjectRequiredlineItem.idstringRequiredlineItem.includes_taxbooleanRequiredlineItem.quantitynumberRequiredlineItem.unit_pricenumberRequired__namedParametersobjectRequired__namedParameters.taxRatenumberRequiredReturns
number
numbernumbergetLineItemTotals
getLineItemTotals(items, «destructured»): Promise<{ [lineItemId: string]: LineItemTotals; }>
Calculate and return the items totals for either the legacy calculation or the new calculation
Parameters
__namedParametersobjectRequired__namedParameters.includeTaxboolean__namedParameters.taxRatenull | numberReturns
Promise<{ [lineItemId: string]: LineItemTotals; }>
getLineItemTotalsLegacy
Protected getLineItemTotalsLegacy(item, «destructured»): Promise<LineItemTotals>
Calculate and return the legacy calculated totals using the tax rate
Parameters
__namedParametersobjectRequired__namedParameters.lineItemAllocationobjectRequired__namedParameters.lineItemAllocation.discountDiscountAllocation__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation__namedParameters.taxRatenumberRequiredReturns
Promise<LineItemTotals>
getLineItemTotals_
Protected getLineItemTotals_(item, «destructured»): Promise<LineItemTotals>
Calculate and return the totals for an item
Parameters
__namedParametersobjectRequired__namedParameters.includeTaxboolean__namedParameters.lineItemAllocationobjectRequired__namedParameters.lineItemAllocation.discountDiscountAllocation__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation__namedParameters.taxLinesLineItemTaxLine[]Returns
Promise<LineItemTotals>
getShippingMethodTotals
getShippingMethodTotals(shippingMethods, «destructured»): Promise<{ [shippingMethodId: string]: ShippingMethodTotals; }>
Calculate and return the shipping methods totals for either the legacy calculation or the new calculation
Parameters
__namedParametersobjectRequired__namedParameters.discountsDiscount[]__namedParameters.includeTaxboolean__namedParameters.taxRatenull | numberReturns
Promise<{ [shippingMethodId: string]: ShippingMethodTotals; }>
getShippingMethodTotalsLegacy
Protected getShippingMethodTotalsLegacy(shippingMethod, «destructured»): Promise<ShippingMethodTotals>
Calculate and return the shipping method totals legacy using the tax rate
Parameters
__namedParametersobjectRequired__namedParameters.discountsDiscount[]__namedParameters.taxRatenumberRequiredReturns
Promise<ShippingMethodTotals>
getShippingMethodTotals_
Protected getShippingMethodTotals_(shippingMethod, «destructured»): Promise<ShippingMethodTotals>
Calculate and return the shipping method totals
Parameters
__namedParametersobjectRequired__namedParameters.discountsDiscount[]__namedParameters.includeTaxboolean__namedParameters.taxLinesShippingMethodTaxLine[]Returns
Promise<ShippingMethodTotals>
shouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?): NewTotalsService
Parameters
transactionManagerEntityManager