Skip to main content

Custom Python UBL 2.1 library with PEPPOL BIS Billing 3.0 support

Project description

python_ubl

A pure Python library for generating and parsing UBL 2.1 XML documents with full PEPPOL BIS Billing 3.0 compliance.

Status: Alpha (v0.1.0)

This library is in early development. The API is not yet stable and may change in future releases.

Features

  • Pure Python: No Django dependency required (optional Django integration available)
  • UBL 2.1 Support: Generate and parse invoices and credit notes
  • PEPPOL Compliance: Full support for PEPPOL BIS Billing 3.0
  • Dataclass-based: Type-safe, immutable-by-convention data structures
  • Bidirectional: Generate UBL XML from Python objects, parse UBL XML into Python objects
  • Automatic Identifier Generation: Auto-generate PEPPOL participant identifiers from VAT/registration numbers
  • 100 PEPPOL Schemes: Supports all PEPPOL v9.4 participant identifier schemes

Installation

pip install python_ubl

Quick Start

from ubl.models import Invoice, Party, InvoiceLine, Amount, Quantity, PostalAddress
from datetime import date

# Create a simple invoice
invoice = Invoice(
    id="INV-001",
    issue_date=date.today(),
    supplier=Party(
        name="My Company",
        vat="BE0123456789",
        country_code="BE",
        postal_address=PostalAddress(
            street_name="Main Street 1",
            city_name="Brussels",
            postal_zone="1000",
            country="BE"  # Smart casting: string -> Country object
        )
    ),
    customer=Party(...),
    lines=[
        InvoiceLine(
            id="1",
            invoiced_quantity=Quantity(value=10, unitCode="EA"),
            line_extension_amount=Amount(value=100.00),
            item=Item(name="Product A"),
            price=Price(price_amount=Amount(value=10.00))
        )
    ]
)

# Export to XML
xml_bytes = invoice.to_xml()

# Parse from XML
invoice = Invoice.from_xml(xml_bytes)

Requirements

  • Python 3.11+
  • lxml >= 4.9.0
  • python-dateutil >= 2.8.0

Development Status

Currently implemented:

  • ✅ Basic components (Amount, Quantity, Identifier, Code)
  • ✅ Aggregate components (Party, Address, Tax, Payment)
  • ✅ PEPPOL identifier generation (100 schemes)
  • ✅ Document models (Invoice, CreditNote)
  • ✅ Bidirectional XML serialization
  • ✅ Official UBL 2.1 example validation

Coming soon:

  • 🚧 XSD schema validation
  • 🚧 Business rules validation
  • 🚧 Django integration module
  • 🚧 Comprehensive documentation
  • 🚧 Public repository and issue tracker

License

MIT License - see LICENSE file for details.

About

This library is developed by LevIT SC as part of their PEPPOL e-invoicing integration project.

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

python_ubl-0.1.2.tar.gz (64.3 kB view details)

Uploaded Source

Built Distribution

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

python_ubl-0.1.2-py3-none-any.whl (74.1 kB view details)

Uploaded Python 3

File details

Details for the file python_ubl-0.1.2.tar.gz.

File metadata

  • Download URL: python_ubl-0.1.2.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for python_ubl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d681006ca726ecd03299dd919173a26daa1304125b43b01e1b7e9b5b662cec77
MD5 5baee202f6b4e058b65c04aa70d7d0fd
BLAKE2b-256 e82f96853924def1a5479b0bcf840a4875e63e897552b526a5ab875e8770f60a

See more details on using hashes here.

File details

Details for the file python_ubl-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: python_ubl-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 74.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for python_ubl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 296366cdc4718c307813be67ec0c753c0f9bd163f7bce8dc45bd3b6d7506f2c4
MD5 8c4468d2d8571a3e99ecdf90b90d8b07
BLAKE2b-256 4980f158bb67bdabf4bdd462241c4572d2d50bf4b0c93824fd48ab60cbbf2e45

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