NewTotalsService
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredfeatureFlagRouter_
FlagRouterRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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.
Type Parameters
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>RequiredgetLineItemTotals
Calculate and return the items totals for either the legacy calculation or the new calculation
Parameters
param1
objectRequiredparam1.includeTax
booleanparam1.taxRate
null | numberReturns
Promise
Promise<object>RequiredgetLineItemTotals_
Calculate and return the totals for an item
Parameters
param1
objectRequiredparam1.lineItemAllocation
objectRequiredparam1.includeTax
booleanparam1.lineItemAllocation.gift_card
GiftCardAllocationparam1.lineItemAllocation.discount
DiscountAllocationparam1.taxLines
LineItemTaxLine[]Returns
Promise
Promise<LineItemTotals>RequiredgetLineItemTotalsLegacy
Calculate and return the legacy calculated totals using the tax rate
Parameters
param1
objectRequiredparam1.lineItemAllocation
objectRequiredparam1.taxRate
numberRequiredparam1.lineItemAllocation.gift_card
GiftCardAllocationparam1.lineItemAllocation.discount
DiscountAllocationReturns
Promise
Promise<LineItemTotals>RequiredgetLineItemRefund
Return the amount that can be refund on a line item
Parameters
lineItem
objectRequiredlineItem.id
stringRequiredlineItem.unit_price
numberRequiredlineItem.includes_tax
booleanRequiredlineItem.quantity
numberRequiredparam1
objectRequiredparam1.taxRate
null | numberReturns
number
numberRequiredgetLineItemRefundLegacy
Parameters
lineItem
objectRequiredlineItem.id
stringRequiredlineItem.unit_price
numberRequiredlineItem.includes_tax
booleanRequiredlineItem.quantity
numberRequiredparam1
objectRequiredparam1.taxRate
numberRequiredReturns
number
numberRequiredgetGiftCardTotals
Calculate and return the gift cards totals
Parameters
Returns
Promise
Promise<object>RequiredgetGiftCardTransactionsTotals
Calculate and return the gift cards totals based on their transactions
Parameters
param0
objectRequiredparam0.giftCardTransactions
GiftCardTransaction[]Requiredparam0.region
objectRequiredparam0.region.gift_cards_taxable
booleanRequiredparam0.region.tax_rate
numberRequiredReturns
total
numberRequiredtax_total
numberRequiredtotal
numberRequiredtax_total
numberRequiredgetShippingMethodTotals
Calculate and return the shipping methods totals for either the legacy calculation or the new calculation
Parameters
Returns
Promise
Promise<object>RequiredgetGiftCardableAmount
Parameters
__namedParameters
objectRequired__namedParameters.subtotal
numberRequired__namedParameters.shipping_total
numberRequired__namedParameters.discount_total
numberRequired__namedParameters.tax_total
numberRequired__namedParameters.gift_cards_taxable
booleanReturns
number
numberRequiredgetShippingMethodTotals_
Calculate and return the shipping method totals
Parameters
param1
objectRequiredparam1.includeTax
booleanparam1.taxLines
ShippingMethodTaxLine[]param1.discounts
Discount[]Returns
Promise
Promise<ShippingMethodTotals>RequiredgetShippingMethodTotalsLegacy
Calculate and return the shipping method totals legacy using the tax rate
Parameters
Returns
Promise
Promise<ShippingMethodTotals>Required