DT-CIUS-PT-175

In a VATBReakdown (BG-23) where the VAT category code (BT-118) is "Exempt from VAT" the VAT category taxable amount (BT-116) shall equal the sum of Invoice line net amounts (BT-131) minus the sum of Document level allowance amounts (BT-92) plus the sum of Document level charge amounts (BT-99) where the VAT category codes (BT-151, BT-95, BT-102) are “Exempt from VAT", with an acceptance range of 1.00 € (it does not mean that this tolerance is accepted by the customer).

error: the document is invalid

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.

Context
//ubl:Invoice/cac:TaxTotal | //cn:CreditNote/cac:TaxTotal
Test
(exists(//cac:InvoiceLine) and ((sum(//cac:TaxTotal/cac:TaxSubtotal[normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:TaxableAmount)) - 1.00) <= (round((sum(//cac:InvoiceLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='E' or normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='ISE']/xs:decimal(cbc:LineExtensionAmount)) + sum(//cac:AllowanceCharge[cbc:ChargeIndicator='true'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount)) - sum(//cac:AllowanceCharge[cbc:ChargeIndicator='false'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount))) * 100) div 100)) and ((sum(//cac:TaxTotal/cac:TaxSubtotal[normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:TaxableAmount)) + 1.00) >= (round((sum(//cac:InvoiceLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='E' or normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='ISE']/xs:decimal(cbc:LineExtensionAmount)) + sum(//cac:AllowanceCharge[cbc:ChargeIndicator='true'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount)) - sum(//cac:AllowanceCharge[cbc:ChargeIndicator='false'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount))) * 100) div 100))) or (exists(//cac:CreditNoteLine) and ((sum(//cac:TaxTotal/cac:TaxSubtotal[normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:TaxableAmount)) - 1.00) <= (round((sum(//cac:CreditNoteLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='E' or normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='ISE']/xs:decimal(cbc:LineExtensionAmount)) + sum(//cac:AllowanceCharge[cbc:ChargeIndicator='true'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount)) - sum(//cac:AllowanceCharge[cbc:ChargeIndicator='false'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount))) * 100) div 100)) and ((sum(//cac:TaxTotal/cac:TaxSubtotal[normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:TaxableAmount)) + 1.00) >= (round((sum(//cac:CreditNoteLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='E' or normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID)='ISE']/xs:decimal(cbc:LineExtensionAmount)) + sum(//cac:AllowanceCharge[cbc:ChargeIndicator='true'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount)) - sum(//cac:AllowanceCharge[cbc:ChargeIndicator='false'][normalize-space(cac:TaxCategory/cbc:ID) = 'E' or normalize-space(cac:TaxCategory/cbc:ID) = 'ISE']/xs:decimal(cbc:Amount))) * 100) div 100)))

Checked with Portugal CIUS-PT Invoice (UBL), Portugal CIUS-PT Credit Note (UBL)