Skip to main content
Skip to main content

NewTotalsService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

atomicPhase_

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

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

PromisePromise<TResult>Required
the result of the transactional work

getGiftCardTotals

Calculate and return the gift cards totals

Parameters

giftCardableAmountnumberRequired
__namedParametersobjectRequired
__namedParameters.giftCardTransactionsGiftCardTransaction[]
__namedParameters.giftCardsGiftCard[]
__namedParameters.regionRegionRequired

Returns

PromisePromise<object>Required

getGiftCardTransactionsTotals

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

objectobject
tax_totalnumberRequired
totalnumberRequired

getGiftCardableAmount

Parameters

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

Returns

numbernumber

getLineItemRefund

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

numbernumber

getLineItemRefundLegacy

Parameters

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

Returns

numbernumber

getLineItemTotals

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

PromisePromise<object>Required

getLineItemTotalsLegacy

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

PromisePromise<LineItemTotals>Required

getLineItemTotals_

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

PromisePromise<LineItemTotals>Required

getShippingMethodTotals

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

PromisePromise<object>Required

getShippingMethodTotalsLegacy

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

Parameters

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

Returns

PromisePromise<ShippingMethodTotals>Required

getShippingMethodTotals_

Calculate and return the shipping method totals

Parameters

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

Returns

PromisePromise<ShippingMethodTotals>Required

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

withTransaction

Parameters

transactionManagerEntityManager

Returns

NewTotalsServiceobjectRequired
Was this section helpful?