Skip to main content
Skip to main content

NewTotalsService

Hierarchy

  • TransactionBaseService

    NewTotalsService

Constructors

constructor

new NewTotalsService(«destructured»)

Parameters

Name
«destructured»

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/new-totals.ts:67

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.__configModule__

Defined in

medusa/src/interfaces/transaction-base-service.ts:14


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


featureFlagRouter_

Protected Readonly featureFlagRouter_: FlagRouter

Defined in

medusa/src/services/new-totals.ts:64


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


taxCalculationStrategy_

Protected Readonly taxCalculationStrategy_: ITaxCalculationStrategy

Defined in

medusa/src/services/new-totals.ts:65


taxProviderService_

Protected Readonly taxProviderService_: TaxProviderService

Defined in

medusa/src/services/new-totals.ts:63


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

-EntityManager:

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

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.

Name
TResult
TError

Parameters

NameDescription
work(transactionManager: EntityManager) => Promise<TResult>
isolationOrErrorHandler?IsolationLevel | (error: TError) => Promise<void | TResult>
maybeErrorHandlerOrDontFail?(error: TError) => Promise<void | TResult>

Returns

Promise<TResult>

-Promise: the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


getGiftCardTotals

getGiftCardTotals(giftCardableAmount, «destructured»): Promise<{ tax_total: number ; total: number }>

Calculate and return the gift cards totals

Parameters

Name
giftCardableAmount
«destructured»
› giftCardTransactions?
› giftCards?
› region

Returns

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

-Promise: -object: (optional)

Defined in

medusa/src/services/new-totals.ts:447


getGiftCardTransactionsTotals

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

Calculate and return the gift cards totals based on their transactions

Parameters

Name
«destructured»
› giftCardTransactions
› region
› region.gift_cards_taxable
› region.tax_rate

Returns

object

-object: (optional)

NameType
tax_totalnumber
totalnumber

Defined in

medusa/src/services/new-totals.ts:526


getGiftCardableAmount

getGiftCardableAmount(«destructured»): number

Parameters

Name
«destructured»
› discount_total
› gift_cards_taxable?
› shipping_total
› subtotal
› tax_total

Returns

number

-number: (optional)

Defined in

medusa/src/services/new-totals.ts:638


getLineItemRefund

getLineItemRefund(lineItem, «destructured»): number

Return the amount that can be refund on a line item

Parameters

Name
lineItem
lineItem.id
lineItem.includes_tax
lineItem.quantity
lineItem.tax_lines
lineItem.unit_price
«destructured»
› calculationContext
› taxRate?

Returns

number

-number: (optional)

Defined in

medusa/src/services/new-totals.ts:333


getLineItemRefundLegacy

Protected getLineItemRefundLegacy(lineItem, «destructured»): number

Parameters

Name
lineItem
lineItem.id
lineItem.includes_tax
lineItem.quantity
lineItem.unit_price
«destructured»
› calculationContext
› taxRate

Returns

number

-number: (optional)

Defined in

medusa/src/services/new-totals.ts:403


getLineItemTotals

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

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

Parameters

Name
items
«destructured»
› calculationContext
› includeTax?
› taxRate?

Returns

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

-Promise: -object: (optional)

Defined in

medusa/src/services/new-totals.ts:87


getLineItemTotalsLegacy

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

Calculate and return the legacy calculated totals using the tax rate

Parameters

Name
item
«destructured»
› calculationContext
› lineItemAllocation
› lineItemAllocation.discount?
› lineItemAllocation.gift_card?
› taxRate

Returns

Promise<LineItemTotals>

-Promise:

Defined in

medusa/src/services/new-totals.ts:254


getLineItemTotals_

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

Calculate and return the totals for an item

Parameters

Name
item
«destructured»
› calculationContext
› includeTax?
› lineItemAllocation
› lineItemAllocation.discount?
› lineItemAllocation.gift_card?
› taxLines?

Returns

Promise<LineItemTotals>

-Promise:

Defined in

medusa/src/services/new-totals.ts:147


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

Name
shippingMethods
«destructured»
› calculationContext
› discounts?
› includeTax?
› taxRate?

Returns

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

-Promise: -object: (optional)

Defined in

medusa/src/services/new-totals.ts:572


getShippingMethodTotalsLegacy

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

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

Parameters

Name
shippingMethod
«destructured»
› calculationContext
› discounts?
› taxRate

Returns

Promise<ShippingMethodTotals>

-Promise:

Defined in

medusa/src/services/new-totals.ts:749


getShippingMethodTotals_

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

Calculate and return the shipping method totals

Parameters

Name
shippingMethod
«destructured»
› calculationContext
› discounts?
› includeTax?
› taxLines?

Returns

Promise<ShippingMethodTotals>

-Promise:

Defined in

medusa/src/services/new-totals.ts:666


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name
err

Returns

boolean

-boolean: (optional)

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


withTransaction

withTransaction(transactionManager?): NewTotalsService

Parameters

Name
transactionManager?

Returns

NewTotalsService

-default:

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20

Was this section helpful?