# BR-CO-11

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

> Sum of allowances on document level (BT-107) = Σ Document level allowance amount (BT-92).

- 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:AllowanceTotalAmount) = (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator=false()]/xs:decimal(cbc:Amount)) * 10 * 10) div 100) or (not(cbc:AllowanceTotalAmount) and not(../cac:AllowanceCharge[cbc:ChargeIndicator=false()]))`

> Sum of allowances on document level (BT-107) = Σ Document level allowance amount (BT-92).

- Level: error
- Rule sets: EN 16931 rules (CII) 1.3.17
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `(not(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator=false()])and not (ram:AllowanceTotalAmount)) or ram:AllowanceTotalAmount = (round(sum(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator=false()]/ram:ActualAmount[1]/xs:decimal(.))* 10 * 10 ) div 100)`

> Sum of allowances on document level (BT-107) = Σ Document level allowance amount (BT-92).

- Level: error
- Rule sets: EN 16931 rules 1.3.16 (CII)
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `(not(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator=false()])and not (ram:AllowanceTotalAmount)) or ram:AllowanceTotalAmount = (round(sum(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator=false()]/ram:ActualAmount[1])* 10 * 10 ) div 100)`

> Sum of allowances on document level (BT-107) = Σ Document level allowance amount (BT-92).

- Level: error
- Rule sets: Factur-X BASIC WL rules 1.09, Factur-X EN 16931 rules 1.09.2
- Context: `//ram:SpecifiedTradeSettlementHeaderMonetarySummation`
- Test: `(not(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator='false'])and not (ram:AllowanceTotalAmount)) or ram:AllowanceTotalAmount = (round(sum(/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator='false']/ram:ActualAmount)* 10 * 10 ) div 100)`

## Why it fails

- `cbc:AllowanceTotalAmount` doesn't equal the sum of the document level allowances (`cac:AllowanceCharge` with `cbc:ChargeIndicator` false), or line allowances were counted in it.

## How to fix it

- Make BT-107 the sum of the document level allowance amounts only, and leave it out when there are none.

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