Skip to main content

No project description provided

Project description

eFacturePy — ads-facturx

Génération, validation et assemblage de factures électroniques Factur-X / EN 16931 en Python.

Python Version Build Status


🧭 Sommaire


📖 À propos

eFacturePy est le dépôt de travail du package Python ads-facturx, un outil qui permet de :

  • produire un XML Cross Industry Invoice conforme au profil urn:cen.eu:en16931:2017 ;
  • générer le PDF/A-3 associé à l’aide de ReportLab ;
  • embarquer ce XML dans le PDF pour obtenir une Factur-X valide (via factur-x) ;
  • valider la facture via XSD (EN16931) et Schematron (moteur SaxonC-HE).

✨ Fonctionnalités

  • ✅ Génération d’un XML Factur-X / EN 16931 à partir d’un dict métier
  • ✅ Génération d’un PDF de facture (template par défaut + logo personnalisable)
  • ✅ Fusion PDF + XML → fichier Factur-X conforme
  • ✅ Validation XSD (profil en16931)
  • ✅ Validation Schematron via XSLT précompilé (SaxonC)
  • ✅ Modèles Pydantic v2 pour typer et valider les données métier

🏗️ Architecture du dépôt

eFacturePy/
├─ ads_facturx/              # Package distribué sur PyPI
│  ├─ Builders/              # Génération XML + PDF + Factur-X
│  ├─ Validators/            # XSD + Schematron (XSLT EN16931-CII)
│  ├─ models/                # Schémas Pydantic (DevisData, Invoice, …)
│  ├─ Samples/               # Jeu de données et XML de référence
│  └─ tests/                 # Tests unitaires pytest
├─ eFacturePy/               # Sorties d’exemple (PDF/XML générés)
├─ archive/                  # Ressources brutes : XSD, XSL, Schematron, Saxon
├─ dist/                     # Wheels et sdist historiques                   
├─ pyproject.toml            # Configuration Poetry
└─ poetry.lock

📦 Installation

Depuis PyPI :

pip install ads-facturx

Prérequis : Python ≥ 3.12. SaxonC-HE est installé automatiquement via la dépendance saxonche.


🚀 Démarrage rapide

from ads_facturx import (
    generate_xml, write_xml_from_string,
    xml_check_xsd, xml_check_schematron,
    generate_invoice, generate_facturx,
)
from ads_facturx.Samples.data import sample_raw_data as data

DESTINATION = "eFacturePy"

xml_string = generate_xml(data)
xml_path   = write_xml_from_string(xml_string, DESTINATION, "my_first_xml")

xml_check_xsd(xml_string)
report = xml_check_schematron(xml_path=xml_path)
print(report)

generate_invoice(file_name="my_first_invoice.pdf",
                 destination_folder=DESTINATION,
                 data=data, title="Ma facture",
                 logopath="TA_logo_reduced.jpg")

generate_facturx(file_name="my_first_invoice.pdf",
                 destination_folder=DESTINATION,
                 xml=xml_string)

🔌 API publique

Exposée via from ads_facturx import ... :

Fonction Rôle
generate_xml(data) Construit la chaîne XML CII EN 16931 à partir d’un dict.
write_xml_from_string Sérialise l’XML sur disque (destination_folder, file_name).
xml_check_xsd Valide l’XML avec le XSD facturx / niveau en16931.
xml_check_schematron Applique les règles Schematron EN16931-CII via SaxonC.
generate_invoice Génère le PDF de facture (ReportLab, logo + annexes optionnels).
generate_facturx Embarque le XML dans le PDF pour produire la Factur-X finale.

🧾 Modèle de données

Le package fournit des schémas Pydantic v2 dans ads_facturx/models (notamment DevisData, Invoice, InvoiceLine, Company, Partner, …). generate_invoice valide les données via DevisData.model_validate(data) et applique des règles EN 16931 critiques (ex. obligation du numéro de TVA vendeur pour la catégorie S).

Un exemple complet de payload est fourni dans ads_facturx/Samples/data.py.


✅ Validation EN 16931

  • XSD : xml_check_xsd s’appuie sur factur-x (flavor="facturx", level="en16931").
  • Schematron : xml_check_schematron exécute Validators/xslt/EN16931-CII-validation.xslt avec SaxonC et renvoie la liste des failed-assert (id, location, message).

📚 Dépendances

factur-x, saxonche, pydantic, reportlab (voir pyproject.toml et poetry.lock).

👤 Auteur

Antoine DucoulombierAlchimie Data Solutions · antoine.ducoulombier@alchimiedatasolutions.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ads_facturx-0.5.1.tar.gz (165.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ads_facturx-0.5.1-py3-none-any.whl (176.7 kB view details)

Uploaded Python 3

File details

Details for the file ads_facturx-0.5.1.tar.gz.

File metadata

  • Download URL: ads_facturx-0.5.1.tar.gz
  • Upload date:
  • Size: 165.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.12.7 Windows/11

File hashes

Hashes for ads_facturx-0.5.1.tar.gz
Algorithm Hash digest
SHA256 dadec3ac39042dee0e7c5c08daa08307995e1d937a0cdff624a3b3597d8ab893
MD5 1ccac1d2b7fb123214a1c5f4302db648
BLAKE2b-256 fc688125a0d1a5d6118d54ead3aa2163673af719376c16cf8f30092f9ce584e1

See more details on using hashes here.

File details

Details for the file ads_facturx-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: ads_facturx-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 176.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.12.7 Windows/11

File hashes

Hashes for ads_facturx-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 47ab8cad3747fa68ffca61fcd7476fb53faaffa21c2c6e4bffee59f6d8f7d91d
MD5 7200e75ec6abc60580fa785e5064ebe6
BLAKE2b-256 bb8c0a2f38c3fb62b824a5af7e781078a1a9923a225b58f452cfa8535800b9e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page