[feature] Line discount (#12393)

* Add "discount" support to order line items

* Fix total_price annotation for ExtraLineItem

* Add regression tests

* Add frontend support

* Updated documentation

* Added docs

* Bump API version and CHANGELOG

* Remove 'total_price' annotation

- Can be achieved using in-memory python methods

* Apply fix for migration testing

* Revert "Apply fix for migration testing"

This reverts commit 8d9f2dce8c.

* Different approach

* Adjust playwright threshold
This commit is contained in:
Oliver
2026-07-20 20:42:54 +10:00
committed by GitHub
parent 44d8d0e266
commit 4c4c86e180
23 changed files with 355 additions and 27 deletions
+30
View File
@@ -23,6 +23,36 @@ Throughout this documentation (and within InvenTree) the concepts of *cost* and
| Price | The theoretical amount of money required to pay for something. |
| Cost | The actual amount of money paid. |
## Line Items
Orders (Purchase Orders, Sales Orders, and Return Orders) are made up of *line items*, each linking a *Quantity* to a *Unit Price*. A line item's *Line Total* is calculated as follows:
```
Line Total = Quantity * Unit Price
```
An order's overall *Total Price* is calculated by summing the *Line Total* of every line item and [extra line item](#extra-line-items) associated with the order.
### Extra Line Items
*Extra Line Items* provide a way to add itemized costs to an order which are not tied to a specific part or stock item - for example freight charges, service fees, or other miscellaneous costs. Extra line items support the same *Quantity* and *Unit Price* fields as regular line items, and are included in the order's *Total Price* calculation.
### Line Item Discount
Line items - and their associated [extra line items](#extra-line-items) - support an optional *Discount* field, expressed as a percentage between 0% and 100%. This is available on:
- [Purchase Order](../purchasing/purchase_order.md#add-line-items) line items and [extra line items](../purchasing/purchase_order.md#extra-line-items)
- [Sales Order](../sales/sales_order.md#add-line-items) line items and [extra line items](../sales/sales_order.md#extra-line-items)
- [Return Order](../sales/return_order.md#line-items) line items and [extra line items](../sales/return_order.md#extra-line-items)
If specified, the discount is applied to the *Line Total*, using the following formula:
```
Line Total = Quantity * Unit Price * (1 - Discount / 100)
```
!!! info "Optional"
The discount percentage is optional, and defaults to 0% (no discount) if not specified.
## Currency Support
+10
View File
@@ -92,6 +92,12 @@ Once the "Add Line Item" form opens, select a supplier part in the list.
Fill out the rest of the form then click on <span class="badge inventree confirm">Submit</span>
!!! info "Auto Pricing"
Enable the *Auto Pricing* option to automatically calculate the line item's *Unit Price* from the [supplier part pricing data](../part/pricing.md#supplier-pricing), based on the line item quantity. While enabled, the *Unit Price* field is calculated automatically and cannot be edited manually. This option is disabled by default.
!!! info "Discount"
An optional [discount](../concepts/pricing.md#line-item-discount) percentage can be applied to each line item.
#### Upload File
It is possible to upload an exported purchase order from the supplier instead of manually entering each line item. To start the process, click on <span class="badge inventree confirm">{{ icon("upload") }} Upload File</span> button next to the <span class="badge inventree add">{{ icon("plus-circle") }} Add Line Item</span> button and follow the steps.
@@ -99,6 +105,10 @@ It is possible to upload an exported purchase order from the supplier instead of
!!! info "Supported Formats"
This process only supports tabular data and the following formats are supported: CSV, TSV, XLS, XLSX, JSON and YAML
### Extra Line Items
While [line items](#add-line-items) must reference a particular supplier part, extra line items are available for any other itemized information that needs to be conveyed with the order - for example freight charges or service fees. Extra line items support an optional [discount](../concepts/pricing.md#line-item-discount) percentage, the same as regular line items.
## Issue Order
Once all the line items were added, click on the {{ icon("send", title="Issue") }} button on the main purchase order detail panel and confirm the order has been submitted.
+4 -1
View File
@@ -117,9 +117,12 @@ Return Order line items can be added while the [status](#return-order-status-cod
!!! info "Serialized Stock Only"
Only stock items which are serialized can be selected for return from the customer
!!! info "Discount"
An optional [discount](../concepts/pricing.md#line-item-discount) percentage can be applied to each line item.
### Extra Line Items
While [line items](#line-items) must reference a particular stock item, extra line items are available for any other itemized information that needs to be conveyed with the order.
While [line items](#line-items) must reference a particular stock item, extra line items are available for any other itemized information that needs to be conveyed with the order - for example freight charges or service fees. Extra line items support an optional [discount](../concepts/pricing.md#line-item-discount) percentage, the same as regular line items.
## Return Order Reports
+7
View File
@@ -90,6 +90,13 @@ Once the "Add Line Item" form opens, select a part in the list.
Fill out the rest of the form then click on <span class="badge inventree confirm">Submit</span>
!!! info "Discount"
An optional [discount](../concepts/pricing.md#line-item-discount) percentage can be applied to each line item.
### Extra Line Items
While [line items](#add-line-items) must reference a particular part, extra line items are available for any other itemized information that needs to be conveyed with the order - for example freight charges or service fees. Extra line items support an optional [discount](../concepts/pricing.md#line-item-discount) percentage, the same as regular line items.
## Shipments
After all line items were added to the sales order, user needs to create one or more [shipments](#sales-order-shipments) in order to allocate stock for those parts.