Skip to content

ZUGFeRD (and FacturX)

lasalesi edited this page Nov 20, 2020 · 8 revisions

Factur-X or ZUGFeRD is an industry standard for electronic invoices. Refer to https://www.ferd-net.de/zugferd/definition/was-ist-zugferd.html for more details.

ZUGFeRD module

The ZUGFeRD module in ERPNextSwiss provides an implementation according to EN 16931 for electronic invoices. It can

  • create electronic invoices from Sales Invoices (PDF with Factur-X content)
  • create new purchase invoices from a electronic invoices

Usage

Create a ZUGFeRD-enabled sales invoice

  • Open the sales invoice and click the e-PDF button. This will create a downloadable pdf with an electronic invoice part

Import a ZUGFeRD purchase invoice

From purchase order

  • Click Make > Invoice
  • Click the button From e-PDF. Select the PDF-invoice with the electronic invoice. The values will be fetched

New purchase invoice

  • Click the button From e-PDF. Select the PDF-invoice with the electronic invoice. The values will be fetched

System configuration notes

In order for ZUGFeRD to work properly, a well-working system configuration is essential. Especially,

  • Company: address
  • Sales Taxes
  • VAT numbers on customers and suppliers

Sales Invoice Custom Script

To be able to download an ZUGFeRD-PDF, add this custom script.

frappe.ui.form.on('Sales Invoice', {
    refresh: function(frm) {
        frm.add_custom_button(__("Download e-PDF"), function() 
        {
            generate_zugferd_pdf(frm);
        });
    }
});


function generate_zugferd_pdf(frm) {
    var w = window.open(
    frappe.urllib.get_full_url("/api/method/erpnextswiss.erpnextswiss.zugferd.zugferd.download_zugferd_pdf?"						
    + "sales_invoice_name=" + encodeURIComponent(frm.doc.name)
        ));
	    if (!w) {
            frappe.msgprint(__("Please enable pop-ups")); return;
        }
}

FAQ

PDFs are generated but have no factur-x content

The system will fall back to normal PDF generation, if anything with the factur-x module fails. In this case, check the Error Log. It will contain a record with the error.

Missing data

In case some mandatory information is missing, the factur-x creation fails. Notably

  • missing address
  • missing payment terms

factur-x error

In case you observe The second argument of the method generate_facturx must be either a string, an etree.Element() object or a file (it is a <class 'bytes'>)., you might be using an old version of factur-x. Please remove and install the current version using

$ cd /home/frappe/frappe-bench
$ env/bin/pip uninstall factur-x
$ env/bin/pip install factur-x