Rule reference

BR-DEC-11 The allowed maximum number of decimals for the Sum of charges on document level (BT-108) is 2, but you declared 5.005, which has 3

The allowed maximum number of decimals for the Sum of charges on document level (BT-108) is 2, but you declared 5.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. Charges are the usual home of per-unit and percentage-based figures — freight per kilo, a 1.5% handling fee — so this is the total most likely to inherit a long decimal from the arithmetic that produced it.

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-108
Severity
fatal

What the library returns

The exact object in result.errors when this rule fires. Generated by running @attestwire/en16931, not transcribed:

TeachingError
{
  "rule": "BR-DEC-11",
  "field": "BT-108",
  "severity": "fatal",
  "message": "The allowed maximum number of decimals for the Sum of charges on document level (BT-108) is 2, but you declared 5.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. Charges are the usual home of per-unit and percentage-based figures — freight per kilo, a 1.5% handling fee — so this is the total most likely to inherit a long decimal from the arithmetic that produced it.",
  "fix": "Round declaredTotals.chargeTotalAmount to two decimals (5.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\": { \"chargeTotalAmount\": 5.01 }",
  "xpath": "/ubl:Invoice/cac:LegalMonetaryTotal/cbc:ChargeTotalAmount",
  "docsUrl": "https://attestwire.com/rules/BR-DEC-11"
}

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

the shape this field expects
"declaredTotals": { "chargeTotalAmount": 5.01 }

The fix

Round declaredTotals.chargeTotalAmount to two decimals (5.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.

Arrived from a stack trace? The docsUrl on every error links straight here. Something wrong on this page — tell us.