F-LIB402
The taxable amount on the … when currency: '…', Tax Category ID: '…' and Tax Scheme ID: '…', does not match the sum of taxable amounts from the invoice or credit note lines, after adjusting for allowances (discounts) and charges (fees). A rounding difference of up to +/- 1 is allowed. Values found: - Taxable amount on the …: … - Calculated taxable amount (sum of lines adjusted for discounts and charges): … - Difference: …
What the rule checks
As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.
(not(current()/cac:TaxCategory/cbc:ID = 'StandardRated' or current()/cac:TaxCategory/cbc:ID = 'ZeroRated' or current()/cac:TaxCategory/cbc:ID = 'ReverseCharge')) or ( not(exists(../../cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ])) and not(exists(../../cac:CreditNoteLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ])) or abs(xs:decimal(cbc:TaxableAmount) - ( sum(../../cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:TaxableAmount) + sum(../../cac:CreditNoteLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:TaxableAmount) - sum(../../cac:AllowanceCharge[ cbc:ChargeIndicator = false() and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:Amount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:Amount) + sum(../../cac:AllowanceCharge[ cbc:ChargeIndicator = true() and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:Amount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:Amount) )) <= 1 )
Checked with Denmark OIOUBL 2.1 Invoice