Skip to main content
Skip to main content

LineItemAdjustmentService

internal.internal.LineItemAdjustmentService

Provides layer to manipulate line item adjustments.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
discountServiceanyRequired
lineItemAdjustmentRepo_anyRequired
manager_EntityManagerRequired
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_


create

create(data): Promise<LineItemAdjustment>

Creates a line item adjustment

Parameters

the line item adjustment to create

Returns

Promise<LineItemAdjustment>

PromisePromise<LineItemAdjustment>Required
line item adjustment

createAdjustmentForLineItem

createAdjustmentForLineItem(cart, lineItem): Promise<LineItemAdjustment[]>

Creates adjustment for a line item

Parameters

cartCartRequired
the cart object holding discounts
lineItemLineItemRequired
the line item for which a line item adjustment might be created

Returns

Promise<LineItemAdjustment[]>

PromisePromise<LineItemAdjustment[]>Required
a line item adjustment or undefined if no adjustment was created

createAdjustments

createAdjustments(cart, lineItem?): Promise<LineItemAdjustment[] | LineItemAdjustment[][]>

Creates adjustment for a line item

Parameters

cartCartRequired
the cart object holding discounts
lineItemLineItem
the line item for which a line item adjustment might be created

Returns

Promise<LineItemAdjustment[] | LineItemAdjustment[][]>

PromisePromise<LineItemAdjustment[] | LineItemAdjustment[][]>Required
if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created otherwise returns an array of line item adjustments for each line item in the cart

delete

delete(selectorOrIds): Promise<void>

Deletes line item adjustments matching a selector

Parameters

selectorOrIdsstring | string[] | FilterableLineItemAdjustmentProps & { discount_id?: FindOperator<null | string> }Required
the query object for find or the line item adjustment id

Returns

Promise<void>

PromisePromise<void>Required
the result of the delete operation

generateAdjustments

generateAdjustments(calculationContextData, generatedLineItem, context): Promise<GeneratedAdjustment[]>

Creates adjustment for a line item

Parameters

calculationContextDataCalculationContextDataRequired
the calculationContextData object holding discounts
generatedLineItemLineItemRequired
the line item for which a line item adjustment might be created
contextAdjustmentContextRequired
the line item for which a line item adjustment might be created

Returns

Promise<GeneratedAdjustment[]>

PromisePromise<GeneratedAdjustment[]>Required
a line item adjustment or undefined if no adjustment was created

list

list(selector?, config?): Promise<LineItemAdjustment[]>

Lists line item adjustments

Parameters

the query object for find
the config to be used for find

Returns

Promise<LineItemAdjustment[]>

PromisePromise<LineItemAdjustment[]>Required
the result of the find operation

retrieve

retrieve(lineItemAdjustmentId, config?): Promise<LineItemAdjustment>

Retrieves a line item adjustment by id.

Parameters

lineItemAdjustmentIdstringRequired
the id of the line item adjustment to retrieve
the config to retrieve the line item adjustment by

Returns

Promise<LineItemAdjustment>

PromisePromise<LineItemAdjustment>Required
the line item adjustment.

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(id, data): Promise<LineItemAdjustment>

Creates a line item adjustment

Parameters

idstringRequired
the line item adjustment id to update
the line item adjustment to create

Returns

Promise<LineItemAdjustment>

PromisePromise<LineItemAdjustment>Required
line item adjustment

withTransaction

withTransaction(transactionManager?): LineItemAdjustmentService

Parameters

transactionManagerEntityManager

Returns

LineItemAdjustmentService

LineItemAdjustmentServiceLineItemAdjustmentServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?