AttestwireRule referenceBR-CO-21

BR-CO-21 A document-level allowance needs a reason, a reason code, or both

noun · EN 16931 · fatal · BT-97 / BT-98

For a sample invoice, the library reports: Taken individually, the reason (BT-97) and the reason code (BT-98) on the document level allowance at allowances[0] are both optional terms — which is why this constraint exists separately from BR-33: it is the co-occurrence rule that forbids the one combination the cardinalities allow, namely neither.

Business term
BT-97 / BT-98
Severity
fatal

The fix

Add allowances[0].reason, allowances[0].reasonCode, or both. If no UNCL 5189 code fits what you are discounting, omit the code and write the reason as free text — the list has no "other" entry, and inventing a code fails BR-CL-19.

A passing value

the shape this field expects
"reason": "Discount", "reasonCode": "95"

What the library returns

The full error returned by @attestwire/en16931. It includes the rule ID, affected field and suggested correction. Developers can use this object in their application:

TeachingError
{
  "rule": "BR-CO-21",
  "field": [
    "BT-97",
    "BT-98"
  ],
  "severity": "fatal",
  "message": "Taken individually, the reason (BT-97) and the reason code (BT-98) on the document level allowance at allowances[0] are both optional terms — which is why this constraint exists separately from BR-33: it is the co-occurrence rule that forbids the one combination the cardinalities allow, namely neither. Supplying both is explicitly permitted and is usually the better answer, since the code is what a receiving system can act on automatically and the text is what a person reads.",
  "fix": "Add allowances[0].reason, allowances[0].reasonCode, or both. If no UNCL 5189 code fits what you are discounting, omit the code and write the reason as free text — the list has no \"other\" entry, and inventing a code fails BR-CL-19.",
  "example": "\"reason\": \"Discount\", \"reasonCode\": \"95\"",
  "xpath": "/ubl:Invoice/cac:AllowanceCharge[1]/cbc:AllowanceChargeReasonCode",
  "docsUrl": "https://attestwire.com/rules/BR-CO-21"
}

xpath is always a UBL path. On a CII invoice, look for the matching CII field instead.