DEV Community

Nicolas Sage
Nicolas Sage

Posted on

The EN 16931 errors that reject most e-invoices, and how to fix them

If you generate Factur-X, ZUGFeRD, XRechnung or Peppol invoices, sooner or later a validator answers with something like [BR-CO-14] and a sentence full of BT numbers. These codes come from the European standard EN 16931, and a handful of them account for most rejections. Almost all are about arithmetic and rounding, not XML.

Here are the ones I see most often, what they actually check, and how to fix the code that produces them.

BR-CO-17: VAT is computed per category, not per line

VAT category tax amount (BT-117) = VAT category taxable amount (BT-116) x (VAT category rate (BT-119) / 100), rounded to two decimals.

This is the classic. Many invoicing systems compute VAT on each line, round it, and add the rounded values. EN 16931 does it the other way: sum the net amounts per VAT rate first, then apply the rate once, then round. With enough lines, the two methods differ by a cent and the invoice is rejected.

// Build the VAT breakdown the way EN 16931 expects it
function vatBreakdown(lines) {
  const byRate = new Map();
  for (const l of lines) {
    const key = `${l.category}:${l.rate}`;
    byRate.set(key, (byRate.get(key) ?? 0) + l.netCents);
  }
  return [...byRate].map(([key, taxableCents]) => {
    const [category, rate] = key.split(':');
    return { category, rate: Number(rate), taxableCents, taxCents: Math.round(taxableCents * Number(rate) / 100) };
  });
}
Enter fullscreen mode Exit fullscreen mode

Work in integer cents and round once, at the category level.

BR-CO-10 and BR-S-08: the sums must use rounded line amounts

Sum of Invoice line net amount (BT-106) = Σ Invoice line net amount (BT-131).

Each line net amount (quantity x net price, minus line allowances) is rounded to two decimals, and the document totals are sums of those rounded values. If you sum unrounded values and round at the end, BR-CO-10 fails. BR-S-08 applies the same rule per standard VAT rate: the taxable amount of each rate is the sum of the line net amounts of that rate, plus document-level charges, minus document-level allowances of that rate. A shipping charge declared at document level but forgotten in the 20% bucket is a typical BR-S-08.

BR-CO-13: document-level allowances and charges

Invoice total amount without VAT (BT-109) = Σ Invoice line net amount (BT-131) - Sum of allowances on document level (BT-107) + Sum of charges on document level (BT-108).

Usually a discount applied twice (once on the lines, once at document level), or shipping added to the total but not declared as a charge.

BR-CO-14, BR-CO-15, BR-CO-16: the chain of totals

Invoice total VAT amount (BT-110) = Σ VAT category tax amount (BT-117).

Invoice total amount with VAT (BT-112) = Invoice total amount without VAT (BT-109) + Invoice total VAT amount (BT-110).

Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Paid amount (BT-113) + Rounding amount (BT-114).

Once the breakdown is right, these follow, as long as you derive each total from the previous one instead of recomputing it independently. For an invoice that is already paid (an online order, for instance), declare the prepaid amount so that the amount due is zero.

BR-S-02: no VAT number, no standard-rated line

An Invoice that contains an Invoice line (BG-25) where the Invoiced item VAT category code (BT-151) is "Standard rated" shall contain the Seller VAT Identifier (BT-31), the Seller tax registration identifier (BT-32) and/or the Seller tax representative VAT identifier (BT-63).

Not arithmetic this time: the seller's VAT identifier is simply missing, often because it lives in a settings screen nobody filled in. I hit exactly this one while testing in an accounting sandbox whose company had no VAT number.

Checking an invoice you received

If you are on the receiving end, you rarely have a validator at hand. I built a free reader, Factur-X Viewer (https://facturxviewer.fr/en/reader), that opens Factur-X / ZUGFeRD PDFs and XRechnung, UBL or CII files in the browser and re-runs the arithmetic checks above (line sums, VAT per rate, totals, amount due, IBAN checksum). It is a sanity check, not a full Schematron validation. I also keep one reference page per rule, in French, at https://facturxviewer.fr/erreurs-facture-electronique. I'm the author; corrections and edge cases are welcome in the comments.

Top comments (0)