# BR-FREXT-CO-15

Source: https://xmlvalid.com/rules/BR-FREXT-CO-15

> 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.

- Level: error
- Rule sets: EXTENDED-CTC-FR rules (UBL) 1.4.0.04
- Context: `cac:LegalMonetaryTotal`
- Test: `($isPresentBT110 and (abs($totalAmountBT112 - $totalVATAmountBT110 - $totalAmountBT109) le (($nbLineItems + $nbAllowanceItems + $nbChargeItems) * 0.01))) or not($isPresentBT110)`

> 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).

- Level: error
- Rule sets: EXTENDED-CTC-FR rules (CII) 1.4.0.04
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `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)`

Validate a document against these rules: https://xmlvalid.com/validate
