BR-KSA-51 🧮 Tax & Line Calculations error

BR-KSA-51: Line Total Amount with VAT Mismatch (KSA-12)

BR-KSA-51: عدم تطابق إجمالي مبلغ البند شامل الضريبة (KSA-12)

Official ZATCA Specification:

The line amount with VAT (KSA-12) must be Invoice line net amount (BT-131) + Line VAT amount (KSA-11). Rounding discrepancies exceeding 0.01 SAR will trigger rejection.

XPath Context: /ubl:Invoice/cac:InvoiceLine/cac:TaxTotal/cbc:RoundingAmount

📌 Overview & Impact

The line amount with VAT (KSA-12) must strictly equal Invoice line net amount (BT-131) + Line VAT amount (KSA-11).

الوصف بالعربية: مبلغ البند شامل الضريبة (KSA-12) يجب أن يساوي تماماً صافي مبلغ البند (BT-131) + مبلغ ضريبة البند (KSA-11).

⚠️ Common Causes for Rejection

  • Calculating VAT on item unit price before multiplying by quantity rather than on line net amount
  • Floating-point math precision errors (e.g. 115.00000000000001 instead of 115.00)
  • Mismatched discount deduction between line net amount and tax total

How to Fix & Resolve

1

Use Decimal Arithmetic

Perform monetary calculations using arbitrary-precision decimal libraries (e.g. Decimal.js or BigDecimal in Java/Node).

2

Verify Formula

Ensure: Line Extension Amount + Line Tax Amount = RoundingAmount (Line Inclusive Total).

💻 Code Comparison: Invalid vs Compliant UBL 2.1 XML

❌ Invalid XML (Rejected by ZATCA) Invalid Payload
<cac:InvoiceLine>
  <cbc:LineExtensionAmount currencyID="SAR">100.00</cbc:LineExtensionAmount>
  <cac:TaxTotal>
    <cbc:TaxAmount currencyID="SAR">15.00</cbc:TaxAmount>
    <cbc:RoundingAmount currencyID="SAR">114.99</cbc:RoundingAmount> <!-- Error: 100 + 15 != 114.99 -->
  </cac:TaxTotal>
</cac:InvoiceLine>
✓ Valid XML (Compliant UBL 2.1) Valid Payload
<cac:InvoiceLine>
  <cbc:LineExtensionAmount currencyID="SAR">100.00</cbc:LineExtensionAmount>
  <cac:TaxTotal>
    <cbc:TaxAmount currencyID="SAR">15.00</cbc:TaxAmount>
    <cbc:RoundingAmount currencyID="SAR">115.00</cbc:RoundingAmount>
  </cac:TaxTotal>
</cac:InvoiceLine>

Verify Your Invoice XML Online

Use Qeemah's free developer tools to inspect transforms, C14N digests, and Phase 2 QR codes.

Frequently Asked Questions

How should line discounts be treated under BR-KSA-51?

Line discounts must be subtracted from Gross Price * Quantity to produce the LineExtensionAmount (BT-131), and VAT (15%) is then calculated on that discounted net amount.

Stop Fighting Cryptic ZATCA XML Errors

Qeemah handles Phase 2 e-invoicing, cryptographic signing, and real-time clearance automatically. Integrate in minutes.