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
EntityManager
EntityManagerRequiredInherited 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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
getGiftCardTotals
getGiftCardTotals(giftCardableAmount
, «destructured»
): Promise
<{ tax_total
: number
; total
: number
}>
Calculate and return the gift cards totals
Parameters
giftCardableAmount
numberRequired__namedParameters
objectRequired__namedParameters.giftCardTransactions
GiftCardTransaction[]__namedParameters.giftCards
GiftCard[]Returns
Promise
<{ tax_total
: number
; total
: number
}>
Promise
Promise<{ tax_total: number ; total: number }>Required
Promise
Promise<{ 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
__namedParameters
objectRequired__namedParameters.region
objectRequired__namedParameters.region.gift_cards_taxable
booleanRequired__namedParameters.region.tax_rate
numberRequiredReturns
object
`object`
objecttax_total
numberRequiredtotal
numberRequiredgetGiftCardableAmount
getGiftCardableAmount(«destructured»
): number
Parameters
__namedParameters
objectRequired__namedParameters.discount_total
numberRequired__namedParameters.gift_cards_taxable
boolean__namedParameters.shipping_total
numberRequired__namedParameters.subtotal
numberRequired__namedParameters.tax_total
numberRequiredReturns
number
number
numbergetLineItemRefund
getLineItemRefund(lineItem
, «destructured»
): number
Return the amount that can be refund on a line item
Parameters
lineItem
objectRequiredlineItem.id
stringRequiredlineItem.includes_tax
booleanRequiredlineItem.quantity
numberRequiredlineItem.unit_price
numberRequired__namedParameters
objectRequired__namedParameters.taxRate
null | numberReturns
number
number
numbergetLineItemRefundLegacy
Protected
getLineItemRefundLegacy(lineItem
, «destructured»
): number
Parameters
lineItem
objectRequiredlineItem.id
stringRequiredlineItem.includes_tax
booleanRequiredlineItem.quantity
numberRequiredlineItem.unit_price
numberRequired__namedParameters
objectRequired__namedParameters.taxRate
numberRequiredReturns
number
number
numbergetLineItemTotals
getLineItemTotals(items
, «destructured»
): Promise
<{ [lineItemId: string]
: LineItemTotals
; }>
Calculate and return the items totals for either the legacy calculation or the new calculation
Parameters
__namedParameters
objectRequired__namedParameters.includeTax
boolean__namedParameters.taxRate
null | numberReturns
Promise
<{ [lineItemId: string]
: LineItemTotals
; }>
getLineItemTotalsLegacy
Protected
getLineItemTotalsLegacy(item
, «destructured»
): Promise
<LineItemTotals
>
Calculate and return the legacy calculated totals using the tax rate
Parameters
__namedParameters
objectRequired__namedParameters.lineItemAllocation
objectRequired__namedParameters.lineItemAllocation.discount
DiscountAllocation__namedParameters.lineItemAllocation.gift_card
GiftCardAllocation__namedParameters.taxRate
numberRequiredReturns
Promise
<LineItemTotals
>
getLineItemTotals_
Protected
getLineItemTotals_(item
, «destructured»
): Promise
<LineItemTotals
>
Calculate and return the totals for an item
Parameters
__namedParameters
objectRequired__namedParameters.includeTax
boolean__namedParameters.lineItemAllocation
objectRequired__namedParameters.lineItemAllocation.discount
DiscountAllocation__namedParameters.lineItemAllocation.gift_card
GiftCardAllocation__namedParameters.taxLines
LineItemTaxLine[]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
__namedParameters
objectRequired__namedParameters.discounts
Discount[]__namedParameters.includeTax
boolean__namedParameters.taxRate
null | 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
__namedParameters
objectRequired__namedParameters.discounts
Discount[]__namedParameters.taxRate
numberRequiredReturns
Promise
<ShippingMethodTotals
>
getShippingMethodTotals_
Protected
getShippingMethodTotals_(shippingMethod
, «destructured»
): Promise
<ShippingMethodTotals
>
Calculate and return the shipping method totals
Parameters
__namedParameters
objectRequired__namedParameters.discounts
Discount[]__namedParameters.includeTax
boolean__namedParameters.taxLines
ShippingMethodTaxLine[]Returns
Promise
<ShippingMethodTotals
>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?
): NewTotalsService
Parameters
transactionManager
EntityManager