• Stars
    star
    108
  • Rank 319,416 (Top 7 %)
  • Language
    Python
  • License
    Other
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python lib for Factur-X, the e-invoicing standard for France and Germany

Factur-X and Order-X Python library

Factur-X is the e-invoicing standard for France and Germany. The Factur-X specifications are available on the FNFE-MPE website in English and French. The Factur-X standard is also called ZUGFeRD 2.1 in Germany.

Order-X is the equivalent of Factur-X for purchase orders. The Order-X specifications are available on the FNFE-MPE website in English. The Order-X standard is also the fruit of a collaboration between France and Germany and you can find information about it in German on the FeRD website.

The main feature of this Python library is to generate Factur-X invoices and Order-X orders from a regular PDF document and a Factur-X or Order-X compliant XML file.

This lib provides additionnal features such as:

  • extract the XML file from a Factur-X or Order-X PDF file,
  • check a Factur-X or Order-X XML file against the official XML Schema Definition.

Some of the features provided by this lib also work for ZUGFeRD 1.0 (the ancestor of the Factur-X standard).

Installation

This library works both on python 2.7 and python 3.

To install it for python 3, run:

sudo pip3 install --upgrade factur-x

To install it for python 2.7, run:

sudo pip2 install --upgrade factur-x

Usage

from facturx import generate_from_file

generate_from_file(regular_pdf_file, xml_file)

The PDF file regular_pdf_file will be updated to Factur-X/Order-X. If you want to write the resulting Factur-X/Order-X PDF to another file, use the argument output_pdf_file.

To have more examples, look at the docstrings in the source code or look at the source code of the command line tools located in the bin subdirectory.

Command line tools

Several command line tools are provided with this lib:

  • facturx-pdfgen: generate a Factur-X or Order-X PDF file from a regular PDF file and an XML file
  • facturx-pdfextractxml: extract the XML file from a Factur-X or Order-X PDF file
  • facturx-xmlcheck: check a Factur-X or Order-X XML file against the official XML Schema Definition

All these commande line tools have a -h option that explains how to use them and shows all the available options.

Webservice

This project also provides a webservice to generate a Factur-X or Order-X PDF file from a regular PDF file, the XML file and additional attachments (if any). This webservice runs on Python3 and uses Flask. To run the webservice, run facturx-webservice available in the bin subdirectory of the project. To query the webservice, you must send an HTTP POST request in multipart/form-data using the following keys:

  • pdf -> PDF file (required)
  • xml -> Factur-X or Order-X file (any profile, required)
  • attachment1 -> First attachment (optional)
  • attachment2 -> Second attachment (optional)
  • ...

It is recommended to run the webservice behind an HTTPS/HTTP proxy such as Nginx or Apache. You will certainly have to increase the default maximum upload size (default value is only 1MB under Nginx!): use the parameter client_max_body_size for Nginx and LimitRequestBody for Apache.

You can use curl, a command line tool to send HTTP requests (on Linux Ubuntu/Debian, just install the curl package) to generate the request:

curl -X POST -F 'pdf=@/home/me/regular_invoice.pdf' -F 'xml=@/home/me/factur-x.xml' -F 'attachment1=@/home/me/delivery_note.pdf' -o /home/me/facturx_invoice.pdf https://ws.fnfe-mpe.org/generate_facturx

A public instance of this webservice is available on a server of FNFE-MPE at the URL https://ws.fnfe-mpe.org/generate_facturx.

Licence

This library is published under the BSD licence (same licence as PyPDF4 on which this lib depends).

Contributors

