---
displayed_sidebar: servicesSidebar
---

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

# LineItemAdjustmentService

Provides layer to manipulate line item adjustments.

## constructor

### Parameters

<ParameterTypes parameters={[
  {
    "name": "__namedParameters",
    "type": "`LineItemAdjustmentServiceProps`",
    "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](services.DiscountService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItemAdjustmentRepo_",
    "type": "Repository&#60;[LineItemAdjustment](../../entities/classes/entities.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\_

#### Returns

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

___

## 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

<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

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

___

### create

Creates a line item adjustment

#### Parameters

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

#### Returns

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

___

### createAdjustmentForLineItem

Creates adjustment for a line item

#### Parameters

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

#### Returns

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

___

### createAdjustments

Creates adjustment for a line item

#### Parameters

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

#### Returns

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[LineItemAdjustment](../../entities/classes/entities.LineItemAdjustment.mdx)[] \\| [LineItemAdjustment](../../entities/classes/entities.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

Deletes line item adjustments matching a selector

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "selectorOrIds",
    "type": "`string` \\| `string`[] \\| `FilterableLineItemAdjustmentProps` & `object`",
    "description": "the query object for find or the line item adjustment id",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

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

___

### generateAdjustments

Creates adjustment for a line item

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "calculationContextData",
    "type": "`CalculationContextData`",
    "description": "the calculationContextData object holding discounts",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "generatedLineItem",
    "type": "[LineItem](../../entities/classes/entities.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`",
    "description": "the line item for which a line item adjustment might be created",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

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

___

### list

Lists line item adjustments

#### Parameters

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

#### Returns

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

___

### retrieve

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](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[LineItemAdjustment](../../entities/classes/entities.LineItemAdjustment.mdx)&#62;",
    "description": "the config to retrieve the line item adjustment by",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

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

___

### shouldRetryTransaction\_

#### Parameters

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

#### Returns

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

___

### update

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&#60;[LineItemAdjustment](../../entities/classes/entities.LineItemAdjustment.mdx)&#62;",
    "description": "the line item adjustment to create",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

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

___

### withTransaction

#### Parameters

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

#### Returns

<ParameterTypes parameters={[
  {
    "name": "LineItemAdjustmentService",
    "type": "`object`",
    "description": "Provides layer to manipulate line item adjustments.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />
