einvoice-mcp
einvoice-mcp
MCP-Server for German e-invoice compliance — XRechnung 3.0 & ZUGFeRD 2.x
An MCP server that enables AI agents (Claude, Cursor, Copilot) to validate, generate, parse, and check compliance of electronic invoices per EN 16931 — without a single line of integration code.
Why This Exists
Germany mandated e-invoice reception for B2B as of January 2025 (BMF 2024-11-15). Issuance mandates follow in 2027 (Vorjahresumsatz > 800K) and 2028 (all businesses). Every German company needs tooling — this MCP server gives AI agents that capability.
Compliance Proof
675 tests | 100% coverage (2106 stmts) | 0 failures | lint clean (ruff + mypy strict)
Run make test to verify.
EN 16931 / XRechnung 3.0 Field Coverage
Every mandatory Business Term is tested in generated XML output:
BT | Field | Test | Result |
BT-1 | Invoice number |
| PASS |
BT-2 | Issue date |
| PASS |
BT-3 | Invoice type code (380/381/384) |
| PASS |
BT-5 | Currency code (EUR) |
| PASS |
BT-10 | Buyer reference / Leitweg-ID |
| PASS |
BT-27 | Seller name |
| PASS |
BT-31 | Seller VAT ID (schemeID=VA) |
| PASS |
BT-32 | Seller tax number (schemeID=FC) |
| PASS |
BT-34 | Seller electronic address (schemeID=EM) |
| PASS |
BT-35..38 | Seller address |
| PASS |
BT-39 | Seller country subdivision |
| PASS |
BT-40 | Seller country code |
| PASS |
BT-41 | Seller contact name (BR-DE-5) |
| PASS |
BT-42 | Seller contact phone |
| PASS |
BT-43 | Seller contact email (BR-DE-7) |
| PASS |
BT-44 | Buyer name |
| PASS |
BT-49 | Buyer electronic address (schemeID=EM) |
| PASS |
BT-50..53 | Buyer address |
| PASS |
BT-54 | Buyer country subdivision |
| PASS |
BT-55 | Buyer country code |
| PASS |
BT-71 | Delivery date (§14 Abs. 4 Nr. 6 UStG) |
| PASS |
BT-20 | Payment terms text |
| PASS |
BT-22 | Invoice note |
| PASS |
BT-73/74 | Service period start/end |
| PASS |
BT-11 | Project reference |
| PASS |
BT-12 | Contract reference |
| PASS |
BT-13 | Purchase order reference |
| PASS |
BT-25 | Preceding invoice number |
| PASS |
BT-81 | Payment means type code |
| PASS |
BT-83 | Remittance information |
| PASS |
BT-84 | IBAN (SEPA credit transfer) |
| PASS |
BT-9 | Due date |
| PASS |
BT-14 | Sales order reference |
| PASS |
BT-29 | Seller registration ID (GLN) |
| PASS |
BT-36/37 | Seller address lines 2/3 |
| PASS |
BT-44 | Buyer contact name |
| PASS |
BT-46 | Buyer contact phone |
| PASS |
BT-47 | Buyer contact email |
| PASS |
BT-51/52 | Buyer address lines 2/3 |
| PASS |
BT-70..80 | Delivery location |
| PASS |
BT-127 | Line item note |
| PASS |
BT-155 | Seller item identifier |
| PASS |
BT-156 | Buyer item identifier |
| PASS |
BT-157 | Standard item ID (GTIN) |
| PASS |
BG-20/21 | Document-level allowances/charges |
| PASS |
BG-27/28 | Line-level allowances/charges |
| PASS |
BT-16 | Despatch advice reference |
| PASS |
BT-18 | Invoiced object identifier |
| PASS |
BT-23 | Business process type |
| PASS |
BT-89 | SEPA mandate reference (BG-19) |
| PASS |
BT-91 | Buyer IBAN (BG-19) |
| PASS |
BT-120 | VAT exemption reason text (BR-E-10) |
| PASS |
BT-121 | VAT exemption reason code |
| PASS |
BT-28 | Seller trading name |
| PASS |
BT-45 | Buyer trading name |
| PASS |
BT-17 | Tender or lot reference |
| PASS |
BT-133 | Buyer accounting reference |
| PASS |
BT-134/135 | Line-level billing period |
| PASS |
BT-147/148 | Gross price / price discount |
| PASS |
BT-158 | Item classification (CPV, etc.) |
| PASS |
BG-11 | Seller tax representative (BT-62..65) |
| PASS |
BG-10 | Payee party (BT-59..61) |
| PASS |
BG-18 | Payment card (BT-87/88) |
| PASS |
BT-159 | Item country of origin |
| PASS |
BG-30 | Item attributes (BT-160/161) |
| PASS |
BT-15 | Receiving advice reference |
| PASS |
BT-71 | Delivery location identifier |
| PASS |
BT-82 | Payment means text |
| PASS |
BG-24 | Supporting documents (BT-122..125) |
| PASS |
Skonto | Payment discount terms |
| PASS |
Calculation Rules
Rule | Description | Test | Result |
BR-CO-14 | TaxTotalAmount = sum of per-group CalculatedAmount |
| PASS |
BR-CO-14 | PDF/XML/API totals use identical per-group rounding |
| PASS |
BR-CO-10 | Line item LineTotalAmount quantized to 0.01 |
| PASS |
BR-DE-23 | IBAN mandatory when PaymentMeansCode=58 |
| PASS |
§14/4/2 | BT-31 or BT-32 must be present |
| PASS |
§14/4/6 | BT-71 or BT-73/74 must be present |
| PASS |
BT-3 | TypeCode validated against EN 16931 codes |
| PASS |
BT-25 | Credit note (381) must reference preceding invoice |
| PASS |
384-BT-25 | Corrective invoice (384) must reference preceding invoice |
| PASS |
RC-COUNTRY | Reverse charge: seller ≠ buyer country advisory |
| PASS |
IC-COUNTRY | Intra-community: seller ≠ buyer country required |
| PASS |
§13b UStG | Reverse charge: seller+buyer VAT IDs, 0% rate |
| PASS |
§4/1b UStG | Intra-community (K): buyer VAT ID, 0% rate |
| PASS |
§19 UStG | Kleinunternehmer: exemption note advisory |
| PASS |
LW-FMT | Leitweg-ID format advisory |
| PASS |
VAT-FMT | German USt-IdNr. format advisory (DE + 9 digits) |
| PASS |
§4/1a UStG | Export (G): 0% tax rate |
| PASS |
§33 UStDV | Kleinbetragsrechnung advisory (≤250€) |
| PASS |
BR-E-10 | Exemption reason required for TaxCategory E |
| PASS |
BR-DE-24 | SEPA DD: mandate (BT-89) + buyer IBAN (BT-91) |
| PASS |
BR-DE-15 | Payment terms (BT-20) required for XRechnung |
| PASS |
BR-DE-20 | Max one payment instruction type (no mix CT+DD) |
| PASS |
CC-BT-87 | Credit card PAN required when code=48 |
| PASS |
REP-BT-63 | Tax rep VAT ID required when BG-11 present |
| PASS |
IBAN | IBAN format validation (ISO 13616) |
| PASS |
BIC | BIC format validation (ISO 9362) |
| PASS |
Parsing Fidelity
Scenario | Description | Test | Result |
SchemeID stripping |
|
| PASS |
Numeric schemeID |
|
| PASS |
Description text |
|
| PASS |
Unicode safety |
|
| PASS |
BT-32 roundtrip | Steuernummer FC generate → parse |
| PASS |
TypeCode roundtrip | 381 Gutschrift generate → parse |
| PASS |
Delivery date roundtrip | BT-71 generate → parse |
| PASS |
Service period roundtrip | BT-73/74 generate → parse |
| PASS |
Electronic address roundtrip | BT-34 generate → parse |
| PASS |
Invoice note roundtrip | BT-22 generate → parse |
| PASS |
Payment terms roundtrip | BT-20 generate → parse |
| PASS |
Payment terms override | BT-20 text overrides days |
| PASS |
Purchase order roundtrip | BT-13 generate → parse |
| PASS |
Contract roundtrip | BT-12 generate → parse |
| PASS |
Project roundtrip | BT-11 generate → parse |
| PASS |
Preceding invoice roundtrip | BT-25 generate → parse |
| PASS |
Remittance roundtrip | BT-83 generate → parse |
| PASS |
Empty scheme stripping |
|
| PASS |
Roundtrip invoice | Generate → Parse → Verify key fields |
| PASS |
Due date roundtrip | BT-9 generate → parse |
| PASS |
Address line 2/3 roundtrip | BT-36/37, BT-51/52 generate → parse |
| PASS |
Buyer contact roundtrip | BT-44/46/47 generate → parse |
| PASS |
Registration ID roundtrip | BT-29 generate → parse |
| PASS |
Sales order roundtrip | BT-14 generate → parse |
| PASS |
Item identifiers roundtrip | BT-155/156/157 generate → parse |
| PASS |
Line item note roundtrip | BT-127 generate → parse |
| PASS |
Delivery location roundtrip | BT-70..80 generate → parse |
| PASS |
Allowance roundtrip | BG-20 generate → parse |
| PASS |
Charge roundtrip | BG-21 generate → parse |
| PASS |
Line allowance roundtrip | BG-27 generate → parse |
| PASS |
Despatch advice roundtrip | BT-16 generate → parse |
| PASS |
Invoiced object roundtrip | BT-18 generate → parse |
| PASS |
Business process roundtrip | BT-23 generate → parse |
| PASS |
SEPA direct debit roundtrip | BG-19 generate → parse |
| PASS |
Skonto roundtrip | PaymentDiscountTerms generate → parse |
| PASS |
BT-133 roundtrip | Buyer accounting reference generate → parse |
| PASS |
Trading names roundtrip | BT-28/BT-45 generate → parse |
| PASS |
Tender reference roundtrip | BT-17 generate → parse |
| PASS |
Exemption reason roundtrip | BT-120/BT-121 generate → parse |
| PASS |
Line period roundtrip | BT-134/BT-135 generate → parse |
| PASS |
Seller tax rep roundtrip | BG-11 generate → parse |
| PASS |
Payee roundtrip | BT-59/60/61 generate → parse |
| PASS |
Payment card roundtrip | BT-87/88 generate → parse |
| PASS |
Gross price roundtrip | BT-147/148 generate → parse |
| PASS |
Classification roundtrip | BT-158 generate → parse |
| PASS |
Country of origin roundtrip | BT-159 generate → parse |
| PASS |
Item attributes roundtrip | BT-160/161 generate → parse |
| PASS |
Receiving advice roundtrip | BT-15 generate → parse |
| PASS |
Delivery location ID roundtrip | BT-71 generate → parse |
| PASS |
Payment means text roundtrip | BT-82 generate → parse |
| PASS |
Supporting docs roundtrip | BG-24 generate → parse |
| PASS |
Supporting docs + tender ref | BG-24 + BT-17 coexistence |
| PASS |
Country subdivision roundtrip | BT-39/BT-54 generate → parse |
| PASS |
Payment means type code roundtrip | BT-81 generate → parse |
| PASS |
Buyer reference roundtrip | BT-10 generate → parse |
| PASS |
Tax rep subdivision roundtrip | BG-11 BT-39 generate → parse |
| PASS |
Combined item features | BT-159 + BG-30 + BT-148 together |
| PASS |
Multi-reference coexistence | BT-17 + BT-18 in same invoice |
| PASS |
Non-ASCII party names | Cyrillic/Chinese names |
| PASS |
All type codes | 380, 381, 384, 389, 875, 876, 877 |
| PASS |
All tax categories | S, Z, E, AE, K, G, O, L, M |
| PASS |
50 line items | Large invoice build + parse |
| PASS |
Mixed tax categories | S + G items in same invoice |
| PASS |
Unicode safety (umlauts) | ÄÖÜäöüß in all text fields |
| PASS |
High-value invoice | 50 line items with high amounts |
| PASS |
Mixed tax rates | 7% + 19% with exact rounding |
| PASS |
Classification version | BT-158-2 version roundtrip |
| PASS |
UBL detection | UBL Invoice/CreditNote rejected |
| PASS |
Defensive handlers | Exception in buyer_reference/tax_rep/payee/exemption |
| PASS |
Pydantic BT mapping | Validation errors show BT numbers |
| PASS |
Tax Category Coverage (All 9 EU VAT Categories)
Category | Code | Description | Result |
Standard | S | 19% / 7% USt | PASS |
Zero | Z | 0% rated | PASS |
Exempt | E | Exempt | PASS |
Reverse charge | AE | Reverse charge (Umkehr der Steuerschuld) | PASS |
Intra-community | K | EU supply (innergemeinschaftliche Lieferung) | PASS |
Export | G | Outside EU (Drittlandslieferung) | PASS |
Not subject | O | No VAT | PASS |
Canary Islands | L | IGIC | PASS |
Ceuta/Melilla | M | IPSI | PASS |
Security Hardening
Attack Vector | Protection | Test | Result |
XXE entity expansion | defusedxml pre-screen |
| PASS |
Billion laughs (entity bomb) | defusedxml pre-screen |
| PASS |
External entity injection | defusedxml pre-screen |
| PASS |
XML bomb (>10 MB) | Size limit |
| PASS |
PDF bomb (>50 MB base64) | Size limit |
| PASS |
Decoded PDF bomb (>50 MB) | Post-decode guard |
| PASS |
KoSIT response bomb | 10 MB + 512 KB cap |
| PASS |
Input reflection in errors | Sanitized |
| PASS |
Error detail leakage | Generic messages |
| PASS |
SSRF via redirect |
| Defense-in-depth | HARDENED |
Supply chain (Docker) | SHA-256 checksum verification |
| HARDENED |
Container privilege | Non-root user (both containers) |
| HARDENED |
Port exposure | KoSIT bound to 127.0.0.1 only |
| HARDENED |
Supply chain (Python) |
|
| HARDENED |
IBAN injection | ISO 13616 format validation |
| HARDENED |
BIC injection | ISO 9362 format validation |
| HARDENED |
Profile Coverage
Profile | Generate | Parse | Validate | Compliance |
XRechnung 3.0 | PASS | PASS | PASS | PASS |
ZUGFeRD EN16931 | PASS | PASS | PASS | PASS |
ZUGFeRD Basic | PASS* | - | - | - |
ZUGFeRD Extended | PASS* | - | - | - |
* Generation produces XML with correct guideline URI; full parse/validate/compliance support planned.
Module Coverage
Module | Lines | Description |
| 16 | Pydantic settings |
| 36 | Custom exceptions |
| 600+ | Pydantic models (invoice, party, line items, results, enums) |
| 633 | 14 German tax scenario prompts |
| 511 | 8 advanced prompts (EU trade, recurring, Schlussrechnung, Proforma, Drittland, Gutschrift) |
| 304 | 5 additional prompts (Berichtigung, RC+Steuervertreter, Teilrechnung, IG deep, Skonto) |
| 1200+ | 24 resources (schemas, reference codes, compliance, SEPA, CPV, BT-23, VAT exemptions, UNCL 5189) |
| 576 | CII XML generation via drafthorse |
| 320 | Flat parameter builder |
| 457 | Party, item, attribute extraction |
| 80 | KoSIT HTTP client |
| 182 | Visual PDF + factur-x embed |
| 720 | CII/ZUGFeRD XML parser |
| 217 | Compliance orchestration |
| 795 | BR-DE/BR-CO field checks |
| 230 | BR-CO-10/11/12/13/14/15/16 math checks |
| 50 | Generate tools |
| 39 | Parse tool |
| 33 | Validation tools |
server.py excluded — FastMCP Context cannot be unit-tested; helpers tested in test_server_helpers.py.
Tools
Tool | Description |
| Validates XRechnung XML against the KoSIT Validator |
| Validates ZUGFeRD PDF (extracts + validates embedded XML) |
| Generates an XRechnung-compliant CII XML invoice |
| Generates a ZUGFeRD hybrid PDF (visual + machine-readable) |
| Parses e-invoices (XML or PDF) into structured data |
| Checks mandatory fields + KoSIT validation with German suggestions |
MCP Resources
Resource URI | Description |
| JSON-Schema für Rechnungspositionen (items-Array) |
| JSON-Schema für Zu-/Abschläge |
| JSON-Schema für Artikelmerkmale (BG-30) |
| JSON-Schema für Belegdokumente (BG-24) |
| Vollständiges JSON-Schema für InvoiceData |
| Rechnungstyp-Codes (380, 381, 384, 389, 875, 876, 877) |
| Zahlungsart-Codes (58=SEPA, 59=Lastschrift, 48=Kreditkarte, …) |
| EU-USt-Kategorien (S, Z, E, AE, K, G, O, L, M) mit Erklärungen |
| Mengeneinheiten-Codes (H87=Stück, HUR=Stunde, KGM=kg, …) |
| Elektronische Adress-Schemata (EM=E-Mail, 9930=USt-IdNr., …) |
| On-demand KoSIT-Validator Statusabfrage |
| Zeitplan E-Rechnungspflichten 2020–2028 mit Rechtsgrundlagen |
| Deutsche Geschäftsregeln (BR-DE-1..24) mit Lösungshinweisen |
| SKR04-Kontenzuordnung für häufige Rechnungsarten (DATEV) |
| Gutschrift-Gründe und Korrektur-Codes mit Empfehlungen |
| Leitweg-ID Aufbau (Grobadresse-Feinadresse-Prüfziffer), Regex, Beispiele |
| Steuerkategorie-Entscheidungsbaum (S/Z/E/AE/K/G/O/L/M) mit Szenarien |
| SEPA-Mandatstypen (CORE/B2B), Sequenztypen (FRST/RCUR/OOFF), Gläubiger-ID |
| CPV-Codes für öffentliche Vergabe (BT-158), IT/Bau/Beratung/Gesundheit |
| BT-23 Geschäftsprozesstyp-Kennungen (Peppol BIS, XRechnung) |
| USt-Befreiungsgründe (BT-120/BT-121) — §19, §4, §13b UStG mit Texten |
| UNCL 5189 Zu-/Abschlagsgrund-Codes (Rabatt, Skonto, Zuschläge) |
MCP Prompts
Prompt | Description |
| Schritt-für-Schritt: Gutschrift (381) erstellen |
| Checkliste: Reverse Charge (§13b UStG, Kategorie AE) |
| Schnellstart: XRechnung für öffentliche Auftraggeber |
| Anleitung: Korrekturrechnung (384) erstellen |
| Abschlagsrechnung / Teilrechnung (TypeCode 875/876/877) |
| Rechnung mit Ratenzahlung erstellen |
| Handwerkerrechnung nach §35a EStG |
| Entscheidungshilfe: Welcher TypeCode für welchen Anlass? |
| Checkliste: B2B E-Rechnungspflicht ab 2027 vorbereiten |
| E-Rechnungen für Betriebsprüfung vorbereiten (GoBD, §147 AO) |
| Kleinunternehmer (§19 UStG) — E-Rechnung ohne Umsatzsteuer |
| Bauleistungen / §13b UStG — Reverse Charge im Baugewerbe |
| Differenzbesteuerung (§25a UStG) für Gebrauchtwarenhändler |
| Stornierung: 381 vs 384 vs neue 380 — Entscheidungsbaum |
| Reiseleistungen (§25 UStG) — Margenbesteuerung |
| Innergemeinschaftliche Lieferung (§4 Nr. 1b / §6a UStG) |
| Dauerrechnung / Monatsrechnung für wiederkehrende Leistungen |
| Steuernummer vs. USt-IdNr. — Entscheidungshilfe (BR-DE-26) |
| Schlussrechnung nach Abschlagszahlungen (prepaid_amount, BT-113) |
| Proforma-Rechnung — rechtliche Einordnung, E-Rechnungs-Behandlung |
| Export außerhalb EU (§4 Nr. 1a UStG, Steuerkategorie G, Incoterms) |
| Gutschriftverfahren / Self-Billing (TypeCode 389, §14 Abs. 2) |
| 381 vs 384: Gutschrift, Korrektur oder Storno? Entscheidungsbaum |
| Reverse Charge + Steuervertreter (BG-11): Kombiniertes Szenario |
| 875 → 877 Lifecycle: Abschlag, Teilrechnung, Schlussrechnung |
| IG Lieferung: Gelangensbestätigung, ZM, Nachweispflichten, eVatR |
| Skonto: Berechnung, BT-20 Kodierung, §17 UStG Steuerbehandlung |
Quick Start
Prerequisites
Python 3.11+
Docker (for the KoSIT Validator)
Installation
git clone https://github.com/Mavengence/einvoice-mcp.git
cd einvoice-mcp
pip install -e ".[dev]"Start KoSIT Validator
make docker-upStarts the KoSIT Validator (v1.6.2, XRechnung scenarios v2026-01-31) on port 8081.
Local Operation (stdio)
make devConfiguration
Claude Desktop
{
"mcpServers": {
"einvoice": {
"command": "python",
"args": ["-m", "einvoice_mcp"],
"env": {
"KOSIT_URL": "http://localhost:8081"
}
}
}
}Claude Code
claude mcp add einvoice -- python -m einvoice_mcpCursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"einvoice": {
"command": "python",
"args": ["-m", "einvoice_mcp"],
"env": {
"KOSIT_URL": "http://localhost:8081"
}
}
}
}Environment Variables
Variable | Default | Description |
|
| KoSIT Validator URL |
|
| Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
Example Prompts
Validiere diese XRechnung: [XML einfügen]
Erstelle eine Rechnung von TechCorp GmbH (DE123456789) an ClientCorp GmbH
für 40 Stunden Software-Beratung à 150€/Stunde mit 19% USt.
Parse diese E-Rechnung und zeig mir die Positionen.
Prüfe ob diese Rechnung XRechnung-konform ist und gib Verbesserungsvorschläge.Advanced Examples
Erstelle eine Gutschrift (TypeCode 381) für Rechnung RE-2025-099 über
200€ netto mit 19% USt.
Erstelle eine Rechnung mit Reverse Charge (§13b UStG, Kategorie AE):
Verkäufer DE123456789, Käufer ATU12345678, Dienstleistung 5.000€.
Erstelle eine Rechnung mit 2% Skonto bei Zahlung innerhalb von 10 Tagen.
Erstelle eine Rechnung mit SEPA-Lastschrift (PaymentMeansCode 59),
Käufer-IBAN DE89370400440532013000, Mandatsreferenz MREF-2025-001.
Erstelle eine Rechnung mit Lieferort: Lager Hamburg, Hafenstraße 42,
20457 Hamburg.
Erstelle eine innergemeinschaftliche Lieferung (Kategorie K) an
einen französischen Kunden (FR12345678901).
Erstelle eine steuerbefreite Rechnung (§19 UStG, Kleinunternehmer)
mit Befreiungsgrund und Code vatex-eu-132.
Erstelle eine Rechnung für ein Vergabeverfahren mit Losnummer VERGABE-2026-42
und Kontierungsreferenz KST-4711 pro Position.
Erstelle eine Korrekturrechnung (TypeCode 384) für die fehlerhafte Rechnung
RE-2026-001 mit korrigiertem Steuersatz.Architecture
[AI Client] --> stdio --> [FastMCP Server]
|-- drafthorse (CII XML generation/parsing)
|-- factur-x (PDF/A-3 embedding/extraction)
|-- reportlab (Visual PDF rendering)
|-- defusedxml (XXE protection on all parse paths)
'-- httpx --> [KoSIT Validator :8081]KoSIT Validator Stack
Component | Version | Source |
KoSIT Validator | v1.6.2 (SHA-256 verified) | |
XRechnung Scenarios | v2026-01-31 (SHA-256 verified) | |
Java Runtime | Eclipse Temurin 17 | OpenJDK |
Development
make install # Install dependencies
make test # Run tests with coverage
make lint # Ruff + mypy strict
make fmt # Format code
make docker-up # Start Docker stackSupported Business Terms (EN 16931)
BT/BG | Field | Generate | Parse | Compliance |
BT-1 | Invoice number | Yes | Yes | Yes |
BT-2 | Issue date | Yes | Yes | Yes |
BT-3 | Type code (380/381/384) | Yes | Yes | Yes |
BT-5 | Currency code | Yes | Yes | Yes |
BT-9 | Due date | Yes | Yes | — |
BT-10 | Buyer reference / Leitweg-ID | Yes | Yes | Yes |
BT-11 | Project reference | Yes | Yes | — |
BT-12 | Contract reference | Yes | Yes | — |
BT-13 | Purchase order reference | Yes | Yes | — |
BT-14 | Sales order reference | Yes | Yes | — |
BT-16 | Despatch advice reference | Yes | Yes | — |
BT-17 | Tender or lot reference | Yes | Yes | — |
BT-18 | Invoiced object identifier | Yes | Yes | — |
BT-20 | Payment terms text | Yes | Yes | — |
BT-22 | Invoice note | Yes | Yes | — |
BT-23 | Business process type | Yes | Yes | — |
BT-25 | Preceding invoice (credit notes) | Yes | Yes | Yes |
BT-27..40 | Seller party + address (incl. lines 2/3, subdivision) | Yes | Yes | Yes |
BT-28 | Seller trading name | Yes | Yes | — |
BT-29 | Seller registration ID (GLN) | Yes | Yes | — |
BT-31 | Seller VAT ID (schemeID=VA) | Yes | Yes | Yes |
BT-32 | Seller tax number (schemeID=FC) | Yes | Yes | Yes |
BT-34 | Seller electronic address | Yes | Yes | Yes |
BT-41 | Seller contact name | Yes | Yes | Yes |
BT-42 | Seller contact phone | Yes | Yes | Yes |
BT-43 | Seller contact email | Yes | Yes | Yes |
BT-44..55 | Buyer party + address (incl. lines 2/3, subdivision) | Yes | Yes | Yes |
BT-45 | Buyer trading name | Yes | Yes | — |
BT-46 | Buyer registration ID (GLN) | Yes | Yes | — |
BT-49 | Buyer electronic address | Yes | Yes | Yes |
BT-70..80 | Delivery location (name + address) | Yes | Yes | — |
BT-71 | Delivery date | Yes | Yes | Yes |
BT-73/74 | Service period | Yes | Yes | Yes |
BT-81 | Payment means type code | Yes | Yes | — |
BT-83 | Remittance information | Yes | Yes | — |
BT-84 | Seller IBAN | Yes | Yes | Yes |
BT-86 | BIC | Yes | Yes | — |
BT-89 | SEPA mandate reference | Yes | Yes | Yes |
BT-91 | Buyer IBAN (SEPA direct debit) | Yes | Yes | Yes |
BT-120 | VAT exemption reason text | Yes | Yes | Yes |
BT-121 | VAT exemption reason code | Yes | Yes | — |
BT-127 | Line item note | Yes | Yes | — |
BT-155 | Seller item identifier | Yes | Yes | — |
BT-156 | Buyer item identifier | Yes | Yes | — |
BT-157 | Standard item ID (GTIN/EAN) | Yes | Yes | — |
BT-159 | Item country of origin | Yes | Yes | — |
BT-160/161 | Item attributes (BG-30, name/value) | Yes | Yes | — |
BG-20/21 | Document-level allowances/charges | Yes | Yes | — |
BG-27/28 | Line-level allowances/charges | Yes | Yes | — |
BT-15 | Receiving advice reference | Yes | Yes | — |
BT-71 | Delivery location identifier | Yes | Yes | — |
BT-82 | Payment means text | Yes | Yes | — |
BG-24 | Supporting documents (BT-122..125) | Yes | Yes | — |
BT-133 | Buyer accounting reference | Yes | Yes | — |
Skonto | Payment discount terms (percent, days) | Yes | Yes | — |
Gutschrift (Credit Note) Support
For credit notes (TypeCode 381), the server:
Sets XML header name to "GUTSCHRIFT" and PDF title accordingly
Requires BT-25 (preceding invoice number) in compliance checks
Shows "Bezug: [Rechnungsnummer]" in the PDF header
Validates against EN 16931 type code whitelist (380, 381, 384, 389, 875, 876, 877)
Example: type_code="381", preceding_invoice_number="RE-2025-099"
Profile Selection Guide
Profile | Use Case | Guideline URI |
| German public sector (B2G), Leitweg-ID required |
|
| B2B invoices (default for ZUGFeRD PDF) |
|
| Simplified B2B invoices |
|
| Extended B2B invoices with additional fields |
|
German Compliance Guide
See docs/GERMAN_COMPLIANCE_GUIDE.md for:
TypeCode decision tree (380/381/384/875/876/877)
Tax category decision tree (S/Z/E/AE/K/G/O/L/M)
Leitweg-ID format and sources
Reverse charge vs. intra-community supply
Handwerkerrechnung §35a EStG
Pflichtfelder-Checkliste for XRechnung 3.0
Limitations
ZUGFeRD Basic/Extended: Generation produces XML with correct guideline URIs, but parsing, validation, and compliance checks are tested for XRechnung 3.0 and ZUGFeRD EN16931 only.
Batch processing: Each tool call processes one invoice. For bulk operations, call the tools in sequence.
Troubleshooting
KoSIT Validator nicht erreichbar
Fehler: KoSIT-Validator nicht erreichbar. Bitte prüfen Sie die Verbindung.Start the Docker containers:
make docker-upWait for healthy status:
docker compose -f docker/docker-compose.yml psVerify manually:
curl http://localhost:8081/server/healthCheck if port 8081 is blocked by firewall or another process
Docker Container startet nicht
# Check logs
docker compose -f docker/docker-compose.yml logs kosit
# Common issue: port already in use
lsof -i :8081
# Restart clean
docker compose -f docker/docker-compose.yml down
docker compose -f docker/docker-compose.yml up -dUBL-Format erkannt
Fehler: UBL-Format erkannt. Dieses Tool unterstützt nur CII.The parser only supports CII (Cross Industry Invoice) XML, which is the standard for XRechnung and ZUGFeRD. If you have a UBL invoice, convert it to CII first using an external tool.
Pydantic Validation Errors
When generating invoices, field errors now reference BT numbers:
Fehler: Ungültige Rechnungsdaten:
- BT-84 (IBAN): String should match pattern ...
- BT-27 (Verkäufername): String should have at least 1 characterCheck the German Compliance Guide for field requirements.
Tests laufen nicht
# Install dev dependencies
pip install -e ".[dev]"
# Run unit tests only (no Docker needed)
make test
# Run integration tests (requires Docker)
make docker-up
pytest -m integrationRegulatory References
EN 16931 — European standard for electronic invoicing
XRechnung 3.0 (Szenarien 3.0.2) — German CIUS (Core Invoice Usage Specification)
ZUGFeRD 2.x / Factur-X 1.08 — Hybrid PDF/A-3 invoice format
BMF 2024-11-15 — German Federal Ministry of Finance e-invoice mandate
§14 UStG — German VAT Act invoice requirements
§14 Abs. 4 Nr. 2 UStG — Steuernummer or USt-IdNr. required (BT-31 / BT-32)
§14 Abs. 4 Nr. 6 UStG — Delivery date or service period required (BT-71 / BT-73/74)
BR-CO-14 — Tax total must equal sum of per-group calculated amounts
BR-DE-5 — Seller contact person (mandatory for XRechnung)
BR-DE-7 — Seller contact email (mandatory for XRechnung)
BR-DE-23 — IBAN mandatory when PaymentMeansCode = 58 (SEPA)
§13b UStG — Reverse charge: seller + buyer VAT IDs required, 0% tax rate
§4 Nr. 1b UStG — Intra-community supply: buyer VAT ID required, 0% tax rate
§19 UStG — Kleinunternehmerregelung: exemption note advisory for TaxCategory E
BG-19 — SEPA direct debit (PaymentMeansCode = 59, buyer IBAN, mandate reference)
BR-DE-20 — Max one payment instruction type (no mixing credit transfer + direct debit)
BR-DE-24 — SEPA direct debit: mandate reference + buyer IBAN required
BR-E-10 — VAT exemption reason (BT-120) required for TaxCategory E
§4 Nr. 1a UStG — Export outside EU (TaxCategory G): 0% tax rate required
§33 UStDV — Kleinbetragsrechnung advisory (invoices ≤250€ gross)
Skonto — Early payment discount terms (PaymentDiscountTerms in CII)
384 Korrekturrechnung — Corrective invoice must reference preceding invoice (BT-25)
RC-COUNTRY — Reverse charge: seller/buyer country advisory (§13b allows domestic)
IC-COUNTRY — Intra-community: seller ≠ buyer country required
§632a BGB — Abschlagsrechnung for construction/service contracts
§35a Abs. 3 EStG — Handwerkerleistungen tax deduction (20% of labor, max 1.200€/year)
§271 BGB — Payment due date per agreement (Ratenzahlung)
ISO 13616 — IBAN format validation (seller + buyer)
ISO 9362 — BIC/SWIFT format validation
License
MIT