# Add inline discounts to order line items

This article describes the purpose, usage, calculation logic, and implementation of inline discounts.

### Purpose

You can apply discounts on order line items by specifying inline discounts.

### Functions

The following fields on the Order Line Item object are used to apply inline discounts:

`inlineDiscountType`

: an enum value. Use this field to specify the inline discount type, which can be`Percentage`

,`FixedAmount`

, or`None`

.`inlineDiscountPerUnit`

: a number value. Use this field in accordance with the`inlineDiscountType`

field, in the following manner:- If the
`inlineDiscountType`

field is set as`Percentage`

, the`inlineDiscountPerUnit`

field specifies the discount percentage for each unit of the order line item. - If the
`inlineDiscountType`

field is set as`FixedAmount`

, the`inlineDiscountPerUnit`

field specifies the discount amount on each unit of the order line item.

- If the
`discount`

: a number value. This field shows the total discount amount that is applied to an order line item after the previous inline discount fields are set.

When creating or updating an order line item, you can specify the `inlineDiscountType`

and `inlineDiscountPerUnit`

fields through both the Zuora UI and API. See more information in Create an order line item.

In addition, the Zuora UI supports the automatic generation of values for the relevant discounting and pricing fields, including `inlineDiscountPerUnit`

, `listPricePerUnit`

, and `amountPerUnit`

. The logic is that when two of the previous fields are set, the remaining field is automatically generated in the UI.

### Calculation logic

The following table uses an example to show the calculation logic of inline discounting and pricing for order line items:

Order Line Item | List Price Per Unit | Inline Discount Per Unit |
Inline Discount Type | Amount Per Unit | Quantity | Discount | Amount |
---|---|---|---|---|---|---|---|

Order Line Item 1 | 50 | 10% | Percentage | 45 | 2 | 10 | 90 |

Order Line Item 2 | 50 | 10 | Fixed Amount | 40 | 2 | 20 | 80 |

Order Line Item 3 | 50 | 0 | None | 50 | 2 | 0 | 100 |

Order Line Item 1 has a percentage inline discount of 10% applied to the list price per unit of 50, so the amount of each unit is 45 (calculated as 50-50*10%=45). The quantity of Order Line Item 1 is 2, so the total discount applied to Order Line Item 1 is 10 (calculated as 50*10%*2=10). The total amount of Order Line Item 1 is 90 (calculated as 50*2-10=90).

Order Line Item 2 has a fixed amount inline discount of 10 applied to the list price per unit of 50, so the amount of each unit is 40 (calculated as 50-10=40). The quantity of Order Line Item 2 is 2, so the total discount applied to Order Line Item 2 is 20 (calculated as 10*2=20). The total amount of Order Line Item 2 is 80 (calculated as 50*2-20=80).

Order Line Item 3 has no inline discounts applied. The amount of each unit is 50 and the quantity of Order Line Item 3 is 2. The total amount of Order Line Item 3 is 100 (calculated as 50*2=100).

### Implementation

The inline discount is implemented as a discount to specify directly through setting the inline discount fields. The inline discount is applied to the list price of an order line item, as the following formula shows:

`Sale Price of Order Line Item = List Price - Inline Discount`

Note that inline discounts on order line items are implemented differently from discounts on rate plan charges. The discount on a rate plan charge is implemented as a discount charge and applied to the sale price of a rate plan charge, as the following formula shows:

`Subtotal of Rate Plan Charge = Sale Price of Rate Plan Charge - Discount`