Invoice Calculations and Rounding

Dear All,
I am lost among this community and the XML Implementation, at the end i’m not sure if i’m getting the right result.

my issue now this sample:

Qty Price Qty*Price TotalBefore(Qty*Price)(Rounded) Tax(TotalBefore*0.15)(Rounded) Tax(Qty*Price*0.15)(Rounded)
1 78.26 78.26 78.26 11.74 11.74
1 78.26 78.26 78.26 11.74 11.74
1 61.9575 61.9575 61.96 9.29 9.29
1 61.9575 61.9575 61.96 9.29 9.29
1 61.947 61.947 61.95 9.29 9.29
1 61.947 61.947 61.95 9.29 9.29
15 3.913 58.695 58.7 8.81 8.8
463.024 463.04 69.45 69.44

Final totals:
TotalBefore= 463.04 or 463.02
Tax= 69.45 or 69.44

if TotalBefore=463.04 then Tax= 463.04*0.15=69.46 didn’t appear in my calculations, but TotalBefore calculated according to XML guide

if TotalBefore=463.02 then Tax= 463.02*0.15=69.45 appeared in my calculations, but Tax NOT calculated according to XML guide

could anyone create a full guide to calculate lines and final totals?

In invoicelines, always calculate the tax before rounding.

If you calculate the tax after rounding, there may be a difference of ±1 halala.

Hi Mohammad,

Not the same problem you are facing, but we recently faced a similar issue caused by unavoidable rounding differences.

In our case, the problem was that there was a difference of ~0.01 between the total tax (BT-110) calculated on the total amount and the sum of the line taxes (KSA-11) due to rounding.

We addressed the problem using “Rounding Amount” (BT-114)

As per original guidelines:

Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Pre-Paid amount (BT-113) + Rounding amount (BT-114)

For our example:

Invoice total = Invoice total amount incl. VAT calculated on total - 0 + Rounding difference (i.e. difference between Tax on Total and sum of Tax per line)

Don’t know if this will help for your problem, but it worked for us and accepted by ZATCA.

Simple example to demonstrate:

Sl.No. Price      VAT
------------------------
1      6562.50    984.38
2      5625.00    843.75
3      6562.50    984.38
------------------------
      18750.00   2812.51

But tax calculated on total = 18750 x 0.15 = 2812.50

So,

Net           = 18,750.00
Tax (on Net)  =  2,812.50
Rounding      =      0.01
------------------------
Total amt due = 21,562.51

Hi @NEOSYS

According to the scenario you mentioned, you do not need to use the rounding amount to settle the total bill.

With regard to XML files, tax must be calculated at the document level from the total taxable amount, not from the total tax amount at the line level.

This is because your use of rounding will not affect the total tax, and thus in the QR code data, the tax amount will be ±1 (one halala). This discrepancy may cause the buyer to reject the invoice.

Hi @mnuaimi

We completely relate to what you’re describing - we run into the same situation almost every day, especially when prices are tax-inclusive. The discrepancy becomes more visible as the number of line items increases.

Here is a simplified example that mirrors what we consistently see. Assume eight line items, each with a tax-inclusive unit price of 150 SAR. (Assuming a Line VAT calculation as suggested by considering the unrounded intermediate step before BT-131).

Item   Qty   Price Inc   Net line (BT-131)   VAT (KSA-11)   Line total (KSA-12)
-----------------------------------------------------------------------------
A      1     150         130.43              19.57           150
B      1     150         130.43              19.57           150
C      1     150         130.43              19.57           150
D      1     150         130.43              19.57           150
E      1     150         130.43              19.57           150
F      1     150         130.43              19.57           150
G      1     150         130.43              19.57           150
H      1     150         130.43              19.57           150
-----------------------------------------------------------------------------
                         1043.44             156.56         1200.00

So as you can see, the issue isn’t here in the line item total with VAT but rather the invoice / vat totals (see below).

Now looking at the totals:

  • Subtotal (BT-109) = Σ(BT-131) = 1043.44

  • VAT total = Round( Rounded Taxable Amount * Tax rate )

    = Round(1043.44 * 0.15, 2)

    = 156.52

  • Total (BT-112) = 1043.44 + 156.52 = 1199.96

This results in a 0.04 SAR difference from the actual inclusive total of 1200.00.

From previous discussions, Ankit suggested placing the rounding difference in BT-114, so that:

  • BT-115 = BT-112 + BT-114

    (ignoring prepaid amounts here)

What remains unclear - and we keep hearing different interpretations - is what the QR code’s “Total Amount” field is mapped to.

Is it expected to reference BT-112, or BT-115 when BT-114 is present?

Tagging @Ankit.K.Tiwari here in case he can confirm the intended handling.

Have you by any chance found a reliable approach to this in your implementation?

@chromodome QR Code should take the value from the field BT-115 (after rounding adjustments of BT-114).

Hi @chromodome

TaxableAmount =1,043.44
TaxAmount =1,043.44*0.15=156.516=>156.52

TaxableAmount +TaxAmount =1200.01

The difference is only +1 halala, not +4 halalas as you mentioned.

This is an acceptable difference that both the buyer and seller can understand.