Money and rounding
How amounts and quantities are written, where VAT sits in a price, and how discounts, VAT, refunds and change are rounded.
On this page
Every amount of the API is a decimal string with at most two decimals, never a JSON number. Inside the till an amount is a whole number of bani, so each rounding below happens once, on an integer.
Decimal strings
- Amounts are written
"61.95", quantities"3"and the VAT rate in percent"21". The currency isRON. - A quantity is a whole number from 1 (
invalid_quantity).discountPercentis a JSON integer, a whole percentage from 0 to 100. - The one signed amount is
closing.differenceof a business day: counted minus expected, with a minus sign when cash is missing.
Formulas
The shelf price of an item includes VAT. Rounding is always to the nearest ban, halves up.
| What | How it is worked out |
|---|---|
| The price of a line | quantity × unitPrice, before the discount. |
| The discount of a line | price × discountPercent / 100, rounded. The line total is the price minus the discount. |
subtotal, discount, total | The sums of the prices, of the discounts, and the first minus the second. |
| VAT of a rate | sum × rate / (100 + rate), rounded, where sum is the total of the lines at that rate. base is the sum minus the VAT. |
vat of the order | The sum of the vat of the rows of vatBreakdown. |
| A refund of units | The cumulative share of the line total for the units returned so far, minus what was already given back. |
| The change of a cash payment | given - amount. |
VAT inside the price
Two rates are in use: 21% and 11%. The vatRate of an item says which one it carries. The VAT is not added to the price, it is part of it: a price of 15.67 at 21% holds about 2.7196 of VAT, which rounds to 2.72, and the base is 12.95.
VAT is worked out for each rate on the sum of its lines, not line by line. One unit each of Milk 1.5%, 1 l (7.20) and Rice, 1 kg (5.90) have the same rate. Line by line the VAT adds to 1.29; on the sum it is 1.30. The order uses 1.30.
Discounts
A discount is a share of the line. 3 units of Beer, 0.5 l at 5.50 are 16.50. A 5% discount is 0.825, which rounds to 0.83, so the line total is 15.67.
Refunds
A refund gives back the price paid for a unit, discount included. The amount of a unit is the cumulative share of the line, so the parts of a full refund add up to the line. For the line above, returning the units one at a time gives 5.22, 5.23, 5.22, which add up to 15.67. You do not send an amount: Refund an order works it out from the lines.
Cash and change
In a cash payment amount is what the payment settles: the cash handed over, or what is due when that is less. The change is given minus amount. A customer who hands over 70.00 for 61.95 gets 8.05 back. Less than the due settles only that part, with no change, and leaves the order partially_paid.