# BR-CO-12 Sum of document charges must match total

Sum of charges on document level (BT-108) shall equal the sum of all document level charge amounts (BT-99): BT-108 = Σ BT-99.

## Problem Description

Sum of charges on document level (BT-108) shall equal the sum of all document level charge amounts (BT-99): BT-108 = Σ BT-99.

> **ERROR**: XRechnung 3.0

## Context and Significance

This EN16931 core calculation rule ties the charge total into the document total chain (BR-CO-13), so any drift breaks the payable amount reconciliation.

## Solution

Recompute BT-108 as the exact arithmetic sum of every document level charge amount (BT-99) and write that value into ChargeTotalAmount.

- validate
- convert

## Valid Examples

- BT-99 = 20.00 and BT-99 = 10.00, BT-108 = 30.00

## Invalid Examples

- BT-99 = 20.00 and BT-99 = 10.00, but BT-108 = 25.00

## Code Examples

### Valid XML
```
<cac:AllowanceCharge>
  <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
  <cbc:Amount currencyID="EUR">20.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:AllowanceCharge>
  <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
  <cbc:Amount currencyID="EUR">10.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:LegalMonetaryTotal>
  <cbc:ChargeTotalAmount currencyID="EUR">30.00</cbc:ChargeTotalAmount>
</cac:LegalMonetaryTotal>
```

### Invalid XML
```
<cac:AllowanceCharge>
  <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
  <cbc:Amount currencyID="EUR">20.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:AllowanceCharge>
  <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
  <cbc:Amount currencyID="EUR">10.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:LegalMonetaryTotal>
  <cbc:ChargeTotalAmount currencyID="EUR">25.00</cbc:ChargeTotalAmount>
</cac:LegalMonetaryTotal>
```

## Affected Fields

- [BT-99 Document level charge amount](/resources/xrechnung/bt-99-document-level-charge-amount)
- [BT-108 Sum of charges on document level](/resources/xrechnung/bt-108-sum-of-charges-on-document-level)

## Related Rules

- [BR-CO-11](/resources/kosit-validator-errors/br-co-11-sum-of-document-allowances-must-match)
- [BR-CO-13](/resources/kosit-validator-errors/br-co-13-invoice-total-without-vat-must-match-totals-chain)

## Validation Tools

- [Official KoSIT Validator](https://erechnungsvalidator.service-bw.de/): Validate your XRechnung files against all BR-DE rules.
- [Convert PDF to XRechnung](/pdf-to-xrechnung): Automatic validation error fixes when converting.

## Related Resources

- [Official Specification](https://xeinkauf.de/xrechnung/)
- [Test Suite](https://github.com/itplr-kosit/xrechnung-testsuite)
- [Complete Error List](/resources/kosit-validator-errors): Overview of all German XRechnung validation rules.
