BR-DEC-10 The allowed maximum number of decimals for the Sum of allowances on document level (BT-107) is 2, but you declared 10.005, which has 3
The allowed maximum number of decimals for the Sum of allowances on document level (BT-107) is 2, but you declared 10.005, which has 3. The rule is written against the serialised value — the schematron counts the characters after the decimal point in the XML — so the check is about what gets written, not about what the number "really" is. A total that carries extra decimals when its parts do not means the parts were added before they were rounded. EN 16931 requires the other order — round each document level allowance amount (BT-92) to two decimals, then sum.
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-107- Severity
fatal
What the library returns
The exact object in result.errors when this rule fires.
Generated by running @attestwire/en16931, not transcribed:
{
"rule": "BR-DEC-10",
"field": "BT-107",
"severity": "fatal",
"message": "The allowed maximum number of decimals for the Sum of allowances on document level (BT-107) is 2, but you declared 10.005, which has 3. The rule is written against the serialised value — the schematron counts the characters after the decimal point in the XML — so the check is about what gets written, not about what the number \"really\" is. A total that carries extra decimals when its parts do not means the parts were added before they were rounded. EN 16931 requires the other order — round each document level allowance amount (BT-92) to two decimals, then sum.",
"fix": "Round declaredTotals.allowanceTotalAmount to two decimals (10.01 here) using half-up rounding away from zero, for which this package exports round2(). Alternatively drop declaredTotals and let the library compute the totals, which it always rounds correctly.",
"example": "\"declaredTotals\": { \"allowanceTotalAmount\": 10.01 }",
"xpath": "/ubl:Invoice/cac:LegalMonetaryTotal/cbc:AllowanceTotalAmount",
"docsUrl": "https://attestwire.com/rules/BR-DEC-10"
}
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
"declaredTotals": { "allowanceTotalAmount": 10.01 }The fix
Round declaredTotals.allowanceTotalAmount to two decimals (10.01 here) using half-up rounding away from zero, for which this package exports round2(). Alternatively drop declaredTotals and let the library compute the totals, which it always rounds correctly.