ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[DE E-Document] Inbound ZUGFeRD/XRechnung invoices are stored without any EN 16931 mandatory-field validation

Open ADO-BST opened this issue 5 months ago • 14 comments

Why do you need this change?

When receiving German e-invoices (ZUGFeRD and XRechnung), Business Central performs no content validation of the incoming document. The German format apps only check the technical envelope and then store whatever data is present ΓÇö missing mandatory fields result in empty fields with no feedback to the user.

This is a compliance problem:

  • EN 16931-1:2017 (the European e-invoicing standard mandated by Directive 2014/55/EU) does not only define fields, it defines a set of business rules with mandatory cardinalities ΓÇö e.g. invoice number (BT-1), issue date (BT-2), document currency (BT-5), seller name and VAT identifiers (BT-27 / BG-4), buyer name (BT-44), VAT breakdown (BG-23) and document totals (BT-112 / BT-115). A document is only a valid e-invoice if these mandatory elements are present. In Germany this is operationalised by the KoSIT / XRechnung Schematron validation rule set.

  • In Germany, ┬º 14 UStG (as amended by the Wachstumschancengesetz, BGBl. 2024 I Nr. 108, 27.03.2024) introduced the mandatory ability to receive structured B2B e-invoices as of 01.01.2025. The BMF letter of 15.10.2024 ("Einf├╝hrung der obligatorischen E-Rechnung") references EN 16931 and the XRechnung/ZUGFeRD profiles as the binding basis. Proper receipt implies the system can determine whether an incoming invoice is complete and EN 16931-conformant ΓÇö not merely extract whatever data happens to be there.

Without mandatory-field/business-rule validation on import, invoices that are missing legally required content are silently accepted as if valid. This pushes the compliance risk (incorrect input VAT deduction, incomplete records) onto the receiving company and gives the user no indication that the received document is non-conformant.

Additionally (legal basis, same BMF letter): a ZUGFeRD/EN 16931 invoice may lawfully be transmitted as pure CII XML without a PDF wrapper. Such a document currently cannot be received at all (see below), which should also be addressed.

Describe the request

On the inbound path of the German e-document formats, validate received e-invoices against the EN 16931 mandatory fields and business rules (and the XRechnung/KoSIT rule set where applicable), and surface clear, itemised validation feedback on the E-Document instead of silently importing documents with missing data.

Current behaviour (code references, repo microsoft/ALAppExtensions):

ZUGFeRD importer ΓÇö Apps/DE/EDocumentDE/app/src/ZUGFeRD/ImportZUGFeRDDocument.Codeunit.al (Codeunit 13919)

  • The only hard checks are:
    • XML attachment present in the PDF ΓÇö ParseBasicInfo, lines 47-48 ΓåÆ error "No invoice attachment found in the PDF file. Please check the PDF file."
    • Document type code in a fixed list ΓÇö lines 59-73 ΓåÆ error "Unsupported document type: %1".
  • All actual invoice content (seller, buyer, VAT IDs, invoice number, dates, currency, amounts, tax breakdown, line items) is read via GetNodeByPath / Evaluate and mapped without any TestField, FieldError, Error or business-rule check. Missing elements simply produce empty fields.

XRechnung importer ΓÇö Apps/DE/EDocumentDE/app/src/XRechnung/ImportXRechnungDocument.Codeunit.al (Codeunit 13915)

  • The only error raised in the whole importer is "Invalid XML file" when the root element cannot be found (GetDocumentType, line 100). No mandatory-field or business-rule validation is performed.

No validation is hooked in elsewhere either:

  • The Check procedures of the format codeunits (ZUGFeRDFormat, XRechnungFormat, EDocPEPPOLBIS30DE) and EDocPEPPOLValidationDE contain the only real validation logic, but they run exclusively on the export/send path (processing phase "Release"). They are never invoked during receipt; the inbound flow only calls GetBasicInfoFromReceivedDocument ΓåÆ ParseBasicInfo and GetCompleteInfoFromReceivedDocument ΓåÆ ParseCompleteInfo.
  • The German app only consumes mapping/lookup helpers from the framework (FindVendor, FindVendorByServiceParticipant, FindGLAccountForLine, FindVendorByNameAndAddress) ΓÇö these resolve master data, they do not validate the invoice content.

So the received document is effectively just parsed and stored; there is no point at which the German format apps verify that the EN 16931 mandatory fields are filled.

