Attestwire › Rule reference › BR-23
BR-23 Every invoice line must have a unit of measure code
noun · EN 16931 · fatal · BT-130
For a sample invoice, the library reports: Line 1 has no unit of measure code (BT-130). EN 16931 requires a code from UN/ECE Recommendation 20, not a free-text unit — "hours" is not valid, "HUR" is.
- Business term
BT-130- Severity
fatal
The fix
Set line.unitCode to the UN/ECE Rec 20 code: "HUR" hours, "DAY" days, "H87" pieces, "C62" one (a unit of anything), "MTR" metres, "KGM" kilograms, "MON" months. resolveUnitCode() turns a unit word such as "Stk" or "hours" into its code.
A passing value
"unitCode": "HUR"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:
{
"rule": "BR-23",
"field": "BT-130",
"severity": "fatal",
"message": "Line 1 has no unit of measure code (BT-130). EN 16931 requires a code from UN/ECE Recommendation 20, not a free-text unit — \"hours\" is not valid, \"HUR\" is.",
"fix": "Set line.unitCode to the UN/ECE Rec 20 code: \"HUR\" hours, \"DAY\" days, \"H87\" pieces, \"C62\" one (a unit of anything), \"MTR\" metres, \"KGM\" kilograms, \"MON\" months. resolveUnitCode() turns a unit word such as \"Stk\" or \"hours\" into its code.",
"example": "\"unitCode\": \"HUR\"",
"xpath": "/ubl:Invoice/cac:InvoiceLine[1]/cbc:InvoicedQuantity/@unitCode",
"docsUrl": "https://attestwire.com/rules/BR-23"
}
xpath is always a UBL path. On a CII invoice, look for the
matching CII field instead.