# BR-CO-07 Line allowance reason and code must agree

The invoice line allowance reason code (BT-140) and the invoice line allowance reason (BT-139) shall indicate the same type of allowance reason.

## Problem Description

The invoice line allowance reason code (BT-140) and the invoice line allowance reason (BT-139) shall indicate the same type of allowance reason.

> **ERROR**: XRechnung 3.0

## Context and Significance

This EN16931 core rule enforces semantic agreement between coded and free-text allowance reasons at line level, mirroring the document-level rule BR-CO-05.

## Solution

Within the invoice line allowance, make the free-text reason (BT-139) and the coded reason (BT-140) describe the same allowance.

- validate
- convert

## Valid Examples

- BT-140 = 95 (Discount) with BT-139 = "Sample discount"

## Invalid Examples

- BT-140 = 95 (Discount) with BT-139 = "Packaging surcharge"

## Code Examples

### Valid XML
```
<cac:InvoiceLine>
  <cac:AllowanceCharge>
    <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
    <cbc:AllowanceChargeReasonCode>95</cbc:AllowanceChargeReasonCode>
    <cbc:AllowanceChargeReason>Sample discount</cbc:AllowanceChargeReason>
    <cbc:Amount currencyID="EUR">2.00</cbc:Amount>
  </cac:AllowanceCharge>
</cac:InvoiceLine>
```

### Invalid XML
```
<cac:InvoiceLine>
  <cac:AllowanceCharge>
    <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
    <cbc:AllowanceChargeReasonCode>95</cbc:AllowanceChargeReasonCode>
    <cbc:AllowanceChargeReason>Packaging surcharge</cbc:AllowanceChargeReason>
    <cbc:Amount currencyID="EUR">2.00</cbc:Amount>
  </cac:AllowanceCharge>
</cac:InvoiceLine>
```

## Affected Fields

- [BT-139 Invoice line allowance reason](/resources/xrechnung/bt-139-invoice-line-allowance-reason)
- [BT-140 Invoice line allowance reason code](/resources/xrechnung/bt-140-invoice-line-allowance-reason-code)

## Related Rules

- [BR-CO-05](/resources/kosit-validator-errors/br-co-05-allowance-reason-code-match)
- [BR-CO-23](/resources/kosit-validator-errors/br-co-23-line-allowance-reason-required)

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