Requested improvements:

  1. Validate incoming e-invoices against the EN 16931 mandatory fields and business rules (and XRechnung/KoSIT rules). At minimum, verify presence of the core mandatory fields after parsing and report a clear, itemised error/warning to the user when something required is missing.
  2. Provide validation feedback on the E-Document instead of silently importing documents with empty fields.
  3. Allow receipt of a standalone CII XML (XML without a PDF wrapper), so EN 16931 / ZUGFeRD invoices delivered as pure XML — which are admissible under § 14 UStG / BMF 15.10.2024 — can be processed. Today the ZUGFeRD importer requires the CII XML to be embedded in a PDF (GetDocumentAttachmentStream, lines 47-48) and the XRechnung importer handles UBL syntax only, so no inbound path accepts a standalone CII document.

Affected version: 28.1

References:

  • Microsoft Docs ΓÇö Electronic invoicing in Germany (XRechnung = UBL only; ZUGFeRD = PDF/A with embedded XML): https://learn.microsoft.com/dynamics365/business-central/localfunctionality/germany/germany-einvoicing
  • EN 16931-1:2017; Directive 2014/55/EU; XRechnung specification / KoSIT validation rules
  • ┬º 14 UStG (Wachstumschancengesetz); BMF-Schreiben 15.10.2024 "Einf├╝hrung der obligatorischen E-Rechnung"

Note: If Microsoft considers inbound EN 16931 validation to belong in the core E-Document framework (microsoft/BCApps) rather than in the country format apps, please re-route this issue accordingly ΓÇö the point is that today this validation happens nowhere for received German e-invoices.


Update:

The referenced objects do exist ΓÇö they are in this repository (microsoft/ALAppExtensions), not in microsoft/BusinessCentralApps. They belong to the German E-Document app (Apps/DE/EDocumentDE). Verified against branch main, commit b6bee5ca6.

Object IDs and file paths:

  • Codeunit 13919 "Import ZUGFeRD Document" Apps/DE/EDocumentDE/app/src/ZUGFeRD/ImportZUGFeRDDocument.Codeunit.al
  • Codeunit 13915 "Import XRechnung Document" Apps/DE/EDocumentDE/app/src/XRechnung/ImportXRechnungDocument.Codeunit.al
  • Codeunit 13920 "ZUGFeRD Format" Apps/DE/EDocumentDE/app/src/ZUGFeRD/ZUGFeRDFormat.Codeunit.al
  • Codeunit 13914 "XRechnung Format" Apps/DE/EDocumentDE/app/src/XRechnung/XRechnungFormat.Codeunit.al
  • Codeunit 11035 "EDoc PEPPOL BIS 3.0 DE" Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLBIS30DE.Codeunit.al
  • Codeunit 13921 "EDoc PEPPOL Validation DE" Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLValidationDE.Codeunit.al

Permalinks to the specific code (pinned to commit b6bee5ca6):

  • ZUGFeRD inbound ΓÇö "No invoice attachment found in the PDF file" (lines 47-48): https://github.com/microsoft/ALAppExtensions/blob/b6bee5ca6/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ImportZUGFeRDDocument.Codeunit.al#L47-L48
  • ZUGFeRD inbound ΓÇö fixed type-code list + "Unsupported document type" (lines 59-73): https://github.com/microsoft/ALAppExtensions/blob/b6bee5ca6/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ImportZUGFeRDDocument.Codeunit.al#L59-L73
  • XRechnung inbound ΓÇö only "Invalid XML file" check (line 100): https://github.com/microsoft/ALAppExtensions/blob/b6bee5ca6/Apps/DE/EDocumentDE/app/src/XRechnung/ImportXRechnungDocument.Codeunit.al#L100

Clarification on scope: this is primarily a compliance/feature request, not only an extensibility request. The core point is that the inbound parsing procedures (ParseBasicInfo / ParseCompleteInfo in the two import codeunits) map the XML data without validating that the EN 16931 mandatory fields are present, and the existing Check procedures (in the Format / Validation codeunits above) run only on the export/send path (processing phase "Release"), never on receipt.

If Microsoft considers the inbound EN 16931 validation to belong in the core E-Document framework in microsoft/BCApps (namespace Microsoft.eServices.EDocument) rather than in these country format apps, please re-route accordingly ΓÇö but the affected country-specific import codeunits listed above are all in microsoft/ALAppExtensions. Internal work item: AB#640416

ADO-BST avatar Jun 15 '26 08:06 ADO-BST

Hi @ADO-BST,

Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

📚 Extensibility Guidelines

Missing Information:

  • Target objects/code references: The requested target objects and procedures could not be located in microsoft/BusinessCentralApps. Please update the issue with valid current object names, procedure names, or file references for ImportZUGFeRDDocument, ImportXRechnungDocument, ZUGFeRDFormat, XRechnungFormat, EDocPEPPOLBIS30DE, and EDocPEPPOLValidationDE.

