ZeRechnung
Language: English

Open-source Go package · MIT license

E-invoices in Go, from the PDFs you already make

Keep generating your invoice PDFs the way you do today. ZeRechnung adds the XML invoice and the metadata the standard requires, and the PDF becomes a compliant Factur-X or ZUGFeRD e-invoice. It also reads and validates the invoices you receive.

go get github.com/ritoon/zerechnung

Version 0: the API may still change before v1.

The Go gopher, in glasses and a paper boat hat, reads an invoice ledger at a desk with a typewriter, between stacks of invoices.

What it does

One package for the whole life of an e-invoice, on the sending side and on the receiving side.

Create

Turn the PDF your application renders into a Factur-X or ZUGFeRD invoice. Totals and the VAT breakdown are worked out with exact decimals, and an invalid invoice is refused before anything is written.

Read

Read hybrid PDFs and plain XML, in CII or UBL, from every ZUGFeRD version since 1.0. Data the model has no field for is kept, and written back in place.

Validate

Check the schemas, the EN 16931 rules, the profile rules and the national rules of France, Germany, the Netherlands and Italy, as well as Peppol. Each finding gives the official rule ID and the XPath of the element.

Convert

Convert between CII, UBL, FatturaPA and Facturae, and rewrite a PDF as PDF/A-3 when that needs no PDF engine. When it does, you get the reasons, page by page.

Why ZeRechnung

  • Pure Go, standard library only

    No CGO, no Java, no external binary, no network call. go get is all the setup there is.

  • Measured against the reference validators

    Every pull request compares the results with KoSIT, Mustang and veraPDF, invoice by invoice. A new difference fails the build.

  • Fast

    Reading and fully validating a typical invoice takes about 25 µs, five times less than with the next fastest Go package.

  • Your PDF stays as it is

    The XML is added with an incremental update. The original bytes are untouched, so an existing signature remains valid.

Formats and countries

One invoice model, invoice.Invoice, for every syntax: converting from one to another is a parse and a marshal.

FormatCountriesReadWriteValidate
Factur-X 1.0x / ZUGFeRD 2.xCII · profiles MINIMUM to EXTENDED, and EXTENDED-CTC-FRFRDEyesyesyes
XRechnung 3.0CII · UBLDEyesyesyes
Peppol BIS Billing 3.0CII · UBLEUyesyesyes
NLCIUSCII · UBLNLyesyesyes
CIUS-ITCII · UBLITyesyesyes
UBL 2.1Invoice · CreditNote · EN 16931EUyesyesyes
FatturaPA 1.2FPA12 · FPR12ITyesyesthrough CII (CIUS-IT)
Facturae 3.2.x3.2 · 3.2.1 · 3.2.2ESyesyesXSD schema; EN 16931 through UBL or CII
ZUGFeRD 1.0CIIDEyesas Factur-Xminimal checks

How accurate is it?

Every pull request runs the reference validators on the official test corpora and compares their results with those of ZeRechnung, invoice by invoice.

128 / 128

KoSIT

XRechnung invoices with exactly the same errors as the KoSIT validator.

241 / 282

Mustang

invoices with the same errors as Mustang. Each difference comes from the references themselves and is explained.

283 / 290

NPa

NLCIUS files with the same rules as the Dutch NPa validators. The other differences are justified.

609 / 614

veraPDF

invalid PDF/A files of the veraPDF corpus caught by a rule of the right clause.

Method and limitations, on the wiki

Get started

  1. Install the package. It needs Go 1.24 or later.

    Shell
    go get github.com/ritoon/zerechnung
  2. Turn your PDF into a Factur-X invoice.

    Go
    pdf, err := zerechnung.Create(host, inv, &zerechnung.CreateOptions{
    	Calculate: true,                // totals and VAT breakdown
    	Validate:  &validate.Options{}, // refuse an invalid invoice
    })
  3. Validate an invoice you received, with the national rules of the seller's country.

    Go
    report, _, err := zerechnung.Check(pdf, &validate.Options{Auto: true})
    if err != nil {
    	log.Fatal(err)
    }
    for _, f := range report.Errors() {
    	fmt.Println(f)
    }
  4. Or use the command line. validate exits with code 1 on errors, so it fits in a CI pipeline as is.

    Shell
    go install github.com/ritoon/zerechnung/cmd/zerechnung@latest
    zerechnung validate -auto invoice.pdf

Open source, and open to contributions

ZeRechnung is free software under the MIT license. Bug reports, differences with a reference validator and missing rules are welcome.

Open an issue

Translations are open to everyone. Spotted a mistake in your language? Edit this translation