DT-CIUS-PT-163

Invoice total amount without VAT (BT-109) = Σ Invoice line net amount (BT-131) - Sum of allowances on document level (BT-107) + Sum of charges on document level (BT-108), 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
cac:LegalMonetaryTotal
Test
(exists(../cac:InvoiceLine) and ((cbc:ChargeTotalAmount) and (cbc:AllowanceTotalAmount) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10) div 100 ) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10) div 100 ) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00)) or ( not(cbc:ChargeTotalAmount) and (cbc:AllowanceTotalAmount) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10 ) div 100) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10 ) div 100) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00) ) or ( (cbc:ChargeTotalAmount) and not(cbc:AllowanceTotalAmount) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount)) * 10 * 10 ) div 100) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount)) * 10 * 10 ) div 100) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00)) or ( not(cbc:ChargeTotalAmount) and not(cbc:AllowanceTotalAmount) and sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and sum(../cac:InvoiceLine/xs:decimal(cbc:LineExtensionAmount)) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00))) or (exists(../cac:CreditNoteLine) and ((cbc:ChargeTotalAmount) and (cbc:AllowanceTotalAmount) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10) div 100 ) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10) div 100 ) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00)) or ( not(cbc:ChargeTotalAmount) and (cbc:AllowanceTotalAmount) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10 ) div 100) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) - xs:decimal(cbc:AllowanceTotalAmount)) * 10 * 10 ) div 100) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00) ) or ( (cbc:ChargeTotalAmount) and not(cbc:AllowanceTotalAmount) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount)) * 10 * 10 ) div 100) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and (round((sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) + xs:decimal(cbc:ChargeTotalAmount)) * 10 * 10 ) div 100) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00)) or ( not(cbc:ChargeTotalAmount) and not(cbc:AllowanceTotalAmount) and sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) <= (xs:decimal(cbc:TaxExclusiveAmount) + 1.00) and sum(../cac:CreditNoteLine/xs:decimal(cbc:LineExtensionAmount)) >= (xs:decimal(cbc:TaxExclusiveAmount) - 1.00)))

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