einvoice / EN 16931 / XRechnung rule reference

BR-CO-23

What this rule means and how to fix it

Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.

Jeder NACHLASS AUF EBENE DER RECHNUNGSPOSITION (BG-27) muss einen Grund für den Nachlass auf Ebene der Rechnungsposition (BT-139) oder einen Code für den Grund des Nachlasses auf Ebene der Rechnungsposition (BT-140) oder beides enthalten.

Deutsche Fassung: Übersetzung der gleichen BT/BG-Semantik (translation — not the official assert).

Requires
Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.
Business terms
BG-27 BT-139 BT-140
Syntax
Binds the UBL-2.1 Invoice / CreditNote syntax and the UN/CEFACT-CII syntax
Location (UBL-2.1 path)
//cac:InvoiceLine/cac:AllowanceCharge[cbc:ChargeIndicator = false()]
Fix
Add the required element at `//cac:InvoiceLine/cac:AllowanceCharge[cbc:ChargeIndicator = false()]`: Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.
Fix (Deutsch)
Ergänzen Sie das erforderliche Element bei `//cac:InvoiceLine/cac:AllowanceCharge[cbc:ChargeIndicator = false()]`: Jeder NACHLASS AUF EBENE DER RECHNUNGSPOSITION (BG-27) muss einen Grund für den Nachlass auf Ebene der Rechnungsposition (BT-139) oder einen Code für den Grund des Nachlasses auf Ebene der Rechnungsposition (BT-140) oder beides enthalten.
Severity
fatal
Provenance source
en16931-ubl
Provenance assert

Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.

The Location above is a UBL-2.1 path, and no UN/CEFACT-CII path for this rule is published here; Fix and Fix (Deutsch), verbatim from remediation_catalog.json and not reworded here; the UN/CEFACT-CII binding of this rule is differentially proven against the official CEN EN 16931 1.3.16 Schematron.

Where to check the fix: paste the corrected invoice into the browser validator at /einvoice/validate/ — it runs this same engine locally in your browser, with no upload, and stops reporting BR-CO-23 once the edit lands.

Korrektur prüfen: Laden Sie die geänderte Rechnung in den Browser-Validator unter /einvoice/validate/ — er führt dieselbe Engine lokal im Browser aus, ohne Upload, und meldet BR-CO-23 nicht mehr, sobald die Korrektur greift.

The same invoice, failing and fixed

Neither block below is hand-written, and neither is an illustration: both are cut verbatim out of corpus/cen-en16931/test/Invoice-unit-UBL/BR-CO-23.xml, the vendored unit test the CEN EN 16931 project ships for this rule. The people who wrote the Schematron wrote these two documents and labelled them <error>BR-CO-23</error> and <success>BR-CO-23</success>. They are published here only because this engine agreed with that labelling: it reported BR-CO-23 for the first document and did not report it for the second, under --profile en16931.

UBL Invoice — fails

The upstream case description: “Trigger error if a Invoice line allowance (BG-20) does not contain a Invoice line allowance reason or a Invoice line allowance reason code, or both.”

<Invoice
	xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
	xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
	xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
	<cac:InvoiceLine>
	<cac:AllowanceCharge>
		<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
		<!--<cbc:AllowanceChargeReasonCode>75</cbc:AllowanceChargeReasonCode>
		<cbc:AllowanceChargeReason>Promotion discount</cbc:AllowanceChargeReason>-->
	</cac:AllowanceCharge>
	</cac:InvoiceLine>
</Invoice>

UBL Invoice — passes

The upstream case description: “Verify that each Invoice line allowance (BG-20) contain a Invoice line allowance reason or a Invoice line allowance reason code, or both.”

<Invoice
	xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
	xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
	xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
	<cac:InvoiceLine>
	<cac:AllowanceCharge>
		<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
		<cbc:AllowanceChargeReasonCode>75</cbc:AllowanceChargeReasonCode>
		<cbc:AllowanceChargeReason>Promotion discount</cbc:AllowanceChargeReason>
	</cac:AllowanceCharge>
	</cac:InvoiceLine>
</Invoice>

What the engine reports for the failing document

{
  "element": "cac:InvoiceLine[1]/cac:AllowanceCharge/cbc:AllowanceChargeReason",
  "field": "cac:InvoiceLine[1]/cac:AllowanceCharge/cbc:AllowanceChargeReason",
  "fix_hint": "Add the required element at `//cac:InvoiceLine/cac:AllowanceCharge[cbc:ChargeIndicator = false()]`: Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.",
  "location": "//cac:InvoiceLine/cac:AllowanceCharge[cbc:ChargeIndicator = false()]",
  "message": "Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.",
  "rule": "BR-CO-23",
  "severity": "fatal",
  "terms": [
    "BG-27",
    "BT-139",
    "BT-140"
  ],
  "title": "Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both."
}

Rule ids reported for the failing document: BR-01 BR-02 BR-03 BR-04 BR-05 BR-06 BR-07 BR-08 BR-10 BR-21 BR-22 BR-23 BR-24 BR-25 BR-26 BR-27 BR-41 BR-42 BR-CO-04 BR-CO-18 BR-CO-23. For the corrected document: BR-01 BR-02 BR-03 BR-04 BR-05 BR-06 BR-07 BR-08 BR-10 BR-21 BR-22 BR-23 BR-24 BR-25 BR-26 BR-27 BR-41 BR-CL-19 BR-CO-04 BR-CO-18.

Read that pair of lists honestly. A unit case is not a complete invoice: the upstream suite strips the document down to the elements this rule reads, so the engine also reports every mandatory element the fragment leaves out — 20 other rule ids here. Those are noise for this page. The signal is the difference: BR-CO-23 is reported for the failing document and gone for the corrected one (so are BR-42, which the same edit also clears).

Reproduce it yourself: save the failing block as invoice.xml and run einvoice validate invoice.xml --profile en16931 --format json, or paste it into the browser validator, which runs this same engine locally with no upload. Then apply the edit the passing block shows and run it again.

Everything here is free and open source — pick up whatever helps, at your own pace: