Skip to main content
Skip to main content

NewTotalsService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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

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

getLineItemTotals_

Calculate and return the totals for an item

Parameters

itemLineItemRequired
param1objectRequired
param1.lineItemAllocationobjectRequired
param1.calculationContextTaxCalculationContextRequired
param1.includeTaxboolean
param1.lineItemAllocation.gift_cardGiftCardAllocation
The gift card applied on the line item.
param1.lineItemAllocation.discountDiscountAllocation
The discount applied on the line item.
param1.taxLinesLineItemTaxLine[]

Returns

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

getLineItemTotalsLegacy

Calculate and return the legacy calculated totals using the tax rate

Parameters

itemLineItemRequired
param1objectRequired
param1.lineItemAllocationobjectRequired
param1.calculationContextTaxCalculationContextRequired
param1.taxRatenumberRequired
param1.lineItemAllocation.gift_cardGiftCardAllocation
The gift card applied on the line item.
param1.lineItemAllocation.discountDiscountAllocation
The discount applied on the line item.

Returns

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

getLineItemRefund

Return the amount that can be refund on a line item

Parameters

lineItemobjectRequired
lineItem.idstringRequired
lineItem.unit_pricenumberRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.tax_linesLineItemTaxLine[]Required
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.unit_pricenumberRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
param1objectRequired
param1.calculationContextTaxCalculationContextRequired
param1.taxRatenumberRequired

Returns

numbernumberRequired

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

totalnumberRequired
tax_totalnumberRequired
totalnumberRequired
tax_totalnumberRequired

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.includeTaxboolean
param1.discountsDiscount[]
param1.taxRatenull | number

Returns

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

getGiftCardableAmount

Parameters

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

Returns

numbernumberRequired

getShippingMethodTotals_

Calculate and return the shipping method totals

Parameters

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

Returns

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

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
Was this section helpful?