Changelog

  • Version 2.5 dated 2023-03-24
    • Add support for ZUGFeRD 1.0 in get_level()
    • xml_check_xsd(): avoid warning Use specific 'len(elem)' or 'elem is not None' test instead.
  • Version 2.4 dated 2023-03-13
    • Update Factur-X XSD of all profiles to version 1.0.6
    • Update Order-X XSD of all profiles to version 1.0.0
  • Version 2.3 dated 2021-04-12
    • Fix wrong flavor argument passed by generate_facturx_from_file() to generate_from_file()
  • Version 2.2 dated 2021-04-08
    • Make method generate_from_binary() accessible via the lib
  • Version 2.1 dated 2021-04-07
    • Update Order-X XSD to the latest version provided to me by FNFE-MPE
  • Version 2.0 dated 2021-04-04
    • Add support for Order-X. This implies several changes:
      • method check_facturx_xsd() deprecated in favor of the new method xml_check_xsd() but still operates with a warning
      • method get_facturx_flavor() deprecated in favor of the new method get_flavor() but still operates with a warning
      • method generate_facturx_from_binary() deprecated in favor of the new method generate_from_binary() but still operates with a warning
      • method generate_facturx_from_file() deprecated in favor of the new method generate_from_file() but still operates with a warning
      • new optional argument orderx_type for methods generate_from_file() and generate_from_binary() with default value autodetect
      • new method get_orderx_type() to get the Order-X type (order, order change or order response)
      • new method get_xml_from_pdf() that work both on Factur-X and Order-X (the method get_facturx_xml_from_pdf() still exists and only operates on Factur-X)
      • scripts updated
    • Add lang argument to methods generate_from_file() and generate_from_binary() to set the lang of the PDF. This is one of the requirements for PDF accessibility, which is important for people with disabilities: it allows PDF speech synthesizers for blind people to choose the right language.
    • Add ability to choose the AFRelationship PDF property for the Factur-X/Order-X XML file and also for the additionnal attachments:
      • new argument afrelationship for methods generate_from_file() and generate_from_binary()
      • new key afrelationship for the attachments dict as argument of generate_from_file() and generate_from_binary()
    • Argument additional_attachments was deprecated in method generate_facturx_from_file() in version 1.8: it doesn't operate any more and only displays a warning.
    • Replace the optparse lib by the argparse lib in scripts.
  • Version 1.12 dated 2020-07-16
    • Compress attachments and XMP metadata using Flate compression
  • Version 1.11 dated 2020-05-11
    • Fix crash UnicodeEncodeError on Python 2.7
  • Version 1.10 dated 2020-04-14
    • Update XSD of all profiles to Factur-X version 1.0.5
  • Version 1.9 dated 2020-02-11
    • Improve Python3 support in get_facturx_xml_from_pdf()
  • Version 1.8 dated 2020-01-16
    • New tool facturx-webservice which implements a REST webservice using Flask to generate a Factur-X PDF invoice via a simple POST request.
    • New argument 'attachments' for generate_facturx_from_file() which replaces argument additional_attachments:
      • Possibility to set a filename for the attachment different from filename of the filepath
      • Possibility to set creation dates for attachments
      • Update script facturx-pdfgen to use the new attachments argument
  • Version 1.7 dated 2020-01-13
    • Fix bug in release 1.6 in XMP: variables were not replaced by their real value
  • Version 1.6 dated 2020-01-09
    • Generate XMP (XML-based PDF metadata) via string replacement instead of using XML lib
  • Version 1.5 dated 2019-11-13
    • Fix bug in generate_facturx_from_file() when using argument additional_attachments
  • Version 1.4 dated 2019-07-24
    • Update Factur-X XSD to the final version of Factur-X v1.0.04
    • Support XML extraction with ZUGFeRD invoices using 'zugferd-invoice.xml' filename (instead of the filename 'ZUGFeRD-invoice.xml' specified by the standard)
  • Version 1.3 dated 2019-06-12
    • Add XSD files for Extended profile in the Python package
  • Version 1.2 dated 2019-06-12
    • add support for the Extended profile
    • validate XML for Minimum and Basic WL profiles with the XSD of profile EN 16931, as asked by Cyrille Sautereau
    • minor improvements in the code for /Kids
  • Version 1.1 dated 2019-04-22
    • Improve support for embedded files extraction by adding support for /Kids
  • Version 1.0 dated 2019-01-26
  • Version 0.9 dated 2019-01-25
  • Version 0.8 dated 2018-06-10
    • Make pretty_print work for XMP file, for better readability of that file
  • Version 0.7 dated 2018-05-24
    • Fix XMP structure under /x:xmpmeta/rdf:RDF/rdf:Description (use XML tags instead of XML attributes)
    • declare PDF-1.6 instead of PDF-1.3 (still declared by default by pyPDF2)
  • Version 0.6 dated 2018-05-01
    • Now fully PDF/A-3 compliant with additionnal attachments (tested with veraPDF)
    • facturx-pdfgen: don't overwrite by default and add --overwrite option
    • Add factur-x library version number in metadata creator entry
  • Version 0.5 dated 2018-03-29
    • Fix XMP metadata structure
    • Now fully PDF/A-3 compliant when the input PDF file is PDF/A compliant (tested with veraPDF). This implied copying /OutputIntents and /ID datas from source PDF to Factur-X PDF.
    • Fix support for additionnal attachments: they can now all be saved with Acrobat Reader
    • Improve XML extraction from PDF Factur-x file
  • Version 0.4 dated 2018-03-27
    • Factur-x specs say /AFRelationship must be /Data (and not /Alternative)
    • Update Factur-X XSD to v1.0 final
    • Add support for additionnal attachments
    • Add factur-x lib version in Creator metadata table
    • Add /PageMode = /UseAttachments, so that the attachments are displayed by default when opening Factur-X PDF invoice with Acrobat Reader
    • Improve and enrich PDF objects (ModDate, CheckSum, Size)

More Repositories

1

ooor

