Skip to main content

Amounts

Every sale has different amounts based on line items, discounts and payments. This document explains how to calculate the amounts for a sale.

Line Items

Every line item has different price levels. The price levels are:

  • grossTotal: The total price of the line item including taxes and any line item discounts applied.
  • netTotal: The total price of the line item excluding taxes and any line item discounts applied.
  • totalTax: The total amount of taxes applied to the line item.
  • baseGrossTotal: The total price of the line item including taxes and no line item discounts applied.
  • grossUnitPrice: The price of a single unit of the line item including taxes and any line item discounts applied.
  • baseGrossUnitPrice: The price of a single unit of the line item including taxes and no line item discounts applied.

For every line item, the following formulas apply:

The grossTotal is the grossUnitPrice multiplied by the quantity:

lineItem.grossTotal=lineItem.quantitylineItem.grossUnitPrice\text{lineItem.grossTotal} = \text{lineItem.quantity} \cdot \text{lineItem.grossUnitPrice}

The baseGrossTotal is the baseGrossUnitPrice multiplied by the quantity:

lineItem.baseGrossTotal=lineItem.quantitylineItem.baseGrossUnitPrice\text{lineItem.baseGrossTotal} = \text{lineItem.quantity} \cdot \text{lineItem.baseGrossUnitPrice}

The baseGrossTotal and grossTotal differ by the sum of all applied discounts:

lineItem.grossTotal=lineItem.baseGrossTotal+dlineItem.discountsd.totalGrossAmount\text{lineItem.grossTotal} = \text{lineItem.baseGrossTotal} + \sum_{\text{d} \,\in\, \text{lineItem.discounts}} \text{d.totalGrossAmount}

grossTotal and netTotal differ by the totalTax:

lineItem.netTotal=lineItem.grossTotallineItem.totalTax\text{lineItem.netTotal} = \text{lineItem.grossTotal} - \text{lineItem.totalTax}

totalTax is the sum of all taxes applied to the line item:

lineItem.totalTax=tlineItem.taxest.taxAmount\text{lineItem.totalTax} = \sum_{\text{t} \,\in\, \text{lineItem.taxes}} \text{t.taxAmount}

Line Item Taxes

Every line item can have multiple taxes applied. When sending taxes the taxAmount is required. The taxAmount represents the tax that is due for this type of tax (e.g. VAT) for this line item.

When sending a grossAmount and netAmount it must hold that:

tax.taxAmount=tax.grossAmounttax.netAmount\text{tax.taxAmount} = \text{tax.grossAmount} - \text{tax.netAmount}

When multiple taxes are applied to a line item, the taxAmount, netAmount and grossAmount per tax item refer to the application of this tax only. If taxes are stacked they can differ between entries.

For example when a line item has a grossAmount of €100 and a netAmount of €85 and two taxes are applied, one with a taxAmount of €10 and one with a taxAmount of €5 then the taxesarray look like this:

{
"taxes": [
{
"taxAmount": {
"amount": "5",
"currency": "EUR"
},
"grossAmount": {
"amount": "100",
"currency": "EUR"
},
"netAmount": {
"amount": "85",
"currency": "EUR"
}
},
{
"taxAmount": {
"amount": "10",
"currency": "EUR"
},
"grossAmount": {
"amount": "100",
"currency": "EUR"
},
"netAmount": {
"amount": "90",
"currency": "EUR"
}
}
]
}

Line Item Discounts

Every line item can have multiple discounts applied. When sending discounts the totalGrossAmount is required. The totalGrossAmount represents the total discount that is due for this line item by this discount.

Transaction level discounts are applied independently of line item discounts. The totalGrossAmount of a line item discount is the total amount of the discount for this line item. Given a sale with a single line item with a baseGrossTotal of €100 and a line item discount of €10 and a transaction level discount of €5 the sale looks like this:

{
"lineItems": [
{
"baseGrossTotal": {
"amount": "100",
"currency": "EUR"
},
"grossTotal": {
"amount": "90",
"currency": "EUR"
},
"discounts": [
{
"totalGrossAmount": {
"amount": "10",
"currency": "EUR"
}
}
]
}
],
"discounts": [
{
"totalGrossAmount": {
"amount": "5",
"currency": "EUR"
}
}
],
"totals": {
"grossAmount": {
"amount": "85",
"currency": "EUR"
}
}
}

So the following relationships hold:

lineItem.grossTotal=lineItem.baseGrossTotaldlineItem.discountsd.totalGrossAmount\text{lineItem.grossTotal} = \text{lineItem.baseGrossTotal} - \sum_{\text{d} \,\in\, \text{lineItem.discounts}} \text{d.totalGrossAmount}

Totals

The grossAmount is the total price of the sale including taxes and any sale level discounts applied.

totals.grossAmount=lilineItemsli.grossTotaldsale.discountsd.totalGrossAmount\text{totals.grossAmount} = \sum_{\text{li} \,\in\, \text{lineItems}} \text{li.grossTotal} - \sum_{\text{d} \,\in\, \text{sale.discounts}} \text{d.totalGrossAmount}

netAmount and grossAmount differ by the taxAmount:

totals.netAmount=totals.grossAmounttotals.taxAmount\text{totals.netAmount} = \text{totals.grossAmount} - \text{totals.taxAmount}