Please update the issue with the missing details. We'll automatically re-analyze once updated.

[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

[!TIP] Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

github-actions[bot] avatar Jun 15 '26 09:06 github-actions[bot]

additional information added

ADO-BST avatar Jun 23 '26 07:06 ADO-BST

Hi @ADO-BST,

Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

📚 Extensibility Guidelines

Missing Information:

  • Target repository/object references: The current analysis context is microsoft/BusinessCentralApps, but your clarifications reference objects and files in microsoft/ALAppExtensions. Please confirm the correct target repository/branch and the exact object/file locations that should be analyzed for this request.

Please update the issue with the missing details. We'll automatically re-analyze once updated.

[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

[!TIP] Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

github-actions[bot] avatar Jun 23 '26 08:06 github-actions[bot]

/not-accurate every reference is in the context. Every info is in the context.

ADO-BST avatar Jun 23 '26 12:06 ADO-BST

✅ Feedback recorded Thanks — your /not-accurate feedback has been logged and will be reviewed.

github-actions[bot] avatar Jun 23 '26 12:06 github-actions[bot]

Hello @ADO-BST,

I will assign it to a Finance team who will do a proper action

AleksandricMarko avatar Jun 25 '26 06:06 AleksandricMarko

@AleksandricMarko can you give me an update?

ADO-BST avatar Jul 28 '26 09:07 ADO-BST

Hi @djukicmilica, could you please share the status

AleksandricMarko avatar Jul 28 '26 09:07 AleksandricMarko

This issue has been approved for contribution ✅ Thanks for contributing.

github-actions[bot] avatar Jul 29 '26 14:07 github-actions[bot]

@ The gap here is not "validate against EN 16931" — that requirement is too large to implement and too easy to defer. What is missing is a priority order: which business rules may reject a document on receipt, which may only warn, and what happens to a document that is formally valid but carries a VAT category BC has no posting group for.

Offering that split, from the perspective of a company that receives these documents and has to decide whether they are deductible.

Hard failures — the document cannot be booked at all

These are the fields without which the receipt is not an invoice in the legal sense, and no amount of manual repair inside BC makes it one:

Rule Field Why it is hard
BR-02 BT-1 invoice number Without it the document cannot be referenced in the VAT return
BR-03 BT-2 issue date Determines the reporting period
BR-05 BT-5 currency Every amount is meaningless without it
BR-06 / BR-07 BT-27 / BT-44 seller and buyer name § 14 Abs 4 Nr 1 UStG
BR-08 / BR-10 BG-5 / BG-8 postal addresses same
BR-CO-15 BT-112 grand total = BT-109 + BT-110 an arithmetically inconsistent invoice cannot be posted
BR-16 at least one BG-25 line item nothing to book

The decisive one for German law is the seller VAT identifier (BT-31) or tax registration (BT-32). Without either, § 15 UStG denies input tax deduction. Booking such a document silently as deductible is the actual financial risk in this issue — larger than the missing validation itself.

Warnings — book it, but flag it

BT-9 due date, BT-10 buyer reference (mandatory only towards public bodies, which is a XRechnung/national profile rule, not EN 16931), BT-13 order reference, payment means, and every semantic rule that only affects readability. These belong in a warning list on the E-Document record, not in a rejection.

The case nobody has raised yet: VAT category codes

This is where receiving hurts more than sending. BT-118 carries the category code and BT-121 the exemption reason, and BC has to map them to a VAT posting group before the document can be booked:

BT-118 Meaning What BC must do
S standard rated ordinary domestic posting group
AE reverse charge recipient owes the tax — different posting group, different box in the return
K intra-Community supply acquisition tax on the recipient side
G export outside the EU zero, evidence required
O outside scope not in the VAT return at all
E exempt needs BT-121, e.g. VATEX-EU-AE, VATEX-EU-IC
Z zero rated distinct from E, distinct from AE

A zero from AE, a zero from K and a zero from G are three different facts that land in three different boxes. If the importer maps all of them to "0 %", the received document books cleanly and the VAT return is wrong — which is a worse failure mode than an import error, because nothing surfaces until an audit. I would argue an unmapped BT-118 should be a hard stop, not a warning: better an unbooked document than a wrongly booked one.

On standalone CII

Agreed, and the reason is worth stating explicitly: EN 16931 defines two syntaxes, UBL and CII, and the German mandate accepts both. Requiring CII to arrive wrapped in a PDF is a ZUGFeRD constraint, not a legal one — an unwrapped CrossIndustryInvoice is a valid e-invoice under § 14 UStG in the 2025 wording. The current split (ZUGFeRD importer expects a PDF, XRechnung importer expects UBL) leaves a legitimate document format with no entry path at all.

Testable data rather than prose

Because arguing about rules in an issue thread is unproductive, the VAT treatment cases are published as plain input/expected-output fixtures, public domain, no implementation attached: https://github.com/PatrickPi1312/eu-vat-conformance — 19 cases covering the categories above, including the ones that break implementations (an invalid customer VAT ID falling back to domestic VAT; a digital service to a business being reverse charge rather than OSS; and one case that deliberately has no correct answer because the OSS threshold is not derivable from the transaction).

They are usable as a conformance set for whatever the receiving path ends up doing, and corrections against them are welcome — an issue with the article that contradicts a case is worth more to me than agreement.

Disclosure: we run a VAT decision engine and an EN 16931 validator commercially at eucompliance.tools, which is where the fixtures come from. The priority split above is not a product argument; it is what we had to decide ourselves before we could book anything. @

PatrickPi1312 avatar Aug 01 '26 12:08 PatrickPi1312

We ran into the same gap when processing inbound German e-invoices. From that experience, it helps to separate the validation into three layers, because they fail differently:

  1. EN 16931 mandatory fields (BR-01…BR-16) — cheap to check, and exactly what would catch the "silently empty fields" problem described here (invoice number, issue date, currency, seller/buyer, VAT identifiers).
  2. Arithmetic and VAT breakdown (BR-CO-10/13/14/15/16, category rules for S/AE/K/G/E/O incl. the mandatory reverse-charge statements) — in our data this is where real-world invoices fail most often, and a missing tax breakdown is far more damaging downstream than a missing text field.
  3. XRechnung/KoSIT Schematron (CIUS) on top — the national business rules.

Layers 1–2 are format-agnostic and work identically for UBL and CII, so supporting standalone CII (point 3 of this issue) comes almost for free once validation is structured this way. +1 on that point in particular: German senders do transmit bare CII XML, and §14 UStG does not require a PDF wrapper.

Until this lands natively, a pragmatic stopgap is a pre-import validation step (e.g. an AL HttpClient call or a Power Automate step) that attaches an itemized rule-level result to the E-Document instead of blocking the import.

Full disclosure: we operate a validation API at https://eucompliance.tools that covers layers 1–2 for UBL and CII (including XML embedded in ZUGFeRD PDFs; profiles XRechnung/ZUGFeRD/Factur-X/Peppol) and returns itemized BR-rule results — we built it for exactly this scenario. Happy to share test samples of commonly failing invoices either way.

PatrickPi1312 avatar Aug 03 '26 15:08 PatrickPi1312

Supporting this from the practitioner side: the legal reading in the issue matches ours. § 14 UStG (Wachstumschancengesetz) has required the ability to receive structured B2B e-invoices since 2025-01-01, and the BMF letter of 2024-10-15 binds that to EN 16931 — a document missing mandatory elements (BT-1, BT-2, BT-5, BG-23, totals) simply isn't the invoice the law means. Storing whatever arrives, silently, moves that problem into posting and VAT deduction, where it is much more expensive to discover.

For partners who need something before a platform fix ships, two workable stopgaps at the interface level (validate the raw XML before/right after the E-Document import, surface findings to the user):

  1. Self-hosted: the KoSIT validator with the XRechnung configuration, or the CEN validation artefacts (official Schematron/XSLT) run through an XSLT-2 processor — both give the complete official business-rule verdicts, not just a field-presence check.
  2. If operating a Java/XSLT toolchain next to BC is the blocker: we run the complete official EN 16931 Schematron rule set (CEN artefacts 1.3.16, unmodified) behind a plain HTTPS endpoint — UBL, CII and ZUGFeRD PDFs, every finding with its BR- code and severity, response signed so it can be attached to the document as validation evidence. Details: https://eucompliance.tools/llms.txt

Neither replaces native validation in the format apps — cardinalities and BR-CO arithmetic belong in the platform — but both close the compliance gap today.

PatrickPi1312 avatar Aug 03 '26 18:08 PatrickPi1312

Hi @ADO-BST could you please move the issue into https://github.com/microsoft/BCApps?

djukicmilica avatar Aug 09 '26 19:08 djukicmilica

Moved to BCApps

AndersLarsenMicrosoft avatar Sep 01 '26 14:09 AndersLarsenMicrosoft