4D v20 R4 introduces an exciting feature in 4D Write Pro—now, it empowers you to generate electronic invoices. But what exactly do we mean by e-invoices?
An electronic invoice (or e-invoice) is generated, transmitted, received, and stored electronically, enabling more efficient and environmentally friendly management of business transactions.
While they offer many advantages, they also come with their own specific constraints, particularly in terms of the complexity of the generation process. However, with 4D Write Pro, we’ve come to realize that managing this complexity is much more manageable than initially perceived!
HDI: Electronic Invoice Generation
Why electronic invoices?
Electronic invoices can take a variety of digital formats, such as PDF (which we’ll be using), and can be transmitted via online portals, CRMs, and so on. Their processing can be automated, reducing management time, the risk of errors, the need for printing, physical storage, ecological impact, etc.
It’s also known as an intelligent or hybrid format because it can be read by a human being and a computer.
It is also a format that will become mandatory and essential in the months or years to come in countries all over the world (Factur-x in Europe), particularly for all government-related matters.
4D Write Pro and the Factur-X/ZUGFeRD format
4D Write Pro already allows you to produce files in PDF format and, since 4D V20 R3, also in PDF/A2 and PDF/A3 formats. For e-invoices, the PDF/A3 format will be used, as it allows external files to be integrated. In the case of an electronic invoice, only one external file is needed, an XML file. This one must be the first one if many files are integrated.
To sum up, we can say that PDF/A3 + XML = Factur-X (in France) / ZUGFeRD(in Germany) will be done in a single step by 4D Write Pro!
What content for XML?
The Factur-X/ZUGFeRD XML file contains structured information on the invoice, such as seller and buyer details, billing lines, amounts, taxes, etc.
European standard templates such as MINIMUM, BASICWL, EN 16931, BASIC, and EXTENDED are the most common ones.
“Custom” formats can also be used, but their validation (we’ll return to this) will be less obvious, and their use restricted.
Complete information about these formats can be found on the fnfe-mpe.org website: https://fnfe-mpe.org/factur-x/factur-x_en/
How do I generate a Factur-x/ZUGFeRD?
Let’s not forget that an electronic invoice is, first and foremost, a PDF in which new information is included. Two new attributes have been added to the existing ones for PDF export.
Let’s start with “facturx”
This attribute, facturX, is an object that contains only two optional attributes.
This means that the mere presence of this object, even empty, will be enough to generate a valid Factur-X/ZUGFeRD document.
$options:={}
$options.facturX:={}
$options.facturX.profile:="BASIC" // optional (when passed, it must match the first file XML content)
$options.facturX.version:="1.0" // default value
Then comes “files”
Many files can be included in a PDF/A3 document. That’s why the files attribute is a collection that will contain objects, each describing the file to be included.
They will have attributes that will differ according to the file function. In the case of an electronic invoice (reminder: first file in the list), most attributes are optional except, of course, for the XML content that can be sent either through a data attribute (as text) or a file attribute (as 4D.File).
Notes:
The XML must be pre-generated and meet all the requirements of the standard (the HDI demo shows an example of XML creation based on the BASIC profile). 4D Write Pro won’t check your XML file content, so ensure you validate your XML file before inserting it into the Factur-X / ZUGFeRD e-invoice.
$xmlFile:={} // creates the first file object
$xmlFile.name:="factur-x.xml" // default value
$xmlFile.description:="Factur-X/ZUGFeRD Invoice" // default value
$xmlFile.mimeType:="text/xml" // default value
$xmlFile.data:=$xmlText // MUST be valid, NOT checked by 4D
$xmlFile.relationship:="Data" // default value
$options.files:=[$file] // more files could be added, the first one always is for facturX/ZUGFeDR
or (variation, instead of $xmlFile.data)
$xmlFile.file:=$xmlFile // actual file on disk that must be a valid xml file
Online validation
As mentioned above, 4D Write Pro does not validate content. Only the structure is checked. However, there are online validators. The most reliable seems to be veraPDF (https://demo.verapdf.org) and fnfe-mpe.org (https://services.fnfe-mpe.org/account/home). The second one has the double advantage of being able to validate the XML itself and, secondly, a complete invoice (See the HDI for a full example).
Conclusion
This new functionality responds to a growing demand for modernity and fills legal and administrative requirements.
Generating electronic invoices in series will be simple, thanks to generic templates and methods for generating correctly formatted XML.
Ultimately, the trickiest part may be choosing between the various possible profiles, but usage often dictates this choice.
Share your feedback and thoughts on this new feature in the 4D Forums.
More about this feature can be read in the documentation.