How VAT is calculated and rounded
The order in which Alya Books computes line amounts, VAT per category and totals, and how fils are rounded.
Alya Books follows the EN 16931 / PINT AE totals model: VAT is computed per category and rate on the taxable base, not line by line, and every amount is rounded to two decimals (fils). The same code produces the totals in the editor, the PDF and the XML, so the three always agree.
The calculation, step by step
- Line net amount = quantity × net unit price, rounded to 2 decimals.
- Subtotal = sum of line net amounts.
- Discounts and charges from the totals box are subtracted or added. Taxable amount = subtotal − discounts + charges.
- Lines, discounts and charges are grouped by VAT category and rate. For each group, the taxable amount is rounded, then VAT = taxable amount × rate ÷ 100, rounded to 2 decimals.
- Total VAT = sum of the group VAT amounts.
- Total = taxable amount + total VAT.
The totals box shows each group as "VAT 5% (S) on …" so you can see the breakdown that goes into the XML tax subtotals. A reverse-charge group reads "Reverse charge (AE) on …: buyer accounts for VAT at 5%" with 0.00 beside it, because the rate is stated in the e-invoice but no VAT is charged by the seller.
Rounding
- Amounts are rounded half up (away from zero) to the nearest fils (0.01) at each step above, so 1.005 becomes 1.01 and a credit of -1.005 becomes -1.01.
- Quantities are written to the XML with three decimals; prices and amounts with two.
- Because VAT is rounded per group and not per line, the sum of the VAT shown on individual lines can differ from the group VAT by a fils. The group figure is the one that counts.
Prices that include VAT
Switch on Prices include VAT in the editor's right panel to type gross prices. Alya Books stores and sends the net price (gross ÷ 1.05 for 5 %, rounded), and the calculation above runs on the net values.
What validation checks
- Line net amount must equal quantity × price (BT-131).
- Subtotal must equal the sum of lines (BT-106).
- The VAT total and the grand total must match the recomputed values (BT-110, BT-112); the message shows the expected figure.
Received documents are checked the same way, with a tolerance of 1 fils.
Good to know
- Credit notes use the same arithmetic; the amounts are shown with a minus sign in reports.
- A VAT accounting currency (BT-6) can be set in the field configuration when the document currency is not AED.