AttestwireRule referenceBR-DEC-01

BR-DEC-01 A document-level allowance amount may have at most two decimals

noun · EN 16931 · fatal · BT-92

For a sample invoice, the library reports: The allowed maximum number of decimals for the document level allowance amount (BT-92) is 2, but allowances[0].amount is 10.005, which has 3.

Business term
BT-92
Severity
fatal

The fix

Round allowances[0].amount to two decimals before you hand it over — 10.01 here. This package exports round2() for it, which avoids the two JavaScript traps: Math.round(1.005 * 100) / 100 gives 1.00, and (2.675).toFixed(2) gives "2.67".

A passing value

the shape this field expects
"amount": 10.01

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-DEC-01",
  "field": "BT-92",
  "severity": "fatal",
  "message": "The allowed maximum number of decimals for the document level allowance amount (BT-92) is 2, but allowances[0].amount is 10.005, which has 3. The schematron measures the digits after the decimal point in the serialised XML, so a value that merely *displays* as two decimals still fails when the underlying number carries more. An allowance amount usually arrives as a percentage of something — 3% settlement discount, 1.5% surcharge — and a percentage of a two-decimal figure is almost never a two-decimal figure. EN 16931 wants the *result* rounded, once, before it is written.",
  "fix": "Round allowances[0].amount to two decimals before you hand it over — 10.01 here. This package exports round2() for it, which avoids the two JavaScript traps: Math.round(1.005 * 100) / 100 gives 1.00, and (2.675).toFixed(2) gives \"2.67\".",
  "example": "\"amount\": 10.01",
  "xpath": "/ubl:Invoice/cac:AllowanceCharge[1]/cbc:Amount",
  "docsUrl": "https://attestwire.com/rules/BR-DEC-01"
}

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