How to make ZUGFeRD in FastReport.Net
The ZUGFeRD standard was developed in Germany specifically to simplify the process of electronic invoicing. This standard allows you to exchange invoices without a preliminary agreement between the supplier and the recipient of the services or goods. In Germany, this standard extends to everywhere: in small, medium and large businesses, as well as in public institutions.
The name of the standard is the abbreviation ZUGFeRD. It stands for "The Unified User Guide developed by the German Forum on Electronic Invoices."
EDI (Data Interchange Electronic) - electronic document standard already used in Germany, but it is used only in large companies. The goal of ZUGFeRD is to cover all spheres of activity in the country, whether it be private enterprise or a large automotive concern. This standard is universal and not tied to a particular industry.
ZUGFeRD is based on the use of structured data. This is implemented using the XML standard. A human-readable account representation is implemented using the PDF / A standard. The PDF / A-3 format has the ability to include arbitrary types of objects in the document. Due to this, an XML representation of structured invoice data is included in the document. Thus, one document contains both a human-readable representation and a machine-readable one.
Advantages of ZUGFeRD before paper workflow:
- • Saves paper;
- • saves the time of document transfer;
- • saves the human resource required to deliver the document;
- • saves time searching for a document;
- • Saves space for documents storage, because electronic;
- • accelerates the process of payment of payment orders, which improves the liquidity of goods;
- • significantly reduces the percentage of errors in documents, due to the automatic addition to accounting systems;
- • eliminates the costs of manually adding to databases, thanks to integration with automated accounting systems;
- • saves time for document approval, thanks to fast delivery.
ZUGFeRD supports the following account types:
• Commercial invoices (invoices for goods and services) with code 380;
• Notifications (for example, requirements for payment of taxes by public authorities) with code 380;
• Commercial credit notes (for example, corrected invoices / cancellations) with a negative value (code 380).
ZUGFeRD Comfort also supports:
• Debit note regarding financial adjustments (code 84);
• A credit note associated with financial adjustments with a negative value (code 84).
ZUGFeRD Extended also supports:
• Self-evaluation accounts (credit note / self-billing procedure in accordance with tax legislation, code 389);
• Self-evaluation of credit notes with a negative value (code 389).
Now let's look at some details of the ZUGFeRD standard document. As noted above, an XML document is integrated into the PDF file for computer processing of invoices. It is also possible to include the XSD schema into a PDF document.
An XML file is always embedded in a PDF document with name "ZUGFeRD-invoice.xml". There is also the option to insert other documents explaining the invoice as additional files.
Here is a typical invoice in the form of an XML part of the ZUGFeRD document:
Let's now consider an example of using FastReport.Net to generate ZUGFeRD invoices. You can find it in the folder "J: \ Program Files (x86) \ FastReports \ FastReport.Net \ Demos \ C # \ ZUGFeRD". The project is a common WinForms application.
The form contains an input field and two buttons:
One of the buttons allows you to specify the path to the file using the standard file open dialog. The second button starts the procedure for generating the ZUGFeRD document.
Consider the code for the entire form class:
From the comments to the code it is clear that we are performing the export of the pre-created report to PDF. In doing so, we set the PDF / A-3 standard and add the ZUGFeRD account file to the xml document.
Let's look at the report template, which is an invoice issued according to the ZUGFeRD standards.
To generate the XML representation of this report, you need to use the library, which can be found here: https://www.nuget.org/packages/ZUGFeRD-csharp/.
Using the code and ZUGFeRD-csharp library, we generate the following XML file:
Run the program:
We select the xml-file of the invoice. Click on "Create PDF / A-3b with embedded XML". And this is how the human-readable representation of the document looks like, actually the PDF document itself:
Thus, in order to use the xml view of ZUGFeRD in conjunction with the FastReport report, you only need to export the report in PDF A-3 and attach the xml file.