Export data as XML with UBL 2.1 Schema


I believe it would be a great improvement to be able to export data (invoices especially) to UBL.
UBL is an international ISO Standard and has been approved by the European Commision (article1). Being able to export to a UBL-xml would enable accountants al over europe to import the data into their software.

Indeed, the UBL Invoice is the only XML Invoice document standard that is sanctioned, stable, integrated within a suite of supply chain documents and is the nearest thing the world has to a purpose-built ebXML document format.

4 Part article on UBL (very interesting!): UBL is an ISO international standard, so now what?
The UBL 2.1 Standard by Oasis: UBL 2.1 Docs
Invoice structure + example in UBL 2.1: UBL 2.1 Docs - Invoice

I’m aware there are a multitude of xml schemas being used though (UBL 2.1, Finvoice, OIO, Svefaktura, ZUGFeRD).

I suggest a XML-exporter with schema selector.

Last Update: 19.01.2017

Related topic: Export invoice list to PDF, Excel, or CSV format

I totally agree with your feature request.
As stated in your request above we currently see that each EU country uses its own internal specifications.
Is it possible to build a common UBL 2.1 plugin with the ability to select a UBL-specific version/schema?
This way a user can determine what kind of UBL his customer needs or wants to use; Zugferd, UBL 2.1, UBL-PEPPOL, UBL-efff, UBL-SI, …
These UBL-specific version (schema) could then later be added to the system as needed.

1 Like

If someone can help me a bit I would love to contribute further to this feature.

I took a look at how the ZuGFerD xml get’s generated and it’s seems straight forward enough for me to be able to deduce how to correctly generate the UBL XML from that.