Odoo Ruby JSON client. Emulates ActiveRecord enough (as much as Mongoid; Implements ActiveModel) to make Rails development with an Odoo datastore straightforward
Ruby
190
star
2

odoo-usability

Akretion addons to improve Odoo Community Edition + OCA usability
Python
116
star
3

nfelib

nfelib - bindings Python para e ler e gerir XML de NF-e, NFS-e nacional, CT-e, MDF-e, BP-e
Python
97
star
4

pywebdriver

Python Web Services to communicate wih Devices
Python
88
star
5

docky

Docky - Helper for docker-compose mainly used in odoo context
Python
54
star
6

boleto_cnab_api

API server for brcobranca (Brazilian boleto/CNAB electronic payment project)
Ruby
42
star
7

angular-odoo

Call Odoo webservices from AngularJS
JavaScript
41
star
8

odoo-py3o-report-templates

Sample reports (quotation, PO, picking, invoice...) for report_py3o
Python
32
star
9

sped-extractor

SPED (Sistema Público de Escrituração Digital) no Odoo ERP (ECD, ECF, EFD ICMS IPI, EFD PIS COFINS)
Python
25
star
10

pypostelium

Python Libraries for Point Of Sale Telium payment terminal
Python
24
star
11

factur-x-libreoffice-extension

Libreoffice Extension to generate PDF Factur-X invoices with Libreoffice Calc
Python
22
star
12

connector-search-engine

This project is now maintained at the OCA at https://github.com/OCA/search-engine
Python
22
star
13

roulier

API for package delivery
Python
20
star
14

ak-odoo-incubator

Misc Odoo modules maturing before going to a specific repo
HTML
20
star
15

connector-google-spreadsheet

Data spreadsheet import in Odoo https://www.youtube.com/watch?v=JiW67o4QCVA
Python
17
star
16

odoo-viewer-groups

Adds viewer security level in Odoo
Python
16
star
17

ooorest

Odoo On Rails, the REST way! A Restful engine and framework to unleash Odoo in Rails applications...
Ruby
14
star
18

nfselib

