BR-FREXT-CO-15
The rule sets below word this rule differently; each wording is shown with its rule set.
In English If the invoice total VAT amount (BT-110) is given in the invoice currency (BT-5), the total with VAT (BT-112) must equal BT-109 plus BT-110, within 0.01 per item; otherwise BT-112 must equal BT-109.
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
BT110 présent : … , Total HT (BT-109) : … , nbelements : … , TVA : … , TTC : … [BR-FREXT-CO-15] - Si le montant de TVA (BT-110) est présent dans la devise du document (BT-5), alors l’écart absolu entre le montant TTC (BT-112) et la somme HT + TVA (BT-109 + BT-110) doit être ≤ 0,01 € * nombre total d’éléments. Sinon, BT-112 = BT-109.
cac:LegalMonetaryTotal
($isPresentBT110 and (abs($totalAmountBT112 - $totalVATAmountBT110 - $totalAmountBT109) le (($nbLineItems + $nbAllowanceItems + $nbChargeItems) * 0.01))) or not($isPresentBT110)
Checked with France EXTENDED-CTC-FR (UBL)
If Invoice Total VAT amount (BT-110), where currency (BT-110-0) is equal to BT-5, is present, then the Absolute Value of (Invoice total amount with VAT (BT-112) - Invoice total amount without VAT (BT-109) - Invoice total VAT amount (BT-110)) <= 0,01 * (Number of line net amounts (BT-131) + Number of Document level allowance amounts (BT-92) + Number of Document level charges amounts (BT-99) + Number of Logistics Service fee amounts (BT-X-272), but only for lines where the "Subtype of invoice item" (BT-X-8) has the value "Regular item (standard case)" (DETAIL) or is not specified. Else, Invoice total amount with VAT (BT-112) is equal to Invoice total amount without VAT (BT-109), where the VAT category code (BT-151, BT-95, BT-102, BT-X-273) is "Zero rated" (Z).
//ram:SpecifiedTradeSettlementHeaderMonetarySummation
for $Currency in ../ram:InvoiceCurrencyCode, $BT109 in xs:decimal(ram:TaxBasisTotalAmount[1]), $BT110 in xs:decimal(ram:TaxTotalAmount[@currencyID=$Currency][1]), $BT112 in xs:decimal(ram:GrandTotalAmount[1]), $nbTaxTotalAmountInvoiceCurrency in count (ram:TaxTotalAmount[@currencyID=$Currency] ), $nbLineItems in xs:decimal(count(../../ram:IncludedSupplyChainTradeLineItem[not(ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode) or ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL'])), $nbAllowanceItems in xs:decimal(count(../ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator='false'])), $nbChargeItems in xs:decimal(count(../ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator='true']) + count(../ram:SpecifiedLogisticsServiceCharge)), $tolerance in xs:decimal(0.01), $maxTolerance in $tolerance * ($nbLineItems + $nbAllowanceItems + $nbChargeItems), $diff in xs:decimal($BT112 - $BT110 - $BT109), $abs in xs:decimal(abs($diff)) return ($abs le $maxTolerance and $nbTaxTotalAmountInvoiceCurrency eq 1) or ($BT109 eq $BT112 and $nbTaxTotalAmountInvoiceCurrency ne 1)
Checked with France EXTENDED-CTC-FR (CII)