Skip to content

Non-Peppol EN 16931 invoices

Not every EN 16931 invoice travels over Peppol. The customization id (BT-24) decides which rules validate() runs by default, and you can register your own composition for any id.

A plain EN 16931 invoice

With the CEN id, or any id that does not start with the Peppol one, only the EN 16931 rules run, so you get no Peppol-specific errors:

ts
const cenInvoice = createInvoice({
  ...baseInvoice,
  customizationId: 'urn:cen.eu:en16931:2017',
});

const cenRules = validate(cenInvoice).ruleset.ids; // ['en16931']: no Peppol rules

Spanish invoices are an example: Peppol has no Spanish national rules, so they are validated with EN 16931, plus Peppol when they declare the Peppol id.

Register a composition for another CIUS

ts
const EXAMPLE_CIUS = 'urn:cen.eu:en16931:2017#compliant#urn:example.org:cius:1.0';

const exampleCius = defineRuleset({
  id: 'example-cius',
  version: '1.0.0',
  requires: [en16931Ruleset],
  rules: [
    rule.custom('EX-R-001', {
      severity: 'fatal',
      message: 'The buyer reference (BT-10) is mandatory in this CIUS.',
      bt: ['BT-10'],
      at: 'document',
      test: (document, ctx) => ctx.normSpace(document.buyerReference) !== '',
    }),
  ],
});

registerRuleset({ customizationId: EXAMPLE_CIUS, ruleset: [en16931Ruleset, exampleCius] });

const ciusInvoice = createInvoice({ ...baseInvoice, customizationId: EXAMPLE_CIUS });
const ciusRules = validate(ciusInvoice).ruleset.ids; // ['en16931', 'example-cius']

A registration applies to the exact id, or to every id that starts with it when you pass matchPrefix: true. You can register the CEN id itself too. See Rulesets and extensions for writing the ruleset.

Add the Danish rules

National rules are opt-in

The official Peppol validator applies national rules by the supplier's country; this library does not. Add dkRuleset to validate the way it does for Danish suppliers.

ts
const danishRules = validate(createInvoice(baseInvoice), {
  ruleset: [en16931Ruleset, peppolRuleset, dkRuleset],
}).ruleset.ids; // ['en16931', 'peppol', 'dk']: the DK rules apply to Danish suppliers only

The Danish rules are the only national rules in this release.

MIT licensed. Specification artefacts belong to OpenPEPPOL, CEN and OASIS.