SchemaGuard by Ironbark Digital · EN 16931 / Peppol / XRechnung Reference
← All 294 EN 16931 / Peppol Rules & Live Validator
FATAL Official EN 16931 / Peppol / CIUS Rule BT/BG Fields: BT-142

BR-DEC-28 — E-Invoice Validation Rule & Fix

Fixture ID: lineAllowanceOverPrecise · XPath: /ubl:Invoice/cac:InvoiceLine[1]/cac:AllowanceCharge[2]/cbc:BaseAmount

1. Why This Rule Triggers (Diagnostic Message)

The allowed maximum number of decimals for the invoice line charge base amount (BT-142) is 2, but lines[0].charges[0].baseAmount is 10.005, which has 3. The constraint is on the serialised value, so it is about what reaches the XML rather than about what your variable holds — and the line is where over-precision starts, since every document total downstream of it inherits the drift. A base amount is normally lifted straight out of a subtotal your own system computed, so it carries whatever precision that computation left behind. It is also the number the percentage is applied to, so an over-precise base tends to produce an over-precise amount alongside it.

2. How to Fix BR-DEC-28

Round lines[0].charges[0].baseAmount to two decimals before assigning it (10.01 here). Use half-up rounding away from zero — this package exports round2(), which handles the cases Math.round and toFixed get wrong.

3. Valid Code / Payload Example

"baseAmount": 10.01
Test & Validate XML / JSON in Live SchemaGuard Validator →