# BR-CO-10

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

> Sum of Invoice line net amount (BT-106) = Σ Invoice line net amount (BT-131).

- Level: error
- Rule sets: EN 16931 rules (UBL) 1.3.17, EN 16931 rules 1.3.16 (UBL), Romanian RO e-Factura rules (UBL) 1.0.9
- Context: `cac:LegalMonetaryTotal`
- Test: `(xs:decimal(cbc:LineExtensionAmount) = xs:decimal(round(sum(//(cac:InvoiceLine|cac:CreditNoteLine)/xs:decimal(cbc:LineExtensionAmount)) * 10 * 10) div 100))`

> Sum of Invoice line net amount (BT-106) = Σ Invoice line net amount (BT-131).

- Level: error
- Rule sets: EN 16931 rules (CII) 1.3.17
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `xs:decimal(ram:LineTotalAmount) = round(sum(../../ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount/xs:decimal(.)) * xs:decimal(100)) div xs:decimal(100)`

> Sum of Invoice line net amount (BT-106) = Σ Invoice line net amount (BT-131).

- Level: error
- Rule sets: EN 16931 rules 1.3.16 (CII), Factur-X EN 16931 rules 1.09.2
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `xs:decimal(ram:LineTotalAmount) = round(xs:decimal(sum(../../ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount)) * xs:decimal(100)) div xs:decimal(100)`

## Why it fails

- A line was added, removed or changed after `cbc:LineExtensionAmount` in `cac:LegalMonetaryTotal` was calculated.
- Line amounts were rounded differently from the total: each line net amount (BT-131) is rounded to two decimals first, and the total is the sum of those rounded amounts.
- Credit note lines or lines with a negative amount were left out of the sum.

## How to fix it

- Recalculate BT-106 as the sum of every line's `cbc:LineExtensionAmount` (`ram:LineTotalAmount` in CII), using the already rounded line amounts.

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