Skip to content

Introduction ​

einvoice-ts reads, builds, validates and writes electronic invoices and credit notes in the UBL syntax of Peppol BIS Billing 3.0, the Peppol profile of the European standard EN 16931. It is written in TypeScript, ships as ES modules and uses no Node.js APIs, so the same code runs on a server and in a browser.

What it does ​

  • Build an invoice from the facts you know. createInvoice() fills in the identifiers the syntax requires and computes the line amounts, the VAT breakdown and the totals.
  • Serialize a document to UBL 2.1 XML with serialize(). Equal documents give identical XML.
  • Parse UBL XML into a typed model with parse(). Structural problems are reported, not thrown.
  • Validate a document against the EN 16931, Peppol and Danish rules with validate(), without a Schematron or XSLT engine. Each issue carries the official rule id, its message, the XPath of the element and a link to the rule's page on docs.peppol.eu.
  • Extend the rules: compose rulesets, add your own rules, disable or soften existing ones.

It does not send invoices over the Peppol network (that is the job of an access point) and it does not render PDFs.

Only the validator validates

createInvoice(), parse() and serialize() never check a document against the rules, so what they return can be invalid. Call validate() or validateXml() before you send a document or accept one.

The packages ​

PackageWhat it holdsDepends on
einvoice-tsEverything below, re-exported, plus validateXml()the four packages below
@einvoice-ts/coreModel types, createInvoice(), Decimal, code lists, runtime schema, errorsnothing
@einvoice-ts/parserparse(), parseInvoice(), parseCreditNote() and the structural diagnosticscore, @rgrove/parse-xml
@einvoice-ts/serializerserialize()core
@einvoice-ts/validatorvalidate(), assertValid(), the built-in rulesets and the extension APIcore

All five are versioned and released together, so any set of them with the same version works together.

Which one to install ​

Install einvoice-ts unless you have a reason not to: one import gives you the whole pipeline. The packages are side-effect free ES modules, so a bundler drops what you do not use.

Install single packages when you need only part of the pipeline and want the dependency to say so: @einvoice-ts/core and @einvoice-ts/serializer to emit invoices, or @einvoice-ts/validator to check documents you build. The validator never loads the XML parser. See Installation.

Status ​

The current release implements Peppol BIS Billing 3.0.22 with its EN 16931 rules, its Peppol rules and the Danish national rules. It also implements CIUS-ES-FACE 1.0.0, for invoices sent to Spanish public administrations through FACe. The other national rule packs of the Peppol release are not implemented yet; see Specification versions and the FAQ.

MIT licensed. Specification material belongs to OpenPeppol, CEN and OASIS (see NOTICE). Peppol is a trademark of OpenPeppol AISBL; this project is not affiliated with it.