Rule reference

BR-CO-23 The reason (BT-139) and the reason code (BT-140) on the invoice line allowance at lines[0].allowances[0] are individually optional terms, and this constraint — separate from BR-42, which is the cardinality rule on the group — is what rules out the one combination those cardinalities would otherwise permit: neither present

The reason (BT-139) and the reason code (BT-140) on the invoice line allowance at lines[0].allowances[0] are individually optional terms, and this constraint — separate from BR-42, which is the cardinality rule on the group — is what rules out the one combination those cardinalities would otherwise permit: neither present. Supplying both is allowed and preferable, because the code is machine-actionable and the text is what a person reads.

This rule is implemented and its error payload below is real, but the long-form write-up — normative text, worked example, divergence note — is not written yet. Everything the library knows about this rule is on this page. Ask and we will prioritise it.

Business term
BT-139 / BT-140
Severity
fatal

What the library returns

The exact object in result.errors when this rule fires. Generated by running @attestwire/en16931, not transcribed:

TeachingError
{
  "rule": "BR-CO-23",
  "field": [
    "BT-139",
    "BT-140"
  ],
  "severity": "fatal",
  "message": "The reason (BT-139) and the reason code (BT-140) on the invoice line allowance at lines[0].allowances[0] are individually optional terms, and this constraint — separate from BR-42, which is the cardinality rule on the group — is what rules out the one combination those cardinalities would otherwise permit: neither present. Supplying both is allowed and preferable, because the code is machine-actionable and the text is what a person reads.",
  "fix": "Add lines[0].allowances[0].reason, lines[0].allowances[0].reasonCode, or both. Where no UNCL 5189 code describes what you are deducting, omit the code entirely and use free text — the lists have no \"other\" entry, and an invented code fails BR-CL-19.",
  "example": "\"reason\": \"Special agreement\", \"reasonCode\": \"100\"",
  "xpath": "/ubl:Invoice/cac:InvoiceLine[1]/cac:AllowanceCharge[1]/cbc:AllowanceChargeReasonCode",
  "docsUrl": "https://attestwire.com/rules/BR-CO-23"
}

xpath locates the element in the generated UBL document, which is where a KoSIT or Peppol validator will report the same problem.

A passing value

the shape this field expects
"reason": "Special agreement", "reasonCode": "100"

The fix

Add lines[0].allowances[0].reason, lines[0].allowances[0].reasonCode, or both. Where no UNCL 5189 code describes what you are deducting, omit the code entirely and use free text — the lists have no "other" entry, and an invented code fails BR-CL-19.

Arrived from a stack trace? The docsUrl on every error links straight here. Something wrong on this page — tell us.