ZUGFeRD and Factur-X are hybrid e-invoicing formats used primarily in Germany and France. They follow the Cross Industry Invoice (CII) standard, which the United Nations Centre for Trade Facilitation and Electronic Business (UN/CEFACT) specifies. They combine a PDF/A-3 file with embedded XML data, meaning the invoice is both human-readable (PDF) and machine-readable (XML) within the same document.
DocumentsCorePack allows for the creation of documents that comply with these formats through the use of One-Click-Actions. This article will demonstrate exactly how to generate such documents. At the end, you will find working samples under Attached Files to quickly try it out yourself.
Prerequisites:
- DocumentsCorePack Server: Version 2024.4 or higher (learn how to update here)
Creating the OCA
To generate a ZUGFeRD/Factur-X-compliant invoice document, we will need to configure a One-Click-Action (OCA) for our Invoice entity. You can create this OCA as usual, but be sure to set the Template Selection to ZUGFeRD (Multipart) under Template Settings.
Note: You can create an OCA for any table in your system, not just invoices, using this functionality. Additionally, while our sample focuses on invoices, you can just as easily apply it to credit notes, debit notes, order confirmations, and other scenarios.
Tip: You can automate OCAs like this using Microsoft Flows with our DocumentsCorePack connector. Find more information here.
Differences to regular OCAs
Selecting this setting will open a Multipart that has two parts: “ZUGFeRD pdf” and “ZUGFeRD xml.” For each of these parts, you have to select a template. In the “pdf” row, select a ❶ template that will display the visual contents of the document as a PDF. In the “xml” row, select a ❷ template to embed as an XML file in the resulting PDF.
Note: If you do not know how to create an XML template, please see here.
You can easily add additional, optional parts to the Multipart, which will concatenate with the resulting PDF. This can be handy when adding cover pages or terms and conditions, for instance. The default concatenation options are available.
After you select the templates, you can configure the rest of the OCA. Do note, however, that the file type for this specific type of OCA is locked to PDF and cannot be changed. Additionally, if you want to send a document directly to a recipient, you will need to set the Attach document option to email attachment.
Furthermore, you cannot edit the selected templates (as modifications could cause the visual to misalign with the XML), and the DocumentsCorePack Dialog cannot create a PNG preview of the generated document.
Save the OCA after you have finished setting it up. Then, navigate to the Create Document button to run your OCA.
Running the OCA
Select your newly created OCA in the Create Document dialog. Whether you’re using the Template Designer or the Create Document dialog, you can individually test components like the PDF or XML as usual. However, to generate a PDF with the embedded XML, you must always use an OCA.
Although DocumentsCorePack does not verify a ZUGFeRD/Factur-X document against a specific schema, it does check whether the XML file is valid. If the file is invalid, you will receive an error message, and the process will halt to prevent the creation or sending of invalid files.
When you download and open the generated PDF, you will see the XML file in the PDF’s attachments.
Note: Ensure that the PDF viewer you choose is capable of this before opening your PDFs, because not all PDF viewers (such as web browsers) can view PDF attachments.
If you’re using your template for e-invoicing in a specific standard, use an online validation tool to check compliance. To ensure your template meets the required standards, start by adjusting it based on any issues found during conformity checks. This way, you can maintain compliance and avoid potential errors in your e-invoicing process.
Try it yourself!
For your convenience, we have provided two templates under Attached Files beneath the article: a template to generate a PDF (“Invoice sample for OCA”) and a template to generate an XML file to attach to the PDF (“InvoiceTemplate-xml-CII_D16B”). You can use these files to test this feature in your own environment.
Please note that these files are just examples meant to demonstrate how the basic technique works. We have tried to adhere to the described standard, and the fields used refer to standard Dynamics systems.
That’s it! We appreciate your feedback on ZUGFeRD and Factur-X for DocumentsCorePack! Please share your thoughts by sending an email to support@mscrm-addons.com.