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.
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.
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).