Skip to main content
Skip to main content

NewTotalsService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

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
param1objectRequired
param1.regionRegionRequired
param1.giftCardTransactionsGiftCardTransaction[]
param1.giftCardsGiftCard[]

Returns

PromisePromise<object>Required
Calculate and return the gift cards totals

getGiftCardTransactionsTotals

Calculate and return the gift cards totals based on their transactions

Parameters

param0objectRequired
param0.giftCardTransactionsGiftCardTransaction[]Required
param0.regionobjectRequired
param0.region.gift_cards_taxablebooleanRequired
param0.region.tax_ratenumberRequired

Returns

tax_totalnumberRequired
totalnumberRequired
tax_totalnumberRequired
totalnumberRequired

getGiftCardableAmount

Parameters

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

Returns

numbernumberRequired

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
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.taxRatenull | number

Returns

numbernumberRequired
Return the amount that can be refund on a line item

getLineItemRefundLegacy

Parameters

lineItemobjectRequired
lineItem.idstringRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.unit_pricenumberRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.taxRatenumberRequired

Returns

numbernumberRequired

getLineItemTotals

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

Parameters

itemsLineItem | LineItem[]Required
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.includeTaxboolean
param1.taxRatenull | number

Returns

PromisePromise<object>Required
Calculate and return the items totals for either the legacy calculation or the new calculation

getLineItemTotalsLegacy

Calculate and return the legacy calculated totals using the tax rate

Parameters

itemLineItemRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.lineItemAllocationobjectRequired
param1.taxRatenumberRequired
param1.lineItemAllocation.discountDiscountAllocation
param1.lineItemAllocation.gift_cardGiftCardAllocation

Returns

PromisePromise<LineItemTotals>Required
Calculate and return the legacy calculated totals using the tax rate

getLineItemTotals_

Calculate and return the totals for an item

Parameters

itemLineItemRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.lineItemAllocationobjectRequired
param1.includeTaxboolean
param1.lineItemAllocation.discountDiscountAllocation
param1.lineItemAllocation.gift_cardGiftCardAllocation
param1.taxLinesLineItemTaxLine[]

Returns

PromisePromise<LineItemTotals>Required
Calculate and return the totals for an item

getShippingMethodTotals

Calculate and return the shipping methods totals for either the legacy calculation or the new calculation

Parameters

shippingMethodsShippingMethod | ShippingMethod[]Required
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.discountsDiscount[]
param1.includeTaxboolean
param1.taxRatenull | number

Returns

PromisePromise<object>Required
Calculate and return the shipping methods totals for either the legacy calculation or the new calculation

getShippingMethodTotalsLegacy

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

Parameters

shippingMethodShippingMethodRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.taxRatenumberRequired
param1.discountsDiscount[]

Returns

PromisePromise<ShippingMethodTotals>Required
Calculate and return the shipping method totals legacy using the tax rate

getShippingMethodTotals_

Calculate and return the shipping method totals

Parameters

shippingMethodShippingMethodRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.discountsDiscount[]
param1.includeTaxboolean
param1.taxLinesShippingMethodTaxLine[]

Returns

PromisePromise<ShippingMethodTotals>Required
Calculate and return the shipping method totals

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired
Was this section helpful?