DT-CIUS-PT-162
Sum of charges on document level (BT-108) = Σ Document level charge amount (BT-99), with an acceptance range of 1.00 € (it does not mean that this tolerance is accepted by the customer).
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.
cac:LegalMonetaryTotal
(exists(../cac:AllowanceCharge[cbc:ChargeIndicator='true']) and ((round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator='true']/xs:decimal(cbc:Amount)) * 10 * 10) div 100) <= (xs:decimal(cbc:ChargeTotalAmount) + 1.00) and (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator='true']/xs:decimal(cbc:Amount)) * 10 * 10) div 100) >= (xs:decimal(cbc:ChargeTotalAmount) - 1.00))) or (not(exists(../cac:AllowanceCharge[cbc:ChargeIndicator='true'])) and xs:decimal(cbc:ChargeTotalAmount) = 0.00) or not(cbc:ChargeTotalAmount)
Checked with Portugal CIUS-PT Invoice (UBL), Portugal CIUS-PT Credit Note (UBL)