E-Invoicing Integrations
The einvoice module turns a posted customer invoice into a standardised EN 16931 /
Peppol BIS Billing 3.0 UBL document, validates it against the core business rules, and
transmits it through a certified Access Point provider. This page documents the
data contract a consultant configures and the provider seam a third party implements to
add a new Access Point — the same shape as the payment and
shipping provider hooks.
What it produces
Section titled “What it produces”For a posted FinancialDocument of type Customer Invoice or Credit Note, the module
generates EN 16931 XML in either syntax the standard binds to: UBL 2.1 (the base, carrying the
Peppol BIS Billing 3.0 customization) or UN/CEFACT CII D16B (used by the XRechnung-CII,
ZUGFeRD and Factur-X profiles). Both are built from the same helpers, so the two syntaxes
always state the same invoice. The tax breakdown is derived from the invoice lines — one
entry per VAT category + rate — even though the document stores only a single rolled-up tax
total.
What the document carries beyond the parties and lines, and where it comes from:
| Business term | Source |
|---|---|
| Country codes | ISO 3166-1 alpha-2, from Country.iso_alpha_2() (the record stores alpha-3) |
| Quantity unit (BT-130) | UoM.unece_code (UN/ECE Rec 20); a line with no unit is C62 (“one”). Every shipped unit is coded; a unit you add needs its code before an e-invoice can be generated |
| Actual delivery date (BT-72) | the document’s supply date, else its date; a supply period is stated as the invoicing period (BG-14) instead |
| Deliver-to (BG-13) | the delivery address; for an intra-community supply with none, the buyer’s address |
| Payment terms (BT-20) | the document’s payment terms (name and description) |
| VAT in accounting currency (BT-6, BT-111) | for a document in a foreign currency, tax_in_company_currency() — the VAT the books hold |
| Preceding invoice (BT-25/26) | a credit note’s source_document |
| Seller VAT identifier (BT-31) | the company’s tax_number, with its country prefix added when it was entered without one (Country.vat_identifier()) |
| Seller tax registration (BT-32) | the company’s local_tax_number (the German Steuernummer), scheme FC — PartyTaxScheme with a non-VAT TaxScheme in UBL, SpecifiedTaxRegistration in CII |
| Exemption reason and code (BT-120/121) | the tax’s exemption_reason and exemption_reason_code (VATEX) |
| Invoice notes (BT-22) | a credit note’s reason, then the legal mentions the printed invoice makes: each exemption’s wording (FinancialDocument.tax_mentions()) and the invoicing regime’s legal notice. UBL carries them in one cbc:Note (Peppol allows one) |
| Document-level allowances and charges (BG-20/BG-21) | every invoice line with an adjustment — see below |
A negative line that is an item (a returned article) states its sign in the quantity, never the price, and an invoice for a supply outside the scope of VAT omits the parties’ VAT identifiers — both as EN 16931 requires.
Seller identity: VAT identifier or tax number
Section titled “Seller identity: VAT identifier or tax number”A seller is identified by its VAT identifier (BT-31), its tax registration number (BT-32), or
both — each stated when filled in. A standard-rated, zero-rated, exempt or reverse-charge
invoice is valid with the tax number alone (BR-S-02, BR-E-02, …), which is how a German
small business under § 19 UStG (Kleinunternehmerregelung) without a USt-IdNr. invoices; an
intra-community supply or an export needs the VAT identifier itself (BR-IC-02, BR-G-02). With
no VAT identifier on the document, the company’s registry is what identifies it (BR-CO-26).
The German localization ships the § 19 tax (de_kleinunternehmer): category Exempt, the
legal wording as its exemption reason — printed on the invoice and carried as BT-120 and
BT-22. The VATEX code list has no code for § 19, so it carries no BT-121.
Invoice-wide discounts and charges
Section titled “Invoice-wide discounts and charges”A document’s total is its lines, so an invoice-wide discount or charge is a line too —
one per set of taxes, so its VAT is charged on what is paid. FinancialDocumentLine.adjustment
marks such a line: an allowance (Discount, Special Rebate, Turnover Bonus; a negative
amount) or a charge (Freight, Packing, Rush Delivery, Other Charge; a positive one).
Totals, tax and the journal entry treat it as any line; the e-invoice states it as a
document-level AllowanceCharge / SpecifiedTradeAllowanceCharge with its reason, its
UNCL 5189 / 7161 reason code and its VAT category, and the totals as items − allowances +
charges (BR-CO-13). A discount given as a percentage (adjustment_percent) also states its
base and percentage when they still produce the amount to the cent.
Lines get it from: Add Discount on a draft invoice (action_add_discount, a percentage or
an amount, split by tax set), an order’s coupon discount (promotions), and an order’s shipping
line (sales). The sign is validated where the line is entered.
The invoice form gains an E-Invoicing tab (status, the generated XML, any validation errors) and four actions:
| Action | Method | Effect |
|---|---|---|
| Validate E-Invoice | action_validate_einvoice | Check the invoice against the core EN 16931 rules; surfaces what to fix. |
| Generate E-Invoice | action_generate_einvoice | Validate, then build and store the XML of the document’s profile. |
| Send E-Invoice | action_send_einvoice | Generate if needed, then transmit through the configured Access Point. |
| Download E-Invoice PDF | action_download_einvoice_pdf | For a hybrid profile (ZUGFeRD, Factur-X): the invoice PDF as PDF/A-3 with the XML inside. |
Data a consultant configures
Section titled “Data a consultant configures”The document is only transmittable when both parties are addressable on the network and the tax data is complete:
| Field | On | Meaning |
|---|---|---|
peppol_endpoint_id + peppol_scheme | Company, Contact | The party’s electronic address on the Peppol network (usually the VAT number or a GLN) and its EAS scheme code (e.g. 9930 = DE VAT, 0088 = GLN). |
tax_number | Company, Contact | The VAT identifier (already part of core). The seller needs it or local_tax_number on any VAT invoice, and it for an intra-community supply or export. |
local_tax_number | Company | The tax registration number (German Steuernummer), stated as BT-32. |
company_registry | Company | The legal registration (BT-30); required when no VAT identifier is stated (BR-CO-26). |
vat_category | Tax | The EN 16931 VAT category (Standard Rate / Zero Rated / Exempt / Reverse Charge / …). Maps to the UNCL5305 code (S/Z/E/AE/…) on the wire. |
exemption_reason | Tax | Required by EN 16931 for Exempt, Reverse Charge, Intra-Community Supply, Export and Outside Scope. Not stated for Zero Rated (BR-Z-10). |
exemption_reason_code | Tax | Optional VATEX code (BT-121), e.g. VATEX-EU-IC, VATEX-FR-FRANCHISE. The German and French packs ship it on their cross-border and franchise taxes. |
unece_code | Unit of Measure | The UN/ECE Recommendation 20 code the quantity is stated in (KGM, HUR, C62, …). |
iban + bic | Company | The SEPA credit-transfer payment means. |
action_validate_einvoice reports missing or inconsistent values in these terms (e.g.
“Buyer Peppol endpoint ID / scheme is missing”) so they can be fixed before sending.
The Access Point provider seam
Section titled “The Access Point provider seam”Peppol uses a 4-corner model: your install is Corner 1 (the sender); the Access Point provider is Corner 2 and handles the AS4 transport plus SML/SMP discovery to reach the recipient’s Access Point (Corner 3) and the recipient (Corner 4). You never operate an Access Point yourself — you connect to a certified provider’s API.
A provider is a module that extends Integration — with integration_category: Accounting in its manifest (its catalogue heading) and provides: [e_invoicing] (what
makes the transmission code find it) — and overrides the
transmission hooks, guarding on its own provider check and delegating to super() for the
rest — exactly the payment/shipping pattern:
class MyApProvider(Model): __inherit__ = "Integration"
async def send_einvoice(self, document, xml_bytes, doc_format): if not await self._is_my_ap(): return await super().send_einvoice(document, xml_bytes, doc_format) # ... POST xml_bytes to the Access Point's API ... return {"message_id": "<ap-ref>", "state": "Sent"} # or "Delivered" / "Rejected"The hooks a provider may implement (the base raises NotImplementedError, so an invoice can
always be generated and validated locally even with no provider connected):
| Hook | Purpose | Returns |
|---|---|---|
send_einvoice(document, xml_bytes, doc_format) | Transmit a generated e-invoice (Corner 2). | {"message_id", "state"} |
fetch_einvoice_status(message_id) | Delivery status of a sent document. A scheduled job asks it every 30 minutes for each document still Sent, of the provider that sent it and for the document’s company; returning Delivered or Rejected (with the reason in detail) moves the document on. Leave it unimplemented and documents stay Sent. | {"state", "detail"} |
validate_einvoice(xml_bytes, doc_format) | Optional provider-side Schematron validation (the full ~200-rule EN 16931 set). | {"valid", "errors": [...]} |
receive_einvoices() | Inbound (Corner 4): fetch e-invoices delivered to you. | [{"message_id", "xml", "sender", "received_at"}] |
The enabled provider is resolved with Integration.resolve_einvoice_provider() — the first
enabled integration that provides e_invoicing (Integration.providers("e_invoicing")).
Leave provides out of the manifest and no document ever finds your Access Point;
check --only integrations fails a module that implements send_einvoice without it.
National profiles
Section titled “National profiles”A profile selects the standard/national flavour of the generated document. The base
ships Peppol BIS Billing 3.0; a country module adds its own profile by extending
FinancialDocument — contributing the profile name to the einvoice_profile selection and
overriding two hooks (guarding on the profile value, delegating to super() for the rest):
class XRechnungDocument(Model): __inherit__ = "FinancialDocument" _selection_add = {"einvoice_profile": ["XRechnung 3.0"]}
async def _einvoice_customization_id(self): if self.einvoice_profile == "XRechnung 3.0": return "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0" return await super()._einvoice_customization_id()
async def _einvoice_profile_validation(self): errors = await super()._einvoice_profile_validation() if self.einvoice_profile == "XRechnung 3.0": # ... append the national (BR-DE) rule violations ... return errors_einvoice_customization_id()sets the specification identifier (BT-24): the UBLcbc:CustomizationID, or the CII guideline ID — whichever syntax the profile renders._einvoice_profile_validation()returns the profile’s national rule violations, which are checked alongside the core EN 16931 set on validate/generate._einvoice_render()returns(xml_text, format). The base renders UBL; a CII profile returnsbuild_cii(self)(fromfullfinity.enterprise.einvoice.models._cii)._einvoice_hybrid_level()returns the Factur-X / ZUGFeRD conformance level (e.g."EN 16931") when the profile is delivered as a hybrid PDF, elseNone. Answering it is all a profile does to get the Download E-Invoice PDF action: the base renders the invoice report as PDF/A-3B with the XML embedded asfactur-x.xml(an associated file, relationship Alternative) and the Factur-X XMP properties._einvoice_augment_ubl(root)lets a profile mutate the built UBL in place before it is serialized — whether it is stored or transmitted — to inject elements its national rules require.
The user picks the profile per invoice (E-Invoicing tab). The reference profiles:
| Module | Profile | Syntax | Identifier (BT-24) |
|---|---|---|---|
einvoice | Peppol BIS Billing 3.0 | UBL | urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 |
l10n_de_einvoice | XRechnung 3.0 | UBL | urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0 |
l10n_de_einvoice | XRechnung 3.0 (CII) | CII | same as above |
l10n_de_einvoice | ZUGFeRD (EN 16931) | CII in PDF/A-3 | urn:cen.eu:en16931:2017 (the EN 16931 profile of Factur-X / ZUGFeRD is identified by the bare EN 16931 identifier) |
l10n_fr_einvoice | Factur-X (France) | CII in PDF/A-3 | same as above |
XRechnung adds the BR-DE checks (Leitweg-ID buyer reference, seller contact point, IBAN payment means); Factur-X checks the French seller’s SIRET and the IBAN. ZUGFeRD and Factur-X are one specification published under two names.
The base emits seller contact and SEPA payment means (from the company’s iban/bic) whenever
present, so those national requirements are satisfiable without profile-specific builder code.
Validating against the official validators
Section titled “Validating against the official validators”Fullfinity’s own validation run (part of its test tooling, not the distribution) raises real invoices and credit notes in every profile — standard, reduced and mixed rates, exempt, reverse charge, intra-community, export, outside scope, zero rated, discounts and negative lines, document-level allowances and charges (percentage and amount), a § 19 UStG small business identified by its tax number, a credit note, a foreign currency, payment terms, a Leitweg-ID, UN/ECE units and rounding-sensitive amounts — and runs the KoSIT validator with the XRechnung configuration, the Factur-X / ZUGFeRD EN 16931 profile XSD and Schematron, the CEN EN 16931 Schematron and veraPDF (PDF/A-3B) over them. To check a profile of your own, run the same validators over the XML your builder produces; each is published by its maintainer.