# E-invoicing: XRechnung and ZUGFeRD

> Create, receive and check e-invoices in SAPUGO. XRechnung (CII and UBL) and ZUGFeRD, checked against the official rules, with the XML kept as the original.

An e-invoice is an invoice in a structured format that software can read without retyping: an XML file that follows the European standard EN 16931. In Germany the formats are **XRechnung** and **ZUGFeRD**. A PDF sent by email is not an e-invoice, even when it looks like one.

SAPUGO creates, reads and checks both formats in [workflows](/docs/workflows). Every file is checked against the official rules before it goes out, and the XML is kept as the original.

> **Note:** This page explains how SAPUGO handles e-invoices. It is not tax advice. Ask your tax adviser which rules apply to your business.

## The dates in Germany

| From | What applies |
| --- | --- |
| 1 January 2025 | Every business must be able to **receive** e-invoices from other businesses in Germany. |
| 1 January 2027 | Businesses with more than €800,000 turnover in the previous year must **send** e-invoices to other businesses. |
| 1 January 2028 | Every business must send e-invoices to other businesses. |

Invoices up to €250 and travel tickets are exempt. Small businesses under § 19 UStG (Kleinunternehmer) do not have to send e-invoices, but they must be able to receive them.

## What SAPUGO supports

| Format | Create | Read | Notes |
| --- | --- | --- | --- |
| XRechnung, CII syntax | Yes | Yes | The German standard. Required by public buyers. |
| XRechnung, UBL syntax | Yes | Yes | The same content in the other syntax. |
| ZUGFeRD EN 16931 | Yes | Yes | A PDF with the XML inside. People read the PDF, software reads the XML. |
| ZUGFeRD EXTENDED | Yes | Yes | EN 16931 plus extra fields. |
| ZUGFeRD XRECHNUNG | Yes | Yes | An XRechnung inside a ZUGFeRD PDF. |
| ZUGFeRD BASIC | No | Yes | Read and checked. |
| ZUGFeRD MINIMUM and BASIC WL | No | Yes | Read, but flagged: they carry no invoice lines and are not e-invoices under German law. |

Invoices and credit notes work in every format.

## Which format to send

- Public buyers (authorities, municipalities): **XRechnung**. They give you a **Leitweg-ID**, which goes into the buyer reference.
- Businesses that want to read the invoice as a PDF too: **ZUGFeRD EN 16931**.
- Businesses that only process XML: **XRechnung** in the syntax they ask for, usually CII.

Store the format on each customer, for example in a [single select](/docs/columns/single-select) property, and pass it to **Generate E-Invoice**. One workflow can then send each customer the format they want.

## Send an e-invoice