I suggest adding:

  • a button to the invoice ‘options’ with ‘Download UBL XML’ or changing the ‘Download pdf’ to ‘Download’ and using a modal for the file-type choice.
  • a file-type multi-select (multi so you can send pdf and xml if unsure what the receiver can handle) to the ‘send email’ page with options ‘normal pdf’,‘ZuGFerD pdf’, ‘UBL 2.1 xml’,…
  • a dropdown-select for the XSLT to style the xml (http://www.w3schools.com/xml/xsl_value_of.asp)

So I think I can do the xml generation part, but how do I go about this? (First time contributing to open-source)
First I do a pull-request on github, then write the xml generation code, and then do a merge-request. Is that about right?
Can grand wizard @Kovah perhaps point me in the right direction?

1 Like

Hi there!
Thanks for the interest in the feature.

I personally would add a new button which downloads the XML. I don’t know if it’s common to change the format of the XML (XSLT?) often but maybe you could just simply add a new setting for the XML style that is set once. I’m not familiar with this XML stuff so I can’t help you very much with the requirements, settings and so on.

I would recommend.mend to fork the project on GitHub and treat it like a normal project: check it out to your machine, switch to the 1.4.11 branch, develop the feature and then push the changes back to GitHub. Please make sure that you add the issue ID to all commits, I will add it tomorrow.
If everything is done just notify me and I will create a pull request.
You may join our slack chat so you can ask me if you have any questions. :slight_smile:

1 Like


@maxdevos:I would like to contribute to the construction of this feature.
Remember that it depends on how ‘the customer’ treats his invoices, his internal workflow and the country in which he is established.
I suggest to first replace the zugferd setting to make a checkbox or radio button ‘Use UBL’ (yes/no) and then display a drop-downmenu where, among other UBL versions; zugferd, UBL 2.1, … can be selected.
For email you could default sent the pdf and xml file as attachments to your customer.
Give the customer also the possibility (drop-downmenu) to download the required UBL version on his own invoice/payment page.

Just to clarify: is Ubl and XML extension for PDF file like Zugferd or is it a raw XML file?

It’s a raw xml file.
That’s why I would add some styling to the file which I thought was gonna work through XSTL but I seem to be mistaken.
Lets start with a simple raw XML and worry about styling later.

I did some more reading and I would actually suggest NOT adding other additional formats besides the already implemented zugFerD and the standard UBL 2.1 because the whole point of UBL (U stands for Universal) is to make the Business transaction data universal. Other formats are mostly aimed at Invoicing only (like zugFerd, Finvoice, etc …) and thus might not be very future proof. Where-as it seems UBL is here to stay.

What is the dependency you are referring to? UBL is accepted in the EU and Universal so I would argue it does not depend on the country (if inside Europe at least) or workflow.

What do you think about the following, just keeping it simple:

Perhaps also include a “Mark invoice a sent if UBL-XML is generated” option.
And indeed also give the customer the option to download it.

1 Like

Hello there,

I am aware of the fact that UBL is indeed ISO certified, globally and in the EU accepted, but today almost every EU country has its own UBL format. Numerous UBL dialects are in use e.g. ZUGFeRD in Germany, UBL SI and UBL OHNL in the Netherlands, UBL eFFF in Belgium, UBL Peppol is used by the governement in different countries and by various industries, etc… More information about this problem can be found here: http://scobdo.eu/background/.
Till this problem is solved and for the time being I propose to add a UBL setting for each client (comparable to the language setting and the template system) as I already implemented on my own system.

For now, some items can be selected in the list box; Zugferd (DE), UBL EFFF (BE), and more can be easily added as the UBL library files (cfg templates) are created.
In this dropdown list the user can choose for the client’s UBL version which he wants to use. Each UBL-format/version has his own library which generates his specified xml file. Included for Zugferd (DE) and external for others like UBL efff (BE).

I do have eliminated the global “Zugferd xml” setting.
I hope that these adjustments may be useful for someone.

I myself am struggling howto attach the external UBL (XML) files to emails.
Q: How do I get the external XML file as an attachment in the email? Can someone point me in the right direction? Some examples might help me out…

Hope this helps. This is where attachment files are added to an invoice:



@maxdevos Thanks for pointing me into the right direction.
This helped me alot (as a starting point) to find where the pdf-invoice is attached and also where the ubl should be added in the email.
I’ve got this working well.
My procedure:

  1. Choose (individually) the right UBL setting for your client.
  2. Create the invoice and send it to the client.
    -> No need to add the created ubl as attachment to the email.
    -> If the ubl-file is created then my function will automatically attach it to the email.
    -> If your client setting is ‘Zugferd UBL’ then the UBL-file is included into the pdf.

@Kovah: (simply out of curosity) is there a reason why the date is added to the ‘pdf-invoice-filename’ in the archive folder?


Can I view your branch on github? I’d like to see how you did it / wrote the functions.
The procedure looks good and it makes sense choosing the format per client instead of per invoice.

I think the date in the filename is an accounting thing.


No problem to show you my coding but…
I am by no means a real developer but I like to find things out and improve where necessary. That’s why I have my adjustments built on a local wamp server instance and not (yet) on github.
Can you show me how to setup and configure github on Windows for InvoicePlane webdevelopment?
In short what did I do:

  1. I have eliminated the global ‘pdf zugferd’ setting.
  2. In the client setting I added a UBL dropdown-menu. See 1ste screenshot in item # 9.
  3. At the same time I added a “contacts field” (for departments or personal names) to the client and user setting because that was lacking in my opinion.
  4. As you can see also (other screenshots - red arrow) in the same item #9 I added some client settings in the invoice view page, e.g. contact, UBL version, VAT Id.
  5. The two screenshots shows a UBL efff version (external file) and a Zugferd version (included in the PDF).
  6. I also (instead of the menu-item ‘Download PDF’) created a ‘View PDF’ menu-item that displays the invoice PDF file in a modal window on the same webpage.
  7. Finally, as described in item # 11 I have made adjustments to ‘phpmailer_helper.php’ so that the pdf invoice and the external UBL-file (if available) are automatically added to the email.

    // Add the attachment if supplied
    if ($attachment_path && $CI->mdl_settings->setting(‘email_pdf_attachment’)) {
    $attachfile = pathinfo($attachment_path);
    // check the date prefix: ‘2017-02-01’_ == today, then strip, copy and attach the new file)
    if ( substr($attachfile[‘filename’], 0, 10) == date(‘Y-m-d’) ){
    $filename = $attachfile[‘dirname’].’/’.substr_replace($attachfile[‘filename’], ‘’, 0, 11);
    copy($attachment_path, $filename.’.pdf’);
    if (file_exists($filename.’.xml’)) {

@VeRony Did you completed the feature and would make it public?