# BR-CO-14

Source: https://xmlvalid.com/rules/BR-CO-14

> Invoice total VAT amount (BT-110) = Σ VAT category tax amount (BT-117).

- Level: error
- Rule sets: EN 16931 rules (UBL) 1.3.17, EN 16931 rules 1.3.16 (UBL), EXTENDED-CTC-FR rules (UBL) 1.4.0.04, Romanian RO e-Factura rules (UBL) 1.0.9
- Context: `/ubl:Invoice/cac:TaxTotal | /cn:CreditNote/cac:TaxTotal`
- Test: `(xs:decimal(child::cbc:TaxAmount)= round((sum(cac:TaxSubtotal/xs:decimal(cbc:TaxAmount)) * 10 * 10)) div 100) or not(cac:TaxSubtotal)`

> Invoice total VAT amount (BT-110) = Σ VAT category tax amount (BT-117).

- Level: error
- Rule sets: EN 16931 rules (CII) 1.3.17
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxTotalAmount[@currencyID=/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode]`
- Test: `. = (round(sum(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax/ram:CalculatedAmount/xs:decimal(.))*10*10)div 100)`

> Invoice total VAT amount (BT-110) = Σ VAT category tax amount (BT-117).

- Level: error
- Rule sets: EN 16931 rules 1.3.16 (CII), EXTENDED-CTC-FR rules (CII) 1.4.0.04, Factur-X BASIC WL rules 1.09, Factur-X EN 16931 rules 1.09.2, Factur-X EXTENDED rules 1.09.2
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxTotalAmount[@currencyID=/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode]`
- Test: `. = (round(sum(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax/ram:CalculatedAmount)*10*10)div 100)`

## Why it fails

- The VAT total in `cac:TaxTotal/cbc:TaxAmount` was calculated over the whole invoice, while the VAT breakdowns (`cac:TaxSubtotal`) were rounded per category, or the other way round.
- A VAT breakdown is missing for one of the VAT categories or rates used on the lines.

## How to fix it

- Make BT-110 the sum of the `cbc:TaxAmount` of every `cac:TaxSubtotal` (BT-117), each already rounded to two decimals.

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