1. Add **Generate E-Invoice**. Connect the invoice number, the dates, the seller, the buyer and the lines from your invoice record. Set **format** from the customer.
2. Keep **check_official** on. The step computes line amounts, the VAT breakdown and the totals, checks the required details, then checks the file against the official rules.
3. Continue from **Valid**. For ZUGFeRD, add **Generate Document** with your invoice template, then **Embed E-Invoice in PDF** with that PDF and the XML from **Generate E-Invoice**.
4. Store the file on the invoice record with **Upload Attachment**, in a [Files](/docs/columns/files) property such as "E-invoice".
5. Send it with **Send Email**. See [Attach files to an email](/docs/workflows/nodes/people#attach-files-to-an-email).
6. On **Invalid**, write the problems to the record and stop. Send nothing.

> **Warning:** Never send from the **Invalid** branch. An invalid e-invoice counts as not sent, and the buyer may reject it.

Lines, seller, buyer and payment are structs. Build them with **Make Struct**, or ask the assistant in the workflow editor to wire them from your tables.

## The details an e-invoice needs

| Detail | Pin | Needed for |
| --- | --- | --- |
| Invoice number, issue date, document type, currency | **number**, **issue_date**, **type_code**, **currency** | All formats |
| Due date or payment terms, when an amount is due | **due_date**, **payment.terms** | All formats |
| Seller name and address with country | **seller** | All formats |
| Seller VAT ID or tax number, when VAT is charged | **seller.vat_id**, **seller.tax_number** | All formats |
| Buyer name and address with country | **buyer** | All formats |
| For each line: name, quantity, unit, net price, VAT category and rate | **lines** | All formats |
| Buyer reference (for public buyers, the Leitweg-ID) | **buyer_reference** | XRechnung |
| Seller contact: name, phone, email | **seller.contact** | XRechnung |
| Seller and buyer city and postcode | **seller.address**, **buyer.address** | XRechnung |
| Seller and buyer electronic address | **seller.electronic_address**, **buyer.electronic_address** | XRechnung |
| Payment means, and the IBAN for a transfer | **payment.means**, **payment.iban** | XRechnung |

A missing detail is reported on **validation** with the pin it belongs to, such as `buyer.address.city`, before the official check runs.

### VAT categories

| Category | Use for | Rate |
| --- | --- | --- |
| `standard` | Normal VAT, such as 19 % or 7 % | The rate |
| `zero_rated` | Goods and services taxed at 0 % | 0 |
| `exempt` | Exempt supplies, and small businesses under § 19 UStG | 0, and set **exemption_reason** |
| `reverse_charge` | The buyer pays the VAT (§ 13b UStG) | 0 |
| `intra_community` | Supplies to businesses in other EU countries | 0 |
| `export` | Exports outside the EU | 0 |
| `not_subject` | Outside the scope of VAT | none |

For `exempt`, set **exemption_reason** on **Generate E-Invoice**, for example "Kleinunternehmer gemäß § 19 UStG". The other zero-rate categories get the standard reason automatically.

### Credit notes

Set **type_code** to `credit_note` and **preceding_invoice** to the invoice number and date the credit note corrects. Enter amounts as positive numbers, as on the original invoice.

## Receive e-invoices

Suppliers send e-invoices by email. Set up a shared inbox and a rule that starts a workflow for each incoming email.

1. In the workflow, add **Break Email** and loop over its **attachments** with **For Each**.
2. Add **Download Attachment** for each attachment, then **Read E-Invoice** with the file.
3. On **Valid**, create the supplier invoice record from **result**, and store the **xml** output in a Files property. That XML is the original.
4. Add **Show E-Invoice as PDF** to store a readable copy next to it, for the people who approve the invoice.
5. On **Invalid**, create the record too, but mark it, and send the problems back to the supplier.
6. On **Not an e-invoice**, the attachment was a plain PDF or another file. Put it on a list for someone to handle.

**Read E-Invoice** reads XRechnung in both syntaxes and every ZUGFeRD and Factur-X PDF, including older ZUGFeRD 2 files.

## Check an e-invoice and fix problems

**Check E-Invoice** checks a file you already have, such as one a customer says they could not process. For a ZUGFeRD PDF it checks the XML and the PDF.

In a test run, click the step to see the **E-invoice check**: whether the file is valid, whether the official rules ran, and each problem with its rule and where it is.

| Rule | What it means | What to fix |
| --- | --- | --- |
| BR-DE-15 | The buyer reference is missing. | Ask the buyer for it. Public buyers give a Leitweg-ID. |
| BR-DE-3 to BR-DE-9 | An address part or the seller contact is missing. | Fill the city, postcode, contact name, phone and email. |
| BR-CO-25 | An amount is due, but there is no due date and no payment terms. | Set **due_date** or **payment.terms**. |
| BR-S-02 | VAT is charged, but the seller has no VAT ID or tax number. | Set **seller.vat_id** or **seller.tax_number**. |
| BR-AE-02 | Reverse charge without the buyer's VAT ID. | Set **buyer.vat_id**. |
| BR-E-10 | Exempt lines without a reason. | Set **exemption_reason**. |
| SAPUGO-REQUIRED | A detail the format needs is empty. | The location names the pin. |
| SAPUGO-NOT-EINVOICE | The file is not an e-invoice. | Ask the sender for XRechnung or ZUGFeRD. |
| SAPUGO-PROFILE | The file is ZUGFeRD MINIMUM or BASIC WL. | Ask the sender for EN 16931 or XRechnung. |

## Keep the originals

The XML is the legal invoice, also inside a ZUGFeRD PDF. Store it unchanged in a Files property on the invoice record, and lock the record once the invoice is issued, for example with a [guard rule](/docs/business-rules/guard). Keep invoices for the retention period your tax adviser names. In Germany that is currently eight years.

  - [File and document steps](/docs/workflows/nodes/files-and-documents#e-invoices): Every e-invoice step, its inputs and its branches.
  - [Documents](/docs/documents): Design the invoice template used for ZUGFeRD PDFs.
  - [Email steps](/docs/workflows/nodes/people#email): Send invoices and read incoming email.

---

Source: https://community.sapugo.app/docs/e-invoicing
