Generate XRechnung (EN 16931) Invoice XML
Skill: Convert invoice data into a valid XRechnung CII XML
Region: Germany (Deutschland)
Category: E-Invoicing — E-Rechnung
Does: Takes ordinary invoice data and produces an EN 16931-compliant XRechnung in UN/CEFACT CII (CrossIndustryInvoice) form, suitable for B2G submission and domestic B2B.
Standard: EN 16931 + XRechnung CIUS (current version, e.g. 3.x)
XRechnung can be expressed as UN/CEFACT CII or UBL. This skill emits CII. Validate the result against the XRechnung schematron (KoSIT validator) before sending — business rules (BR-DE-*) are stricter than the base XSD.
Input data required
| Input | EN 16931 term | Used for |
|---|---|---|
| Invoice number, issue date, type code | BT-1, BT-2, BT-3 | ExchangedDocument |
| Buyer reference (Leitweg-ID for B2G) | BT-10 | BuyerReference |
| Currency | BT-5 | InvoiceCurrencyCode |
| Seller name, address, VAT ID | BT-27, BT-35.., BT-31 | SellerTradeParty |
| Buyer name, address, VAT ID | BT-44, BT-50.., BT-48 | BuyerTradeParty |
| Payment means, IBAN, due date | BG-16, BT-9 | SpecifiedTradeSettlementPaymentMeans |
| Line items: name, quantity, net price, VAT category & rate | BG-25 | IncludedSupplyChainTradeLineItem |
A mandatory BT-10 Buyer reference (Leitweg-ID) is required for German B2G invoices.
Namespaces (CII)
| Prefix | URI |
|---|---|
rsm |
urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100 |
ram |
urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100 |
udt |
urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100 |
The specification identifier (BT-24) is set in GuidelineSpecifiedDocumentContextParameter:
urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_3.0
Document structure to emit
rsm:CrossIndustryInvoice
├── rsm:ExchangedDocumentContext (BT-24 spec identifier)
├── rsm:ExchangedDocument (BT-1 number, BT-3 type, BT-2 date)
└── rsm:SupplyChainTradeTransaction
├── ram:IncludedSupplyChainTradeLineItem ... (one per line)
├── ram:ApplicableHeaderTradeAgreement (seller, buyer, BT-10)
├── ram:ApplicableHeaderTradeDelivery (delivery)
└── ram:ApplicableHeaderTradeSettlement (currency, VAT breakdown, totals, payment)
Key header fields
| Field | EN 16931 | Element path |
|---|---|---|
| Invoice number | BT-1 | ExchangedDocument/ram:ID |
| Type code | BT-3 | ExchangedDocument/ram:TypeCode (380 invoice, 381 credit note) |
| Issue date | BT-2 | ExchangedDocument/ram:IssueDateTime/udt:DateTimeString format 102 = YYYYMMDD |
| Currency | BT-5 | ...HeaderTradeSettlement/ram:InvoiceCurrencyCode |
| Buyer reference | BT-10 | ...HeaderTradeAgreement/ram:BuyerReference |
Totals (ram:SpecifiedTradeSettlementHeaderMonetarySummation)
| Field | EN 16931 | Element |
|---|---|---|
| Sum of line net amounts | BT-106 | ram:LineTotalAmount |
| Total without VAT | BT-109 | ram:TaxBasisTotalAmount |
| Total VAT | BT-110 | ram:TaxTotalAmount (with currencyID) |
| Grand total (incl. VAT) | BT-112 | ram:GrandTotalAmount |
| Amount due for payment | BT-115 | ram:DuePayableAmount |
VAT category codes (BT-151 / BT-118)
| Code | Meaning |
|---|---|
S |
Standard rate (19% / 7% in Germany) |
Z |
Zero-rated |
E |
Exempt |
AE |
Reverse charge |
K |
Intra-community supply |
G |
Export outside EU |
O |
Outside scope of VAT |
Each VAT breakdown group (ram:ApplicableTradeTax under settlement) needs CategoryCode, RateApplicablePercent, BasisAmount, CalculatedAmount, and a TypeCode of VAT. For categories other than S/Z, supply an exemption reason.
Calculation rules
- Line net amount = quantity × net unit price, rounded to 2 decimals (BT-131).
- Group line nets by VAT category + rate → each group's
BasisAmount(BT-116);CalculatedAmount(BT-117) = basis × rate. TaxBasisTotalAmount(BT-109) = Σ group basis;TaxTotalAmount(BT-110) = Σ group VAT.GrandTotalAmount(BT-112) = BT-109 + BT-110;DuePayableAmount(BT-115) = BT-112 − prepaid.- Monetary values: 2 decimals; the document-level
TaxTotalAmountcarries acurrencyIDattribute.
Worked example (single standard-rate line)
<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_3.0</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>RE-2024-001</ram:ID>
<ram:TypeCode>380</ram:TypeCode>
<ram:IssueDateTime><udt:DateTimeString format="102">20240115</udt:DateTimeString></ram:IssueDateTime>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument><ram:LineID>1</ram:LineID></ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct><ram:Name>Beratungsleistung</ram:Name></ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice><ram:ChargeAmount>250.00</ram:ChargeAmount></ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery><ram:BilledQuantity unitCode="HUR">40</ram:BilledQuantity></ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax><ram:TypeCode>VAT</ram:TypeCode><ram:CategoryCode>S</ram:CategoryCode><ram:RateApplicablePercent>19</ram:RateApplicablePercent></ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation><ram:LineTotalAmount>10000.00</ram:LineTotalAmount></ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>04011000-12345-34</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Acme GmbH</ram:Name>
<ram:PostalTradeAddress><ram:PostcodeCode>10115</ram:PostcodeCode><ram:LineOne>Beispielstr. 1</ram:LineOne><ram:CityName>Berlin</ram:CityName><ram:CountryID>DE</ram:CountryID></ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration><ram:ID schemeID="VA">DE123456789</ram:ID></ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:Name>Kunde AG</ram:Name>
<ram:PostalTradeAddress><ram:PostcodeCode>80331</ram:PostcodeCode><ram:LineOne>Kundenweg 7</ram:LineOne><ram:CityName>München</ram:CityName><ram:CountryID>DE</ram:CountryID></ram:PostalTradeAddress>
</ram:BuyerTradeParty>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery/>
<ram:ApplicableHeaderTradeSettlement>
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount>1900.00</ram:CalculatedAmount><ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount>10000.00</ram:BasisAmount><ram:CategoryCode>S</ram:CategoryCode><ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount>10000.00</ram:LineTotalAmount>
<ram:TaxBasisTotalAmount>10000.00</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">1900.00</ram:TaxTotalAmount>
<ram:GrandTotalAmount>11900.00</ram:GrandTotalAmount>
<ram:DuePayableAmount>11900.00</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
Validation checklist
- BT-24 specification identifier matches the target XRechnung version
- BT-10 Buyer reference (Leitweg-ID) present for B2G
- Seller VAT ID present with
schemeID="VA" - Each line has quantity (with
unitCode), net price, VAT category + rate, line total - Per-category VAT breakdown reconciles with the sum of lines
- BT-112 = BT-109 + BT-110; BT-115 = BT-112 − prepaid
-
TaxTotalAmountcarriescurrencyID - Passes the KoSIT XRechnung validator (XSD + schematron) before sending
Last updated: 2026-05-26 — confirm the current XRechnung CIUS version, the BT-24 specification identifier, and BR-DE business rules against the KoSIT publication before use.