Purchase and discounts

Through the Purchase API, purchase information is passed from the Purchase service. The purchase information also includes information about any discounts applied to a purchase.

Discounts can exist both on a specific row of items (product line items), last fixes on the entire purchase. Discount on a row of items is applied to the entire amount of the row. Discount can be set either as a percentage or as a fixed amount.

Item row discounts will be applied first, followed by the discount on the sum of the already discounted row prices.

VAT calculation for purchase with discounts

Depending on the type of item, each row of items can have a different VAT (value-added tax) percentage. Therefore, the discount on the entire purchase is evenly distributed over all purchased items. The VAT is then calculated after all the discounts are deducted.

If the purchase discount is a fixed amount, that amount will be deducted from each row. This is done according to the price of each row in relation to the total purchase price.

Examples

If the purchase discount is 20%, then the price of each row of item will be deducted by 20% before calculating the VAT for each row.

A purchase has a total price of 100, and contains two rows with the first row priced at 40, and the second at 60. Then 40% of the fixed purchase discount will be deducted from the first row, and 60% from the other row before calculating the VAT.

Discount expressions

Row discounts

Row discounts are expressed using the following JSON structure in the products list. It contains either amount for fixed discounts, or percentage for percentage discounts.

The discountValue field following the discount object contains the total discount amount for the row:

1
"discount": {
2
"name": "10% off",
3
"quantity": 1,
4
"percentage": 10
5
},
6
"discountValue": 1000

Note: Currently only one discount per row of items is supported. This means the quantity field will always be set to 1. This could potentially change in the future.

Discount for an entire purchase

Discounts for an entire purchase are expressed using the following JSON structure.

They can contain either amount or percentage.

1
"discounts": [
2
{
3
"amount": 2000,
4
"quantity": 1,
5
"value": 2000
6
}

Note: Currently only one discount for the entire purchase is supported. This means the discounts list will only contain one item with quantity set to 1. This could potentially change in the future.

See Fetch a purchase with discount for a full response example containing discounts.

See Purchase API reference for more information on the objects shown in the examples.

Discount calculation

The following example purchase contains discounts both on rows and for the entire purchase.

NrProductUnit priceQuantityDiscount
1Foo2025
2Bar101010%
Purchase discount20%
  1. To calculate the total discount, we start by calculating the discount per row:

    First row contains 2 items and a fixed discount amount of 5.

    Second row contains 10 items and a percentage discount of 10%.

    Row discounts = 5 + 10 × 10 × 0.1 = 15

  2. Then we calculate the purchase discount, based on the sum of the previously discounted rows: Sum of discounted rows = 20 × 2 + 10 × 10 15 = 125

    Purchase discount = 125 × 0.2 = 25

    The total discount on this purchase is 15 + 25 = 40, and the total sum to pay is 140 40 = 100.

Note: A discount can never be greater than the actual amount of the row or purchase price.