---
displayed_sidebar: servicesSidebar
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# LineItemAdjustmentService

Provides layer to manipulate line item adjustments.

## Constructors

### constructor

`**new LineItemAdjustmentService**(«destructured»)`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "__namedParameters",
    "type": "[LineItemAdjustmentServiceProps](../types/LineItemAdjustmentServiceProps.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Properties

<ParameterTypes parameters={[
  {
    "name": "__configModule__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__container__",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__moduleDeclaration__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "discountService",
    "type": "[DiscountService](DiscountService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItemAdjustmentRepo_",
    "type": "Repository&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "manager_",
    "type": "EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "transactionManager_",
    "type": "`undefined` \\| EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Accessors

### activeManager\_

`Protected get**activeManager_**(): EntityManager`

#### Returns

EntityManager

<ParameterTypes parameters={[
  {
    "name": "EntityManager",
    "type": "EntityManager",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

## Methods

### atomicPhase\_

`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;`

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.

<ParameterTypes parameters={[
  {
    "name": "TResult",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "TError",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "work",
    "type": "(`transactionManager`: EntityManager) => Promise&#60;TResult&#62;",
    "description": "the transactional work to be done",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "isolationOrErrorHandler",
    "type": "`IsolationLevel` \\| (`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "the isolation level to be used for the work.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "maybeErrorHandlerOrDontFail",
    "type": "(`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "Potential error handler",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;TResult&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;TResult&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the transactional work",
    "expandable": false,
    "children": []
  }
]} />

___

### create

`**create**(data): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;`

Creates a line item adjustment

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "data",
    "type": "[Partial](../types/Partial.mdx)&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "description": "the line item adjustment to create",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "line item adjustment",
    "expandable": false,
    "children": []
  }
]} />

___

### createAdjustmentForLineItem

`**createAdjustmentForLineItem**(cart, lineItem): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;`

Creates adjustment for a line item

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "cart",
    "type": "[Cart](Cart.mdx)",
    "description": "the cart object holding discounts",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItem",
    "type": "[LineItem](LineItem.mdx)",
    "description": "the line item for which a line item adjustment might be created",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "a line item adjustment or undefined if no adjustment was created",
    "expandable": false,
    "children": []
  }
]} />

___

### createAdjustments

`**createAdjustments**(cart, lineItem?): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[] \| [LineItemAdjustment](LineItemAdjustment.mdx)[][]&#62;`

Creates adjustment for a line item

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "cart",
    "type": "[Cart](Cart.mdx)",
    "description": "the cart object holding discounts",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItem",
    "type": "[LineItem](LineItem.mdx)",
    "description": "the line item for which a line item adjustment might be created",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[] \| [LineItemAdjustment](LineItemAdjustment.mdx)[][]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[] \\| [LineItemAdjustment](LineItemAdjustment.mdx)[][]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created\notherwise returns an array of line item adjustments for each line item in the cart",
    "expandable": false,
    "children": []
  }
]} />

___

### delete

`**delete**(selectorOrIds): Promise&#60;void&#62;`

Deletes line item adjustments matching a selector

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "selectorOrIds",
    "type": "`string` \\| `string`[] \\| [FilterableLineItemAdjustmentProps](FilterableLineItemAdjustmentProps.mdx) & `&#123; discount_id?: FindOperator&#60;`null` \\| string&#62;  &#125;`",
    "description": "the query object for find or the line item adjustment id",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the delete operation",
    "expandable": false,
    "children": []
  }
]} />

___

### generateAdjustments

`**generateAdjustments**(calculationContextData, generatedLineItem, context): Promise&#60;[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]&#62;`

Creates adjustment for a line item

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "calculationContextData",
    "type": "[CalculationContextData](../types/CalculationContextData.mdx)",
    "description": "the calculationContextData object holding discounts",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "generatedLineItem",
    "type": "[LineItem](LineItem.mdx)",
    "description": "the line item for which a line item adjustment might be created",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "context",
    "type": "[AdjustmentContext](../types/AdjustmentContext.mdx)",
    "description": "the line item for which a line item adjustment might be created",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "a line item adjustment or undefined if no adjustment was created",
    "expandable": false,
    "children": []
  }
]} />

___

### list

`**list**(selector?, config?): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;`

Lists line item adjustments

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "selector",
    "type": "[FilterableLineItemAdjustmentProps](FilterableLineItemAdjustmentProps.mdx)",
    "description": "the query object for find",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "description": "the config to be used for find",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the find operation",
    "expandable": false,
    "children": []
  }
]} />

___

### retrieve

`**retrieve**(lineItemAdjustmentId, config?): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;`

Retrieves a line item adjustment by id.

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "lineItemAdjustmentId",
    "type": "`string`",
    "description": "the id of the line item adjustment to retrieve",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "description": "the config to retrieve the line item adjustment by",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the line item adjustment.",
    "expandable": false,
    "children": []
  }
]} />

___

### shouldRetryTransaction\_

`Protected **shouldRetryTransaction_**(err): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "err",
    "type": "`Record<string, unknown>` \\| `&#123; code: string  &#125;`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### update

`**update**(id, data): Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;`

Creates a line item adjustment

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "the line item adjustment id to update",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "[Partial](../types/Partial.mdx)&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "description": "the line item adjustment to create",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](LineItemAdjustment.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "line item adjustment",
    "expandable": false,
    "children": []
  }
]} />

___

### withTransaction

`**withTransaction**(transactionManager?): [LineItemAdjustmentService](LineItemAdjustmentService.mdx)`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "transactionManager",
    "type": "EntityManager",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

[LineItemAdjustmentService](LineItemAdjustmentService.mdx)

<ParameterTypes parameters={[
  {
    "name": "LineItemAdjustmentService",
    "type": "[LineItemAdjustmentService](LineItemAdjustmentService.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />
