Attestwire › Rule reference › BR-DEC-12
BR-DEC-12 The total amount without VAT may have at most two decimals
noun · EN 16931 · fatal · BT-109
For a sample invoice, the library reports: The allowed maximum number of decimals for the Invoice total amount without VAT (BT-109) is 2, but you declared 1500.001, which has 3.
- Business term
BT-109- Severity
fatal
The fix
Round declaredTotals.taxExclusiveAmount to two decimals before assigning it (1500.00 here), using half-up rounding away from zero. This package exports round2() for exactly this, and it avoids the two JavaScript traps: Math.round(1.005 * 100) / 100 gives 1.00, and (2.675).toFixed(2) gives "2.67". Alternatively drop declaredTotals and let the library compute the totals, which it always rounds correctly.
A passing value
"declaredTotals": { "taxExclusiveAmount": 1500.00 }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-DEC-12",
"field": "BT-109",
"severity": "fatal",
"message": "The allowed maximum number of decimals for the Invoice total amount without VAT (BT-109) is 2, but you declared 1500.001, which has 3. The rule is written against the serialised value — the schematron measures the digits after the decimal point in the XML — so a value that merely *displays* as two decimals still fails if the underlying number carries more. This total inherits its precision from BT-106; check that one too.",
"fix": "Round declaredTotals.taxExclusiveAmount to two decimals before assigning it (1500.00 here), using half-up rounding away from zero. This package exports round2() for exactly this, and it avoids the two JavaScript traps: Math.round(1.005 * 100) / 100 gives 1.00, and (2.675).toFixed(2) gives \"2.67\". Alternatively drop declaredTotals and let the library compute the totals, which it always rounds correctly.",
"example": "\"declaredTotals\": { \"taxExclusiveAmount\": 1500.00 }",
"xpath": "/ubl:Invoice/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount",
"docsUrl": "https://attestwire.com/rules/BR-DEC-12"
}
xpath is always a UBL path. On a CII invoice, look for the
matching CII field instead.