bindings Python das NFS-e de 450 cidades (usando xsdata com os XSD's do UNINFE)
Python
12
star
19

vim-odoo-snippets

Vim snippets for Odoo
Vim Snippet
12
star
20

ak

The toolbelt for Odoo
Python
12
star
21

connector-amazon

Amazon Connector for odoo
Python
11
star
22

vertical-olive-mill

Opensource Odoo module to manage an Olive Mill. Sponsored by the Barroux Abbey.
Python
11
star
23

odoo-json-rpc

JavaScript
10
star
24

odoo-mooncard-connector

Connector between Odoo (OpenSource ERP) and Mooncard (new-generation corporate cards)
Python
10
star
25

overdue-reminder

Odoo module to handle invoice overdue reminders
Python
9
star
26

xsdata-odoo

Odoo abstract model generator from xsd schemas using xsdata
Python
9
star
27

pyposdisplay

Python Libraries for Point Of Sale Display
Python
8
star
28

file-exchange

File Exchange
Python
7
star
29

esociallib

biblioteca para ler e gerir documentos de Sistema de Escrituração Digital das Obrigações Fiscais, Previdenciárias e Trabalhistas (eSocial)
Python
7
star
30

odooapps

JavaScript
6
star
31

ovh-supplier-invoice

Download OVH invoices as supplier invoices in Odoo via SoAPI. For v10, use the module account_invoice_download_ovh from https://github.com/OCA/edi/pull/30
Python
6
star
32

odoo-elasticapm

Elastic APM integration for Odoo
Python
6
star
33

docker-openupgrade

Basic Docker Images with OpenUpgrade
Dockerfile
6
star
34

ctelib

biblioteca para ler e gerir documentos de Conhecimento de Transporte eletrônico (CT-e)
Python
6
star
35

generateds-odoo

generateDS extension to generate Odoo model mixins from XSD schemas
Python
5
star
36

aktooor

forms to edit Odoo entities in your Ruby web app (based on simple_form)
Ruby
5
star
37

bank-statement-reconcile-simple

An very simple alternative to OCA/bank-statement-reconcile for odoo
Python
5
star
38

erpify

brings Odoo entitites to your customizable Ruby website via the Liquid non-evaling markup language from Shopify
Ruby
5
star
39

csv2xml4odoo

Odoo csv / xml converter
Python
5
star
40

support

Support module between Akretion and customers
Python
5
star
41

ak-prestashop

Cookbook for installing easily prestashop, do not use it for production environnement, it's just for demo
Ruby
5
star
42

factur-x-validator

Odoo module for Factur-X validation
Python
5
star
43

ak-magento

Chef recipe for install magento and webservice extension needed by MagentoERPconnect
Ruby
4
star
44

odoo-import-helper

Small modules to help on data import in Odoo
Python
4
star
45

account-move-import

Python
4
star
46

laposte_api

Python
4
star
47

odoo-ionic-picker

JavaScript
4
star
48

jenji-connector

Odoo-Jenji connector
Python
4
star
49

openerp-addons

git mirror of https://code.launchpad.net/openobject-addons
Python
4
star
50

astrotrain

A transformer that will convert a Shopify template into a Locomotive one
Python
4
star
51

caisse-ap-ip

Caisse-AP over IP protocol server and client
Python
4
star
52

prodoo

Web app to log in to Odoo, access Manufacturing Orders and manage them
JavaScript
4
star
53

sale-configurator

[WIP] Product Configurator based on configurable option (each option is an other product)
HTML
4
star
54

flaskoo

Basic template for Flask Application connected to Odoo
Python
4
star
55

docker-mailcatcher

Lightweigh version of docker mailcatcher image only 132.6 MB
Shell
3
star
56

odoo-boleto-cnab

Brazilian Boleto and CNAB implementation for Odoo ERP using the brcobranca gem
Python
3
star
57

payment-gateway

Python
3
star
58

sale-import

HTML
3
star
59

voodoo-template

Templates for Voodoo
Python
3
star
60

smsclient

smsclient module from julius
Python
3
star
61

odoo2dev

Make your production odoo db copy dev ready
Python
3
star
62

logistics-center

Allow to exchange file datas between Odoo ERP and external warehouses
Python
3
star
63

partner-relation

Manage relations between partners in Odoo
Python
3
star
64

PyRemoteServer

Flask App for starting ssh tunneling between an inacessible server and a support team
Python
3
star
65

odoo-mail

Python
3
star
66

exodoo

Odoo json datastore for LocomotiveCMS
Ruby
3
star
67

docky-odoo-brasil

Exemplos Docky para OCA/l10n-brazil e uso do Odoo no Brasil
Python
3
star
68

magento-rma

PHP
3
star
69

odoo-factoring

Accounts Receivable Factoring for Odoo; incubation before targeting OCA inclusion
Python
3
star
70

custom-report

This are default custom report
Mako
3
star
71

storage-deprecated-moved-to-oca

Python
3
star
72

mdfelib

biblioteca para ler e gerir Manifesto Eletrônico de Documentos Fiscais brasileiros (MDF-e)
Python
3
star
73

subcontractor

Python
3
star
74

edoc-gen

generateDS helper script for Brazilian electronic documents Python libraries and Odoo ERP modules for NF-e, CC-e, NFS-e, MDF-e, CT-e, EFD-Reinf, e-Social, BP-e...
Shell
3
star
75

brazil-fiscal-client

base SOAP Client for the Brazilian fiscal authority
Python
3
star
76

business_intelligence_fields

Python
3
star
77

bank-statement-import-camt

Import CAMT .052 and .053 XML files in Odoo
Python
2
star
78

mrp_subcontracting-backport

backport of mrp_subcontracting* modules from Odoo CE 13.0 to Odoo 12.0
Python
2
star
79

odoo-vat-prorata

Add support for VAT Pro Rata in Odoo
Python
2
star
80

pos-sale-order

Alternative pos implementation that use sale order
Python
2
star
81

carrier-delivery-colipostefr

ColiPoste : Colissimo / So Colissimo for Odoo ERP
Python
2
star
82

ocb-account-payment

Python
2
star
83

mondialrelay_pyt

Python library for MondialRelay (French carrier)
Python
2
star
84

openerp-web

git mirror of https://code.launchpad.net/openerp-web
JavaScript
2
star
85

ebaypyt

Python Ebay API
Python
2
star
86

procurement-suggest

Python
2
star
87

account-move-base-import

Python
2
star
88

ocb-fiscal-rules

Python
2
star
89

docky-odoo-template

This a project template to use with docky
Jinja
2
star
90

yousign-connector

Odoo-Yousign connector
Python
2
star
91

geonames-import-simple

Module base_address_city_geonames_import. No dependency on base_location.
HTML
2
star
92

docker-odoo-project-prebuild

Prebuilt image for Odoo
Dockerfile
1
star
93

chefdk

Shell
1
star
94

siscomexlib

Biblioteca Python para integração da API do Siscomex
1
star
95

manufacturing

Python
1
star
96

connector-import-data

Python
1
star
97

python-cfonb

Python librairy for reading/writing document enforcing the CFONB norm
Python
1
star
98

odoocker

native and base Python dependencies for Odoo on Docker. Based on Trusty. No Odoo src, no Postgresql, no server CMD
Dockerfile
1
star
99

migrate-to-shopinvader

My name is Noe and I will save all of you !
Python
1
star
100

odoo-module-stats

Python
1
star