Skip to main content

Python bindings for the fatoora ZATCA SDK

Project description

fatoora Python bindings

This package wraps the fatoora-ffi shared library via cffi.

Development (uv)

uv venv
uv pip install -e .

Build a wheel (uv)

uv build --wheel

Wheels (CI)

  • GitHub Actions uses cibuildwheel to produce platform wheels in dist/ (wheel-only publishing).
  • See .github/workflows/python-wheels.yml for the build matrix.

Notes

  • The build step compiles fatoora-ffi with cargo build -p fatoora-ffi --release.
  • The shared library is bundled into the Python package.
  • For local dev without install, set FATOORA_FFI_PATH or build and use the repo target/ output.
  • If a fatoora_ffi.h header is present (from FATOORA_CBINDGEN=1 cargo build -p fatoora-ffi), the Python wrapper will load its declarations automatically. You can override the header with FATOORA_FFI_HEADER=/path/to/fatoora_ffi.h.

Examples

python examples/load_lib.py
python examples/invoice_basic.py
python examples/invoice_parse.py

Tests

uv pip install -e .[dev]
uv run pytest tests

High-level API

from datetime import datetime, timezone
from fatoora import InvoiceBuilder, InvoiceSubType, InvoiceTypeKind, VatCategory

builder = InvoiceBuilder.new(
    invoice_type=InvoiceTypeKind.TAX,
    invoice_subtype=InvoiceSubType.SIMPLIFIED,
    invoice_id="INV-1",
    uuid="123e4567-e89b-12d3-a456-426614174000",
    issue_datetime=datetime.now(timezone.utc),
    currency_code="SAR",
    previous_invoice_hash="hash",
    invoice_counter=1,
    payment_means_code="10",
    vat_category=VatCategory.STANDARD,
    seller_name="Acme Inc",
    seller_country_code="SAU",
    seller_city="Riyadh",
    seller_street="King Fahd",
    seller_building_number="1234",
    seller_postal_code="12222",
    seller_vat_id="399999999900003",
)
builder.add_line_item(
    description="Item",
    quantity=1.0,
    unit_code="PCE",
    unit_price=100.0,
    vat_rate=15.0,
    vat_category=VatCategory.STANDARD,
)
invoice = builder.build()
print(invoice.xml())

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

fatoora_rs-0.1.0-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file fatoora_rs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fatoora_rs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Void","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fatoora_rs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24bae4d10558876af32869075d2bd387f24d7b3a42e3e4f4d92578a82143760e
MD5 27741766a1e0d0f2cb2815ce8636526d
BLAKE2b-256 f531a59e5d3767b58a2fb97d67f97d55e7a69c1ecca2f98f49661d7bf9064ce7

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