Skip to main content
Skip to main content

NewTotalsService

internal.internal.NewTotalsService

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
featureFlagRouter_FlagRouterRequired
manager_EntityManagerRequired
taxCalculationStrategy_ITaxCalculationStrategyRequired
taxProviderService_TaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited 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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited 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[]
__namedParameters.regionRegionRequired

Returns

Promise<{ tax_total: number ; total: number }>

PromisePromise<{ tax_total: number ; total: number }>Required

getGiftCardTransactionsTotals

getGiftCardTransactionsTotals(«destructured»): { tax_total: number ; total: number }

Calculate and return the gift cards totals based on their transactions

Parameters

__namedParametersobjectRequired
__namedParameters.giftCardTransactionsGiftCardTransaction[]Required
__namedParameters.regionobjectRequired
__namedParameters.region.gift_cards_taxablebooleanRequired
__namedParameters.region.tax_ratenumberRequired

Returns

object

`object`object
tax_totalnumberRequired
totalnumberRequired

getGiftCardableAmount

getGiftCardableAmount(«destructured»): number

Parameters

__namedParametersobjectRequired
__namedParameters.discount_totalnumberRequired
__namedParameters.gift_cards_taxableboolean
__namedParameters.shipping_totalnumberRequired
__namedParameters.subtotalnumberRequired
__namedParameters.tax_totalnumberRequired

Returns

number

numbernumber

getLineItemRefund

getLineItemRefund(lineItem, «destructured»): number

Return the amount that can be refund on a line item

Parameters

lineItemobjectRequired
lineItem.idstringRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.tax_linesLineItemTaxLine[]Required
lineItem.unit_pricenumberRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.taxRatenull | number

Returns

number

numbernumber

getLineItemRefundLegacy

Protected getLineItemRefundLegacy(lineItem, «destructured»): number

Parameters

lineItemobjectRequired
lineItem.idstringRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.unit_pricenumberRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.taxRatenumberRequired

Returns

number

numbernumber

getLineItemTotals

getLineItemTotals(items, «destructured»): Promise<{ [lineItemId: string]: LineItemTotals; }>

Calculate and return the items totals for either the legacy calculation or the new calculation

Parameters

itemsLineItem | LineItem[]Required
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.includeTaxboolean
__namedParameters.taxRatenull | number

Returns

Promise<{ [lineItemId: string]: LineItemTotals; }>

PromisePromise<{ [lineItemId: string]: LineItemTotals; }>Required

getLineItemTotalsLegacy

Protected getLineItemTotalsLegacy(item, «destructured»): Promise<LineItemTotals>

Calculate and return the legacy calculated totals using the tax rate

Parameters

itemLineItemRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.lineItemAllocationobjectRequired
__namedParameters.lineItemAllocation.discountDiscountAllocation
__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation
__namedParameters.taxRatenumberRequired

Returns

Promise<LineItemTotals>

PromisePromise<LineItemTotals>Required

getLineItemTotals_

Protected getLineItemTotals_(item, «destructured»): Promise<LineItemTotals>

Calculate and return the totals for an item

Parameters

itemLineItemRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.includeTaxboolean
__namedParameters.lineItemAllocationobjectRequired
__namedParameters.lineItemAllocation.discountDiscountAllocation
__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation
__namedParameters.taxLinesLineItemTaxLine[]

Returns

Promise<LineItemTotals>

PromisePromise<LineItemTotals>Required

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

shippingMethodsShippingMethod | ShippingMethod[]Required
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.includeTaxboolean
__namedParameters.taxRatenull | number

Returns

Promise<{ [shippingMethodId: string]: ShippingMethodTotals; }>

PromisePromise<{ [shippingMethodId: string]: ShippingMethodTotals; }>Required

getShippingMethodTotalsLegacy

Protected getShippingMethodTotalsLegacy(shippingMethod, «destructured»): Promise<ShippingMethodTotals>

Calculate and return the shipping method totals legacy using the tax rate

Parameters

shippingMethodShippingMethodRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.taxRatenumberRequired

Returns

Promise<ShippingMethodTotals>

PromisePromise<ShippingMethodTotals>Required

getShippingMethodTotals_

Protected getShippingMethodTotals_(shippingMethod, «destructured»): Promise<ShippingMethodTotals>

Calculate and return the shipping method totals

Parameters

shippingMethodShippingMethodRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.includeTaxboolean
__namedParameters.taxLinesShippingMethodTaxLine[]

Returns

Promise<ShippingMethodTotals>

PromisePromise<ShippingMethodTotals>Required

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


withTransaction

withTransaction(transactionManager?): NewTotalsService

Parameters

transactionManagerEntityManager

Returns

NewTotalsService

defaultNewTotalsServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?