Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9a270e186 | ||
|
|
5f2cc72a4f | ||
|
|
630dd696da | ||
|
|
34490db0ad | ||
|
|
fa9eaa4f82 | ||
|
|
4ff994a299 | ||
|
|
7aa4506dd7 | ||
|
|
6126a19bb7 | ||
|
|
fead1534c7 | ||
|
|
b2274894b5 | ||
|
|
ccf8ad67fa | ||
|
|
0cf359d201 | ||
|
|
7fcb3ff21d | ||
|
|
e2e1d8c046 | ||
|
|
d497a4cb5b | ||
|
|
18a902bcc9 | ||
|
|
e47e36d55c | ||
|
|
d0f4f0ff2e | ||
|
|
aeaa171bbf | ||
|
|
d585390289 | ||
|
|
3eddd66003 | ||
|
|
1a01b46ed6 | ||
|
|
867b47efd0 | ||
|
|
4791c91f06 | ||
|
|
c1f603cd46 | ||
|
|
29bd8453ec | ||
|
|
0db2482bf2 | ||
|
|
48ad42aa19 |
@@ -0,0 +1,73 @@
|
|||||||
|
# Dolt database (managed by Dolt, not git)
|
||||||
|
dolt/
|
||||||
|
embeddeddolt/
|
||||||
|
|
||||||
|
# Runtime files
|
||||||
|
bd.sock
|
||||||
|
bd.sock.startlock
|
||||||
|
sync-state.json
|
||||||
|
last-touched
|
||||||
|
.exclusive-lock
|
||||||
|
|
||||||
|
# Daemon runtime (lock, log, pid)
|
||||||
|
daemon.*
|
||||||
|
|
||||||
|
# Interactions log (runtime, not versioned)
|
||||||
|
interactions.jsonl
|
||||||
|
|
||||||
|
# Push state (runtime, per-machine)
|
||||||
|
push-state.json
|
||||||
|
|
||||||
|
# Lock files (various runtime locks)
|
||||||
|
*.lock
|
||||||
|
|
||||||
|
# Credential key (encryption key for federation peer auth — never commit)
|
||||||
|
.beads-credential-key
|
||||||
|
|
||||||
|
# Local version tracking (prevents upgrade notification spam after git ops)
|
||||||
|
.local_version
|
||||||
|
|
||||||
|
# Worktree redirect file (contains relative path to main repo's .beads/)
|
||||||
|
# Must not be committed as paths would be wrong in other clones
|
||||||
|
redirect
|
||||||
|
|
||||||
|
# Sync state (local-only, per-machine)
|
||||||
|
# These files are machine-specific and should not be shared across clones
|
||||||
|
.sync.lock
|
||||||
|
export-state/
|
||||||
|
export-state.json
|
||||||
|
|
||||||
|
# Ephemeral store (SQLite - wisps/molecules, intentionally not versioned)
|
||||||
|
ephemeral.sqlite3
|
||||||
|
ephemeral.sqlite3-journal
|
||||||
|
ephemeral.sqlite3-wal
|
||||||
|
ephemeral.sqlite3-shm
|
||||||
|
|
||||||
|
# Dolt server management (auto-started by bd)
|
||||||
|
dolt-server.pid
|
||||||
|
dolt-server.log
|
||||||
|
dolt-server.lock
|
||||||
|
dolt-server.port
|
||||||
|
dolt-server.activity
|
||||||
|
|
||||||
|
# Corrupt backup directories (created by bd doctor --fix recovery)
|
||||||
|
*.corrupt.backup/
|
||||||
|
|
||||||
|
# Backup data (auto-exported JSONL, local-only)
|
||||||
|
backup/
|
||||||
|
|
||||||
|
# Per-project environment file (Dolt connection config, GH#2520)
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Legacy files (from pre-Dolt versions)
|
||||||
|
*.db
|
||||||
|
*.db?*
|
||||||
|
*.db-journal
|
||||||
|
*.db-wal
|
||||||
|
*.db-shm
|
||||||
|
db.sqlite
|
||||||
|
bd.db
|
||||||
|
# NOTE: Do NOT add negation patterns here.
|
||||||
|
# They would override fork protection in .git/info/exclude.
|
||||||
|
# Config files (metadata.json, config.yaml) are tracked by git by default
|
||||||
|
# since no pattern above ignores them.
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# Beads - AI-Native Issue Tracking
|
||||||
|
|
||||||
|
Welcome to Beads! This repository uses **Beads** for issue tracking - a modern, AI-native tool designed to live directly in your codebase alongside your code.
|
||||||
|
|
||||||
|
## What is Beads?
|
||||||
|
|
||||||
|
Beads is issue tracking that lives in your repo, making it perfect for AI coding agents and developers who want their issues close to their code. No web UI required - everything works through the CLI and integrates seamlessly with git.
|
||||||
|
|
||||||
|
**Learn more:** [github.com/steveyegge/beads](https://github.com/steveyegge/beads)
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Essential Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create new issues
|
||||||
|
bd create "Add user authentication"
|
||||||
|
|
||||||
|
# View all issues
|
||||||
|
bd list
|
||||||
|
|
||||||
|
# View issue details
|
||||||
|
bd show <issue-id>
|
||||||
|
|
||||||
|
# Update issue status
|
||||||
|
bd update <issue-id> --claim
|
||||||
|
bd update <issue-id> --status done
|
||||||
|
|
||||||
|
# Sync with Dolt remote
|
||||||
|
bd dolt push
|
||||||
|
```
|
||||||
|
|
||||||
|
### Working with Issues
|
||||||
|
|
||||||
|
Issues in Beads are:
|
||||||
|
- **Git-native**: Stored in Dolt database with version control and branching
|
||||||
|
- **AI-friendly**: CLI-first design works perfectly with AI coding agents
|
||||||
|
- **Branch-aware**: Issues can follow your branch workflow
|
||||||
|
- **Always in sync**: Auto-syncs with your commits
|
||||||
|
|
||||||
|
## Why Beads?
|
||||||
|
|
||||||
|
✨ **AI-Native Design**
|
||||||
|
- Built specifically for AI-assisted development workflows
|
||||||
|
- CLI-first interface works seamlessly with AI coding agents
|
||||||
|
- No context switching to web UIs
|
||||||
|
|
||||||
|
🚀 **Developer Focused**
|
||||||
|
- Issues live in your repo, right next to your code
|
||||||
|
- Works offline, syncs when you push
|
||||||
|
- Fast, lightweight, and stays out of your way
|
||||||
|
|
||||||
|
🔧 **Git Integration**
|
||||||
|
- Automatic sync with git commits
|
||||||
|
- Branch-aware issue tracking
|
||||||
|
- Dolt-native three-way merge resolution
|
||||||
|
|
||||||
|
## Get Started with Beads
|
||||||
|
|
||||||
|
Try Beads in your own projects:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install Beads
|
||||||
|
curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
|
||||||
|
|
||||||
|
# Initialize in your repo
|
||||||
|
bd init
|
||||||
|
|
||||||
|
# Create your first issue
|
||||||
|
bd create "Try out Beads"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
- **Documentation**: [github.com/steveyegge/beads/docs](https://github.com/steveyegge/beads/tree/main/docs)
|
||||||
|
- **Quick Start Guide**: Run `bd quickstart`
|
||||||
|
- **Examples**: [github.com/steveyegge/beads/examples](https://github.com/steveyegge/beads/tree/main/examples)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Beads: Issue tracking that moves at the speed of thought* ⚡
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# Beads Configuration File
|
||||||
|
# This file configures default behavior for all bd commands in this repository
|
||||||
|
# All settings can also be set via environment variables (BD_* prefix)
|
||||||
|
# or overridden with command-line flags
|
||||||
|
|
||||||
|
# Issue prefix for this repository (used by bd init)
|
||||||
|
# If not set, bd init will auto-detect from directory name
|
||||||
|
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
|
||||||
|
# issue-prefix: ""
|
||||||
|
|
||||||
|
# Use no-db mode: JSONL-only, no Dolt database
|
||||||
|
# When true, bd will use .beads/issues.jsonl as the source of truth
|
||||||
|
# no-db: false
|
||||||
|
|
||||||
|
# Enable JSON output by default
|
||||||
|
# json: false
|
||||||
|
|
||||||
|
# Feedback title formatting for mutating commands (create/update/close/dep/edit)
|
||||||
|
# 0 = hide titles, N > 0 = truncate to N characters
|
||||||
|
# output:
|
||||||
|
# title-length: 255
|
||||||
|
|
||||||
|
# Default actor for audit trails (overridden by BEADS_ACTOR or --actor)
|
||||||
|
# actor: ""
|
||||||
|
|
||||||
|
# Export events (audit trail) to .beads/events.jsonl on each flush/sync
|
||||||
|
# When enabled, new events are appended incrementally using a high-water mark.
|
||||||
|
# Use 'bd export --events' to trigger manually regardless of this setting.
|
||||||
|
# events-export: false
|
||||||
|
|
||||||
|
# Multi-repo configuration (experimental - bd-307)
|
||||||
|
# Allows hydrating from multiple repositories and routing writes to the correct database
|
||||||
|
# repos:
|
||||||
|
# primary: "." # Primary repo (where this database lives)
|
||||||
|
# additional: # Additional repos to hydrate from (read-only)
|
||||||
|
# - ~/beads-planning # Personal planning repo
|
||||||
|
# - ~/work-planning # Work planning repo
|
||||||
|
|
||||||
|
# JSONL backup (periodic export for off-machine recovery)
|
||||||
|
# Auto-enabled when a git remote exists. Override explicitly:
|
||||||
|
# backup:
|
||||||
|
# enabled: false # Disable auto-backup entirely
|
||||||
|
# interval: 15m # Minimum time between auto-exports
|
||||||
|
# git-push: false # Disable git push (export locally only)
|
||||||
|
# git-repo: "" # Separate git repo for backups (default: project repo)
|
||||||
|
|
||||||
|
# Integration settings (access with 'bd config get/set')
|
||||||
|
# These are stored in the database, not in this file:
|
||||||
|
# - jira.url
|
||||||
|
# - jira.project
|
||||||
|
# - linear.url
|
||||||
|
# - linear.api-key
|
||||||
|
# - github.org
|
||||||
|
# - github.repo
|
||||||
|
|
||||||
|
sync:
|
||||||
|
remote: "git+https://git.az-gruppe.com/AZ-Intec-GmbH/zugferd-service.git"
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
# --- BEGIN BEADS INTEGRATION v1.0.3 ---
|
||||||
|
# This section is managed by beads. Do not remove these markers.
|
||||||
|
if command -v bd >/dev/null 2>&1; then
|
||||||
|
export BD_GIT_HOOK=1
|
||||||
|
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
timeout "$_bd_timeout" bd hooks run post-checkout "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
if [ $_bd_exit -eq 124 ]; then
|
||||||
|
echo >&2 "beads: hook 'post-checkout' timed out after ${_bd_timeout}s — continuing without beads"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
bd hooks run post-checkout "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -eq 3 ]; then
|
||||||
|
echo >&2 "beads: database not initialized — skipping hook 'post-checkout'"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||||
|
fi
|
||||||
|
# --- END BEADS INTEGRATION v1.0.3 ---
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
# --- BEGIN BEADS INTEGRATION v1.0.3 ---
|
||||||
|
# This section is managed by beads. Do not remove these markers.
|
||||||
|
if command -v bd >/dev/null 2>&1; then
|
||||||
|
export BD_GIT_HOOK=1
|
||||||
|
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
timeout "$_bd_timeout" bd hooks run post-merge "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
if [ $_bd_exit -eq 124 ]; then
|
||||||
|
echo >&2 "beads: hook 'post-merge' timed out after ${_bd_timeout}s — continuing without beads"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
bd hooks run post-merge "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -eq 3 ]; then
|
||||||
|
echo >&2 "beads: database not initialized — skipping hook 'post-merge'"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||||
|
fi
|
||||||
|
# --- END BEADS INTEGRATION v1.0.3 ---
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
# --- BEGIN BEADS INTEGRATION v1.0.3 ---
|
||||||
|
# This section is managed by beads. Do not remove these markers.
|
||||||
|
if command -v bd >/dev/null 2>&1; then
|
||||||
|
export BD_GIT_HOOK=1
|
||||||
|
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
timeout "$_bd_timeout" bd hooks run pre-commit "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
if [ $_bd_exit -eq 124 ]; then
|
||||||
|
echo >&2 "beads: hook 'pre-commit' timed out after ${_bd_timeout}s — continuing without beads"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
bd hooks run pre-commit "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -eq 3 ]; then
|
||||||
|
echo >&2 "beads: database not initialized — skipping hook 'pre-commit'"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||||
|
fi
|
||||||
|
# --- END BEADS INTEGRATION v1.0.3 ---
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
# --- BEGIN BEADS INTEGRATION v1.0.3 ---
|
||||||
|
# This section is managed by beads. Do not remove these markers.
|
||||||
|
if command -v bd >/dev/null 2>&1; then
|
||||||
|
export BD_GIT_HOOK=1
|
||||||
|
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
timeout "$_bd_timeout" bd hooks run pre-push "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
if [ $_bd_exit -eq 124 ]; then
|
||||||
|
echo >&2 "beads: hook 'pre-push' timed out after ${_bd_timeout}s — continuing without beads"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
bd hooks run pre-push "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -eq 3 ]; then
|
||||||
|
echo >&2 "beads: database not initialized — skipping hook 'pre-push'"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||||
|
fi
|
||||||
|
# --- END BEADS INTEGRATION v1.0.3 ---
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
# --- BEGIN BEADS INTEGRATION v1.0.3 ---
|
||||||
|
# This section is managed by beads. Do not remove these markers.
|
||||||
|
if command -v bd >/dev/null 2>&1; then
|
||||||
|
export BD_GIT_HOOK=1
|
||||||
|
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
timeout "$_bd_timeout" bd hooks run prepare-commit-msg "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
if [ $_bd_exit -eq 124 ]; then
|
||||||
|
echo >&2 "beads: hook 'prepare-commit-msg' timed out after ${_bd_timeout}s — continuing without beads"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
bd hooks run prepare-commit-msg "$@"
|
||||||
|
_bd_exit=$?
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -eq 3 ]; then
|
||||||
|
echo >&2 "beads: database not initialized — skipping hook 'prepare-commit-msg'"
|
||||||
|
_bd_exit=0
|
||||||
|
fi
|
||||||
|
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||||
|
fi
|
||||||
|
# --- END BEADS INTEGRATION v1.0.3 ---
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{"_type":"issue","id":"zugferd-048","title":"flake.nix: factur-x von 3.8 auf 6.8 anheben (Lockfile/CI nutzen 6.8)","description":"Die Nix-Dev-Shell und das Nix-Paket bauen factur-x 3.8, uv.lock und CI nutzen 6.8. Die Versionen verhalten sich unterschiedlich (z. B. Profil-Erkennung XRechnung CII). Flake auf 6.8 angleichen und Tests in der Nix-Shell laufen lassen.","status":"closed","priority":1,"issue_type":"task","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:57Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:22:58Z","closed_at":"2026-11-11T17:22:58Z","close_reason":"flake.nix baut factur-x 6.8 (wie uv.lock); Dev-Shell und nix build inkl. Tests gruen","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-sq7","title":"Neuer Check xsd: Schema-Pruefung des Roh-XML ueber factur-x (xml_check_xsd)","description":"Stufe 1 aus zugferd-d9d. factur-x 6.8 prueft CII (alle Profile) und UBL 2.1 gegen das XSD. /validate braucht dafuer das Roh-XML (z. B. neues Feld xml_raw im ValidateRequest) oder die Pruefung laeuft in /extract. Schema-Fehler als critical melden.","status":"open","priority":2,"issue_type":"feature","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:26:12Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:26:12Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-dpo","title":"Kaeuferreferenz / Leitweg-ID (BT-10) extrahieren und pruefen","description":"BT-10 ist bei XRechnung Pflicht, wird aber weder extrahiert noch validiert. Feld in XmlData aufnehmen (CII: BuyerReference, UBL: cbc:BuyerReference) und bei XRechnung-Profilen als Pflichtfeld pruefen.","status":"closed","priority":2,"issue_type":"feature","assignee":"m3ta-chiron","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:58Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:25:29Z","started_at":"2026-11-11T17:22:59Z","closed_at":"2026-11-11T17:25:29Z","close_reason":"Umgesetzt mit Tests, siehe Arbeitsbaum","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-obf","title":"CII: due_date aus SpecifiedTradePaymentTerms/DueDateDateTime lesen","description":"parse_zugferd_xml liest due_date aus ApplicableTradeDeliveryTerms/Description (Freitext der Lieferbedingungen) statt aus dem Faelligkeitsdatum BT-9. UBL liefert das echte Datum. Auf BT-9 umstellen und als YYYY-MM-DD normalisieren.","status":"closed","priority":2,"issue_type":"bug","assignee":"m3ta-chiron","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:58Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:25:28Z","started_at":"2026-11-11T17:22:58Z","closed_at":"2026-11-11T17:25:28Z","close_reason":"Umgesetzt mit Tests, siehe Arbeitsbaum","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-efj","title":"pdf_abgleich: echten Abgleich XML gegen PDF-Text implementieren","description":"validate_invoice erkennt nur die englischen Muster Invoice und Total:. Bei deutschen Rechnungen wird nichts verglichen und der Check besteht immer. src/pdf_parser.py (extract_from_text) existiert, wird aber nicht verwendet. Rechnungsnummer, Netto, USt und Brutto gegen den PDF-Text abgleichen.","status":"closed","priority":2,"issue_type":"bug","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:57Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:25:29Z","closed_at":"2026-11-11T17:25:29Z","close_reason":"Umgesetzt mit Tests, siehe Arbeitsbaum","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-158","title":"KoSIT-Validator als optionalen Sidecar anbinden (offizielle XRechnung-Konformitaet)","description":"Stufe 2 aus zugferd-d9d. KoSIT-Validator im Daemon-Modus mit validator-configuration-xrechnung als Container neben dem Service; neuer Check, der das Roh-XML per HTTP prueft, wenn eine Validator-URL konfiguriert ist. Deckt EN-16931- und BR-DE-Regeln ab. Vorab praktisch erproben (Report-Format, Laufzeit, Image-Groesse).","status":"open","priority":3,"issue_type":"feature","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:26:12Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:26:12Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-57v","title":"Lizenz klaeren: README nennt MIT, LICENSE-Datei fehlt","description":"README.md nennt MIT als Lizenz, im Repository gibt es keine LICENSE-Datei und pyproject.toml hat keinen license-Eintrag. Lizenz festlegen und Datei bzw. README angleichen.","status":"open","priority":3,"issue_type":"task","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:59Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:14:59Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
|
{"_type":"issue","id":"zugferd-d9d","title":"Offizielle Konformitaetspruefung (XSD + Schematron / KoSIT) evaluieren","description":"Die vier Checks sind Plausibilitaetspruefungen. Es gibt keine Pruefung gegen EN-16931-/XRechnung-Schemas und Schematron-Regeln (BR-DE-*). Optionen bewerten: KoSIT-Validator anbinden oder Schematron per lxml/saxon ausfuehren.","notes":"Ergebnis der Evaluation (2026-11-11):\n1) XSD: factur-x 6.8 bringt xml_check_xsd mit. Im Versuch bestehen alle 12 Fixtures (CII aller Profile, XRechnung CII, UBL 2.1). Keine neue Abhaengigkeit, prueft aber nur die Struktur, keine Geschaeftsregeln. Braucht das Roh-XML, /validate bekommt bisher nur xml_data.\n2) Schematron in factur-x: xml_check_schematron liefert EN-16931-Regeln fuer CII und UBL mit, braucht aber einen externen Saxon-Server (HTTP) und enthaelt keine deutschen BR-DE-Regeln (nur FR-CTC).\n3) lxml isoschematron scheidet aus: die Regeln brauchen XSLT 2.0.\n4) KoSIT-Validator (Java) mit validator-configuration-xrechnung: offizielle Pruefung inkl. BR-DE fuer CII und UBL; als Daemon per HTTP als Sidecar betreibbar. Nicht praktisch erprobt.\nEmpfehlung: Stufe 1 XSD-Check direkt im Service; Stufe 2 KoSIT-Validator als optionaler Sidecar (konfigurierbare URL) fuer die offizielle Konformitaet. Folge-Issues angelegt.","status":"closed","priority":3,"issue_type":"feature","assignee":"m3ta-chiron","owner":"m3ta-chiron@agentmail.to","created_at":"2026-11-11T17:14:59Z","created_by":"m3ta-chiron","updated_at":"2026-11-11T17:26:13Z","started_at":"2026-11-11T17:25:30Z","closed_at":"2026-11-11T17:26:13Z","close_reason":"Evaluation abgeschlossen, Empfehlung in den Notizen, Folge-Issues zugferd-sq7 und zugferd-158","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"database": "dolt",
|
||||||
|
"backend": "dolt",
|
||||||
|
"dolt_mode": "embedded",
|
||||||
|
"dolt_database": "zugferd",
|
||||||
|
"project_id": "3cfb9df3-e5cc-4209-8d7b-29a77aebdde9"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"PreCompact": [
|
||||||
|
{
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"command": "bd prime",
|
||||||
|
"type": "command"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"matcher": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"SessionStart": [
|
||||||
|
{
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"command": "bd prime",
|
||||||
|
"type": "command"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"matcher": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
*.egg-info/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
.venv
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
.pytest_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
*.md
|
||||||
|
docs/
|
||||||
|
|
||||||
|
# Nix
|
||||||
|
result/
|
||||||
|
.direnv/
|
||||||
|
.sisyphus/
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
docker-compose.yml
|
||||||
|
.dockerignore
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github/
|
||||||
|
.gitlab-ci.yml
|
||||||
|
Jenkinsfile
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Activate the devshell from the Nix flake
|
||||||
|
# This loads all tools and environment variables defined in flake.nix
|
||||||
|
|
||||||
|
use flake
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, main]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v5
|
||||||
|
with:
|
||||||
|
enable-cache: true
|
||||||
|
|
||||||
|
- name: Install dependencies from lockfile
|
||||||
|
run: uv sync --extra dev --frozen
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: uv run --extra dev pytest -q
|
||||||
|
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: docker build -t zugferd-service:ci .
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env/
|
||||||
|
.direnv/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
.pytest_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
|
||||||
|
# Sisyphus internal
|
||||||
|
.sisyphus/boulder.json
|
||||||
|
.sisyphus/notepads/*/issues.md
|
||||||
|
.sisyphus/notepads/*/problems.md
|
||||||
|
|
||||||
|
# Opencode rules
|
||||||
|
.opencode-rules/
|
||||||
|
opencode.json
|
||||||
|
.todos/
|
||||||
|
|
||||||
|
# Sidecar worktree state files
|
||||||
|
.sidecar/
|
||||||
|
.sidecar-agent
|
||||||
|
.sidecar-task
|
||||||
|
.sidecar-pr
|
||||||
|
.sidecar-start.sh
|
||||||
|
.sidecar-base
|
||||||
|
.td-root
|
||||||
|
|
||||||
|
# pi
|
||||||
|
.pi*
|
||||||
|
|
||||||
|
# Beads / Dolt files (added by bd init)
|
||||||
|
.dolt/
|
||||||
|
*.db
|
||||||
|
.beads-credential-key
|
||||||
|
|
||||||
|
# Beads runtime lock
|
||||||
|
.beads.gate.lock
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
/nix/store/5f1zpyn23pabv4j30g651cy2bfkpi7f6-source/rules
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3.11
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"active_plan": "/home/m3tam3re/p/AZ/zugferd-service/.sisyphus/plans/zugferd-service.md",
|
||||||
|
"started_at": "2026-02-04T18:12:44.865Z",
|
||||||
|
"session_ids": [
|
||||||
|
"ses_3d634d45bffeW59tJMBkcCfwyd"
|
||||||
|
],
|
||||||
|
"plan_name": "zugferd-service"
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Draft: ZUGFeRD-Service Implementation
|
||||||
|
|
||||||
|
## Requirements (confirmed)
|
||||||
|
|
||||||
|
### Core Functionality
|
||||||
|
- **Purpose**: Python REST API for ZUGFeRD/Factur-X invoice extraction and validation
|
||||||
|
- **Framework**: FastAPI (preferred by user)
|
||||||
|
- **Runtime**: Python 3.11+
|
||||||
|
- **Deployment**: Docker container on NixOS server + native Nix package
|
||||||
|
|
||||||
|
### API Endpoints
|
||||||
|
1. `GET /health` - Health check endpoint
|
||||||
|
2. `POST /extract` - PDF extraction (accepts base64-encoded PDF)
|
||||||
|
3. `POST /validate` - Invoice validation (pflichtfelder, betraege, ustid, pdf_abgleich)
|
||||||
|
|
||||||
|
### Key Dependencies
|
||||||
|
- `factur-x>=2.5` - ZUGFeRD/Factur-X extraction
|
||||||
|
- `pypdf>=4.0.0` - PDF text extraction
|
||||||
|
- `fastapi>=0.109.0` - API framework
|
||||||
|
- `uvicorn>=0.27.0` - ASGI server
|
||||||
|
- `pydantic>=2.5.0` - Data models
|
||||||
|
- `lxml>=5.0.0` - XML parsing
|
||||||
|
- `python-multipart>=0.0.6` - File uploads
|
||||||
|
|
||||||
|
### Project Structure (user-specified)
|
||||||
|
```
|
||||||
|
zugferd-service/
|
||||||
|
├── Dockerfile
|
||||||
|
├── requirements.txt
|
||||||
|
├── README.md
|
||||||
|
├── src/
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── main.py # FastAPI App + Endpoints
|
||||||
|
│ ├── extractor.py # ZUGFeRD/PDF Extraktion
|
||||||
|
│ ├── validator.py # Validierungslogik
|
||||||
|
│ ├── pdf_parser.py # PDF-Text-Parsing für Abgleich
|
||||||
|
│ ├── models.py # Pydantic Models
|
||||||
|
│ └── utils.py # Hilfsfunktionen
|
||||||
|
├── tests/
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── test_extractor.py
|
||||||
|
│ ├── test_validator.py
|
||||||
|
│ └── fixtures/
|
||||||
|
│ ├── sample_zugferd.pdf
|
||||||
|
│ └── sample_no_zugferd.pdf
|
||||||
|
└── docker-compose.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Research Findings
|
||||||
|
|
||||||
|
### Nix Packaging (from librarian research)
|
||||||
|
- Use `buildPythonApplication` for standalone service
|
||||||
|
- `pyproject = true` with hatchling/setuptools
|
||||||
|
- `pythonRelaxDeps = true` for dependency flexibility
|
||||||
|
- mem0 example pattern: custom server script via `postInstall`
|
||||||
|
- Consider flake.nix for modern Nix workflow
|
||||||
|
|
||||||
|
### factur-x Library (from librarian research)
|
||||||
|
- `get_xml_from_pdf()` - Core extraction function
|
||||||
|
- `get_level()` / `get_flavor()` - Profile detection
|
||||||
|
- Namespaces: rsm, ram, udt for UN/CEFACT CII format
|
||||||
|
- Profile levels: minimum, basicwl, basic, en16931, extended
|
||||||
|
|
||||||
|
### UN/ECE Unit Codes
|
||||||
|
- C62 = Piece, KGM = Kilogram, H87 = Piece (alt)
|
||||||
|
- Need comprehensive mapping dictionary
|
||||||
|
|
||||||
|
## Technical Decisions
|
||||||
|
|
||||||
|
### Python Tooling
|
||||||
|
- **PENDING**: Use pyproject.toml (modern) or requirements.txt (legacy)?
|
||||||
|
- **PENDING**: Build system: setuptools, hatchling, or poetry-core?
|
||||||
|
|
||||||
|
### Nix Approach
|
||||||
|
- **PENDING**: Flake-based or traditional Nix expressions?
|
||||||
|
- **PENDING**: Include NixOS service module?
|
||||||
|
|
||||||
|
### Testing Strategy
|
||||||
|
- **PENDING**: TDD or tests-after?
|
||||||
|
- **PENDING**: Test framework: pytest (standard choice)
|
||||||
|
|
||||||
|
## Scope Boundaries
|
||||||
|
|
||||||
|
### INCLUDE
|
||||||
|
- All 3 API endpoints as specified
|
||||||
|
- All validation checks (pflichtfelder, betraege, ustid, pdf_abgleich)
|
||||||
|
- Docker multi-stage build
|
||||||
|
- Nix packaging
|
||||||
|
- Basic test suite
|
||||||
|
- README documentation
|
||||||
|
|
||||||
|
### EXCLUDE
|
||||||
|
- Online USt-ID validation (only format check)
|
||||||
|
- Database/persistence (stateless service)
|
||||||
|
- Authentication/authorization
|
||||||
|
- Rate limiting
|
||||||
|
- Metrics/tracing
|
||||||
|
|
||||||
|
## Open Questions (RESOLVED)
|
||||||
|
|
||||||
|
1. ✅ **Python project structure**: pyproject.toml with hatchling
|
||||||
|
2. ✅ **Build system**: hatchling (modern, Nix-friendly)
|
||||||
|
3. ✅ **Nix approach**: Flake-based
|
||||||
|
4. ✅ **Testing**: TDD (test-first) with pytest
|
||||||
|
5. ✅ **Sample PDFs**: Source from official ZUGFeRD repositories
|
||||||
|
|
||||||
|
## Metis Gap Analysis (Reviewed)
|
||||||
|
|
||||||
|
### Gaps Classified as MINOR (Auto-Resolved)
|
||||||
|
- **UN/ECE unit codes**: Start with common codes (C62, KGM, H87, MTR, LTR, etc.), expand as needed
|
||||||
|
- **Tolerance**: Hardcode 0.01 EUR as specified
|
||||||
|
- **Validation scope**: Check required fields exist for declared profile
|
||||||
|
- **Error codes**: Implement as specified in user's detailed spec
|
||||||
|
|
||||||
|
### Gaps Classified as DEFAULTS APPLIED
|
||||||
|
- **Authentication**: OPEN (no auth mentioned in spec → stateless public API)
|
||||||
|
- **ZUGFeRD profiles**: ALL profiles supported (MINIMUM, BASIC, BASIC WL, EN16931, EXTENDED)
|
||||||
|
- **Deployment**: Container-based on NixOS (as per NixOS config section in spec)
|
||||||
|
- **PDF text extraction**: REQUIRED for pdf_abgleich check (explicitly in spec)
|
||||||
|
- **File size limit**: Handle as error for >10MB (spec mentions this edge case)
|
||||||
|
|
||||||
|
### Guardrails (Must NOT Have)
|
||||||
|
- NO authentication middleware
|
||||||
|
- NO database/persistence
|
||||||
|
- NO caching layers
|
||||||
|
- NO rate limiting
|
||||||
|
- NO metrics endpoints (beyond /health)
|
||||||
|
- NO CLI interface
|
||||||
|
- NO web UI
|
||||||
|
- NO abstraction layers for "future extensibility"
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Decisions - zugferd-service
|
||||||
|
|
||||||
|
This file accumulates architectural and design decisions during execution.
|
||||||
|
|
||||||
|
## [2026-02-04T18:12:44.864Z] Session Start
|
||||||
|
Planning decisions from Prometheus session.
|
||||||
|
|
||||||
|
## Tech Stack
|
||||||
|
- Python 3.11+
|
||||||
|
- FastAPI for REST API
|
||||||
|
- Pydantic for data validation
|
||||||
|
- pytest for testing
|
||||||
|
- factur-x library for ZUGFeRD extraction
|
||||||
|
- pypdf for PDF text extraction
|
||||||
|
|
||||||
|
## Scope Lock
|
||||||
|
- NO authentication (stateless service)
|
||||||
|
- NO database
|
||||||
|
- NO caching
|
||||||
|
- NO rate limiting
|
||||||
|
- 10MB file size limit
|
||||||
|
- 0.01 EUR tolerance for calculations
|
||||||
|
|
||||||
|
## Validation Rules
|
||||||
|
- pflichtfelder: Required fields check
|
||||||
|
- betraege: Amount calculations check
|
||||||
|
- ustid: VAT ID format check (no online validation)
|
||||||
|
- pdf_abgleich: XML vs PDF text comparison
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Issues - zugferd-service
|
||||||
|
|
||||||
|
This file accumulates problems, errors, and gotchas during execution.
|
||||||
|
|
||||||
|
## [2026-02-04T18:12:44.864Z] Session Start
|
||||||
|
Initial session started. No issues yet.
|
||||||
|
|
||||||
@@ -0,0 +1,812 @@
|
|||||||
|
# Learnings - zugferd-service
|
||||||
|
|
||||||
|
This file accumulates conventions, patterns, and learnings during execution.
|
||||||
|
|
||||||
|
## [2026-02-04T18:12:44.864Z] Session Start
|
||||||
|
Initial session for ZUGFeRD-Service implementation.
|
||||||
|
|
||||||
|
## Framework Decisions
|
||||||
|
- FastAPI (user preference)
|
||||||
|
- Pydantic v2+ for data models
|
||||||
|
- pytest with pytest-asyncio for testing
|
||||||
|
- hatchling for build system
|
||||||
|
|
||||||
|
## Packaging Decisions
|
||||||
|
- pyproject.toml (modern Python packaging)
|
||||||
|
- Docker multi-stage build
|
||||||
|
- Nix flake-based packaging with buildPythonApplication
|
||||||
|
|
||||||
|
## Testing Decisions
|
||||||
|
- TDD (test-first) approach
|
||||||
|
- All acceptance criteria must be verifiable without human intervention
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T19:14:00.000Z] Task 1: Project Scaffold
|
||||||
|
|
||||||
|
### hatchling Configuration Pattern
|
||||||
|
- For src-layout projects, MUST add `[tool.hatch.build.targets.wheel]` section
|
||||||
|
- Without this, hatchling cannot determine which files to ship
|
||||||
|
- Config: `packages = ["src"]` to specify src directory
|
||||||
|
|
||||||
|
### Nix Environment Considerations
|
||||||
|
- Nix store is read-only, standard pip install fails
|
||||||
|
- Use temporary venv for verification: `python -m venv /tmp/test_env`
|
||||||
|
- Install to venv, verify imports, then cleanup
|
||||||
|
|
||||||
|
### Entry Point Documentation
|
||||||
|
- Functions referenced in `[project.scripts]` MUST have docstrings
|
||||||
|
- These are public API entry points (CLI commands)
|
||||||
|
- Example: `zugferd-service = "src.main:run"` -> run() needs docstring
|
||||||
|
|
||||||
|
### Module Docstring Convention
|
||||||
|
- Module-level docstrings: minimal, one line, describe purpose
|
||||||
|
- Entry point function docstrings: Args/Returns style for CLI documentation
|
||||||
|
- Both necessary for scaffolding clarity
|
||||||
|
|
||||||
|
## [2026-02-04T19:23:00.000Z] Task 2: Download ZUGFeRD Sample PDFs
|
||||||
|
|
||||||
|
### Sample PDF Sources
|
||||||
|
- **Best source**: Mustang project (https://github.com/ZUGFeRD/mustangproject)
|
||||||
|
- Contains 20+ authentic ZUGFeRD samples across multiple directories
|
||||||
|
- Library test resources: `library/src/test/resources/` (15 PDFs)
|
||||||
|
- Validator test resources: `validator/src/test/resources/` (14 PDFs)
|
||||||
|
- CLI test resources: `Mustang-CLI/src/test/resources/` (2 PDFs)
|
||||||
|
- **FeRD official site**: https://www.ferd-net.de/download/testrechnungen
|
||||||
|
- Returns 404 - URL may have moved
|
||||||
|
- Mustang project likely mirrors these samples
|
||||||
|
- **factur-x library tests**: https://github.com/akretion/factur-x/tree/master/tests
|
||||||
|
- No PDF files found in repository (only code tests)
|
||||||
|
|
||||||
|
### ZUGFeRD Profile Coverage
|
||||||
|
- **Available samples**: BASIC, BASIC WL, EN16931, EXTENDED, XRechnung
|
||||||
|
- **Missing**: MINIMUM profile (future addition needed)
|
||||||
|
- **Versions covered**: ZUGFeRD 1.0, 2.0, 2.1, XRechnung
|
||||||
|
- **Related formats**: ORDER-X (for orders, not invoices)
|
||||||
|
|
||||||
|
### Negative Testing
|
||||||
|
- `EmptyPDFA1.pdf`: Valid PDF/A-1 with no ZUGFeRD XML data
|
||||||
|
- Useful for testing error handling and graceful degradation
|
||||||
|
|
||||||
|
### PDF Verification Pattern
|
||||||
|
- When `file` command unavailable, verify PDF magic bytes
|
||||||
|
- Magic bytes: `25 50 44 46` (hex) = "%PDF" (ASCII)
|
||||||
|
- Command: `head -c 4 "$f" | od -A n -t x1`
|
||||||
|
- All valid PDFs start with these 4 bytes
|
||||||
|
|
||||||
|
### Sample Selection Strategy
|
||||||
|
- Prioritize coverage: multiple profiles, versions, edge cases
|
||||||
|
- Keep focused: 8-10 samples max (11 selected with good variety)
|
||||||
|
- Include historical samples for backward compatibility testing
|
||||||
|
- Document thoroughly: MANIFEST.md with profile, description, source
|
||||||
|
|
||||||
|
### File Naming Conventions
|
||||||
|
- Mustang uses descriptive names: `EN16931_1_Teilrechnung.pdf`
|
||||||
|
- Include profile and feature description in filename
|
||||||
|
- Date-based names for temporal versions: `MustangBeispiel20221026.pdf`
|
||||||
|
- Test prefixes: `ZTESTZUGFERD_1_...` for ZUGFeRD v1 test samples
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T19:45:00.000Z] Task 3: Pydantic Models
|
||||||
|
|
||||||
|
### Pydantic v2+ Syntax Patterns
|
||||||
|
- Use `type | None = None` for optional fields (not `Optional[type]`)
|
||||||
|
- Use `Field(description=...)` for field documentation (appears in OpenAPI docs)
|
||||||
|
- Use `Field(default_factory=list)` for list defaults to avoid mutable default issues
|
||||||
|
- Use `Field(default=None)` for None defaults on optional fields
|
||||||
|
- Model docstrings serve as public API documentation for FastAPI's OpenAPI schema
|
||||||
|
|
||||||
|
### JSON Serialization
|
||||||
|
- Use `model.model_dump_json()` to serialize to JSON string
|
||||||
|
- Use `model.model_validate_json(json_str)` to deserialize from JSON
|
||||||
|
- Pydantic handles datetime, nested models, and type conversion automatically
|
||||||
|
|
||||||
|
### Test-First Development Pattern
|
||||||
|
- Write tests before implementing models (RED-GREEN-REFACTOR)
|
||||||
|
- Tests should cover: minimal data, full data, edge cases
|
||||||
|
- Test JSON roundtrip: `model.model_dump_json()` → `Model.model_validate_json()`
|
||||||
|
- Verify imports: `python -c "from src.models import ModelName"`
|
||||||
|
|
||||||
|
### Nested Models with Dict Input
|
||||||
|
- Pydantic v2 accepts dict for nested models: `supplier={"name": "ACME"}`
|
||||||
|
- Use for test convenience and API requests
|
||||||
|
- Internally converts to proper model instances
|
||||||
|
|
||||||
|
### Field Required vs Optional
|
||||||
|
- Required fields: No default value in Field
|
||||||
|
- Optional fields: `type | None = Field(default=None, ...)`
|
||||||
|
- Empty list defaults: `list[Type] = Field(default_factory=list)`
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T20:30:00.000Z] Task 5: PDF Text Parser Implementation
|
||||||
|
|
||||||
|
### TDD Implementation Pattern
|
||||||
|
- Write failing tests first (RED), implement minimum code (GREEN), refactor if needed
|
||||||
|
- 27 tests written covering: PDF extraction, regex patterns, number/date formats, edge cases
|
||||||
|
- All tests pass after implementation
|
||||||
|
|
||||||
|
### pypdf Text Extraction
|
||||||
|
- `PdfReader` requires file-like object, not raw bytes
|
||||||
|
- Use `io.BytesIO(pdf_bytes)` to wrap bytes for pypdf
|
||||||
|
- Extract text page-by-page, concatenate with newlines
|
||||||
|
|
||||||
|
### Regex Pattern Design for Numbers
|
||||||
|
- Initial pattern `[0-9.,]+` matches lone dots (invalid number)
|
||||||
|
- Fixed pattern: `[0-9]+(?:[.,][0-9]+)*` requires at least one digit
|
||||||
|
- Ensures matched values are valid numbers before parsing
|
||||||
|
|
||||||
|
### German Number Format Detection
|
||||||
|
- German: `1.234,56` (dot=thousands, comma=decimal)
|
||||||
|
- International: `1,234.56` (comma=thousands, dot=decimal)
|
||||||
|
- Detection: Check if comma appears after last dot
|
||||||
|
```python
|
||||||
|
if "," in num_str and num_str.rfind(",") > num_str.rfind("."):
|
||||||
|
# German format
|
||||||
|
else:
|
||||||
|
# International format
|
||||||
|
```
|
||||||
|
|
||||||
|
### Confidence Scoring
|
||||||
|
- First pattern match = 1.0 confidence
|
||||||
|
- Each subsequent pattern reduces confidence by 0.1
|
||||||
|
- Range: 1.0 (first pattern) → 0.6 (fifth pattern)
|
||||||
|
|
||||||
|
### German Date Format Conversion
|
||||||
|
- Input: `04.02.2025` (DD.MM.YYYY)
|
||||||
|
- Output: `2025-02-04` (ISO format YYYY-MM-DD)
|
||||||
|
- Use `zfill(2)` to pad single digits: `4` → `04`
|
||||||
|
|
||||||
|
### Test Docstrings are Necessary
|
||||||
|
- Pytest uses method docstrings in test reports
|
||||||
|
- Essential for readable test output
|
||||||
|
- Module/class docstrings provide organization context
|
||||||
|
|
||||||
|
### Invoice Field Patterns (from spec)
|
||||||
|
- invoice_number: "Rechnungs-Nr", "Invoice No", "Beleg-Nr", "Rechnung X/Y"
|
||||||
|
- gross_amount: "Brutto", "Gesamtbetrag", "Total", "Endbetrag", "Summe"
|
||||||
|
- net_amount: "Netto", "Rechnungsbetrag"
|
||||||
|
- vat_amount: "MwSt", "USt", "Steuer"
|
||||||
|
- invoice_date: "Rechnungsdatum", "Datum", "Invoice Date"
|
||||||
|
- supplier_name: "Lieferant", "Verkäufer"
|
||||||
|
|
||||||
|
### PDF Layout Variations
|
||||||
|
- Real PDFs may have different field layouts than spec patterns
|
||||||
|
- EN16931 sample uses "Bruttosumme" instead of "Brutto"
|
||||||
|
- Patterns can be refined iteratively based on real data
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T20:45:00.000Z] Task 6: Utility Functions Implementation
|
||||||
|
|
||||||
|
### UNECE Unit Code Mapping
|
||||||
|
- UN/ECE unit codes standardized for cross-border trade documents
|
||||||
|
- 17 common codes mapped to German translations:
|
||||||
|
- "C62", "H87", "PCE", "EA" → "Stück"
|
||||||
|
- "KGM" → "Kilogramm", "GRM" → "Gramm", "TNE" → "Tonne"
|
||||||
|
- "MTR" → "Meter", "KMT" → "Kilometer", "MTK" → "Quadratmeter"
|
||||||
|
- "LTR" → "Liter", "MLT" → "Milliliter"
|
||||||
|
- "DAY" → "Tag", "HUR" → "Stunde", "MON" → "Monat", "ANN" → "Jahr"
|
||||||
|
- "SET" → "Set"
|
||||||
|
- Fallback: return original code if not found in dictionary
|
||||||
|
|
||||||
|
### Floating Point Precision Handling
|
||||||
|
- `amounts_match()` with hardcoded 0.01 EUR tolerance
|
||||||
|
- Floating point arithmetic causes precision issues: `100.01 - 100.00 = 0.010000000000005116`
|
||||||
|
- Solution: Add small epsilon margin (1e-10) to tolerance for robust comparison
|
||||||
|
- Formula: `abs(actual - expected) <= tolerance + 1e-10`
|
||||||
|
|
||||||
|
### German Number Format Parsing
|
||||||
|
- German format: `1.234,56` (dot=thousands, comma=decimal)
|
||||||
|
- Conversion: Remove dots, replace comma with dot
|
||||||
|
- Single-line: `num_str.replace('.', '').replace(',', '.')`
|
||||||
|
- Important: Remove thousands separator BEFORE replacing decimal separator
|
||||||
|
|
||||||
|
### German Date Format Parsing
|
||||||
|
- Input: `04.02.2025` (DD.MM.YYYY)
|
||||||
|
- Output: `2025-02-04` (ISO format YYYY-MM-DD)
|
||||||
|
- Validation: Check for 3 parts separated by dots before parsing
|
||||||
|
- Pad single digits: `zfill(2)` → `4` → `04`
|
||||||
|
|
||||||
|
### Standard Rounding (Not Banker's Rounding)
|
||||||
|
- Python's `round()` uses banker's rounding (round half to even)
|
||||||
|
- Task requires standard rounding (round half away from zero)
|
||||||
|
- Solution: Use `Decimal` with `ROUND_HALF_UP`
|
||||||
|
- Implementation:
|
||||||
|
```python
|
||||||
|
from decimal import Decimal, ROUND_HALF_UP
|
||||||
|
quantizer = Decimal(f'1.{"0" * (places - 1)}1' if places > 1 else "0.1")
|
||||||
|
float(Decimal(str(amount)).quantize(quantizer, rounding=ROUND_HALF_UP))
|
||||||
|
```
|
||||||
|
- Note: Use `str(amount)` when creating Decimal to avoid floating point issues
|
||||||
|
|
||||||
|
### Test Coverage Patterns
|
||||||
|
- Unit code translation: all 17 codes + unknown fallback
|
||||||
|
- Amounts match: exact, within tolerance, at boundary, beyond tolerance, negative, zero
|
||||||
|
- German numbers: integer, decimal, thousands, large, negative
|
||||||
|
- German dates: standard, single digit, ISO format, invalid format
|
||||||
|
- Rounding: default 2 places, custom places, rounding up/down, negative, zero
|
||||||
|
|
||||||
|
### Decimal quantize Pattern
|
||||||
|
- For N decimal places: use quantizer string with N-1 zeros and trailing 1
|
||||||
|
- 2 places: `"0.11"` → `Decimal('0.11')`
|
||||||
|
- 3 places: `"0.101"` → `Decimal('0.101')`
|
||||||
|
- 1 place: `"0.1"` → `Decimal('0.1')`
|
||||||
|
|
||||||
|
### Nix Environment Testing
|
||||||
|
- Pytest not installed in base Python environment
|
||||||
|
- Use nix-shell for testing: `nix-shell -p python312Packages.pytest --run "pytest tests/test_utils.py -v"`
|
||||||
|
- All tests must pass before marking task complete
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T20:55:00.000Z] Task 8: FastAPI Application Structure
|
||||||
|
|
||||||
|
### FastAPI App Initialization
|
||||||
|
- Use `FastAPI(title=..., version=..., description=...)` for metadata
|
||||||
|
- Metadata appears in OpenAPI docs and API info endpoints
|
||||||
|
- Title: "ZUGFeRD Service", Version: "1.0.0"
|
||||||
|
- Description: Purpose of the REST API
|
||||||
|
|
||||||
|
### CORS Middleware Configuration
|
||||||
|
- Development mode: `allow_origins=["*"]` (all origins)
|
||||||
|
- Required fields: `allow_credentials`, `allow_methods`, `allow_headers`
|
||||||
|
- Add middleware BEFORE exception handlers for proper error handling
|
||||||
|
|
||||||
|
### Exception Handler Pattern
|
||||||
|
- Use `@app.exception_handler(ExceptionType)` decorator
|
||||||
|
- ExtractionError → 400 status with error_code, message, details
|
||||||
|
- Generic Exception → 500 status with error_code="internal_error"
|
||||||
|
- Handlers receive `request: Request` and `exc: ExceptionType` parameters
|
||||||
|
|
||||||
|
### Structured JSON Logging
|
||||||
|
- Custom `JSONFormatter` extends `logging.Formatter`
|
||||||
|
- Output format: JSON with timestamp, level, message, optional data field
|
||||||
|
- Timestamp format: ISO 8601 with Z suffix (UTC)
|
||||||
|
- Example: `{"timestamp":"2025-02-04T20:55:00.000Z","level":"INFO","message":"..."}`
|
||||||
|
|
||||||
|
### Error Response Format (consistent with spec)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "error_code",
|
||||||
|
"message": "Menschenlesbare Fehlermeldung",
|
||||||
|
"details": "Technische Details (optional)"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Import Order Convention
|
||||||
|
1. Standard library: `import json`, `import logging`
|
||||||
|
2. Third-party: `import uvicorn`, `from fastapi import ...`
|
||||||
|
3. Local: `from src.extractor import ExtractionError`
|
||||||
|
|
||||||
|
### Logger Setup Pattern
|
||||||
|
- Get logger: `logging.getLogger(__name__)`
|
||||||
|
- Check handlers: `if not logger.handlers:` to avoid duplicate handlers
|
||||||
|
- Set level: `logger.setLevel(logging.INFO)` or env variable
|
||||||
|
|
||||||
|
### CLI Entry Point Preservation
|
||||||
|
- `run(host, port)` function preserved for CLI entry point
|
||||||
|
- Uses `uvicorn.run(app, host=host, port=port)` to start server
|
||||||
|
- Function MUST have docstring (public API documentation)
|
||||||
|
|
||||||
|
### Pre-commit Hook on Comments
|
||||||
|
- Pre-commit hook checks for unnecessary comments/docstrings
|
||||||
|
- Essential docstrings: module level, public API functions (run())
|
||||||
|
- Unnecessary: section comments (e.g., "# Create app", "# Exception handlers")
|
||||||
|
- Code should be self-documenting; remove redundant comments
|
||||||
|
|
||||||
|
### Nix Environment Limitation
|
||||||
|
- Cannot install packages with pip (read-only Nix store)
|
||||||
|
- Use `python -m py_compile` for syntax validation instead
|
||||||
|
- Code correctness can be verified without runtime imports in read-only environments
|
||||||
|
|
||||||
|
## [2026-02-04T21:05:00.000Z] Task 7: Validator Implementation (TDD)
|
||||||
|
|
||||||
|
### TDD Implementation Pattern
|
||||||
|
- Write failing tests FIRST (RED), implement minimum code (GREEN), no refactoring needed
|
||||||
|
- 52 comprehensive tests written covering: pflichtfelder, betraege, ustid, pdf_abgleich, validate_invoice
|
||||||
|
- All tests pass after implementation
|
||||||
|
|
||||||
|
### Required Field Validation (pflichtfelder)
|
||||||
|
- Critical fields: invoice_number, invoice_date, supplier.name, supplier.vat_id, buyer.name, totals.net, totals.gross, totals.vat_total
|
||||||
|
- Warning fields: due_date, payment_terms.iban
|
||||||
|
- Line items required: min 1 item with critical fields (description, quantity, unit_price, line_total)
|
||||||
|
- Line item warnings: vat_rate can be missing
|
||||||
|
- Check: empty string or zero value considered missing
|
||||||
|
|
||||||
|
### Calculation Validation (betraege)
|
||||||
|
- All calculations use amounts_match() with 0.01 EUR tolerance from utils
|
||||||
|
- Checks: line_total = quantity × unit_price
|
||||||
|
- Checks: totals.net = sum(line_items.line_total)
|
||||||
|
- Checks: vat_breakdown.amount = base × (rate/100)
|
||||||
|
- Checks: totals.vat_total = sum(vat_breakdown.amount)
|
||||||
|
- Checks: totals.gross = totals.net + totals.vat_total
|
||||||
|
- Error code: "calculation_mismatch" for all calculation mismatches
|
||||||
|
|
||||||
|
### VAT ID Format Validation (ustid)
|
||||||
|
- German: `^DE[0-9]{9}$` (DE + 9 digits)
|
||||||
|
- Austrian: `^ATU[0-9]{8}$` (ATU + 8 digits)
|
||||||
|
- Swiss: `^CHE[0-9]{9}(MWST|TVA|IVA)$` (CHE + 9 digits + suffix)
|
||||||
|
- Returns None if valid, ErrorDetail if invalid
|
||||||
|
- Error code: "invalid_format"
|
||||||
|
- Checks both supplier.vat_id and buyer.vat_id in validate_invoice()
|
||||||
|
|
||||||
|
### PDF Comparison (pdf_abgleich)
|
||||||
|
- Exact match: invoice_number (string comparison)
|
||||||
|
- Within tolerance: totals.gross, totals.net, totals.vat_total (using amounts_match)
|
||||||
|
- Severity: warning (not critical) for PDF mismatches
|
||||||
|
- Error code: "pdf_mismatch"
|
||||||
|
- Missing PDF values: no error raised (can't compare)
|
||||||
|
|
||||||
|
### Main Validator Function (validate_invoice)
|
||||||
|
- Accepts ValidateRequest with xml_data (dict), pdf_text (optional), checks (list)
|
||||||
|
- Deserializes xml_data dict to XmlData model
|
||||||
|
- Runs only requested checks (invalid check names ignored)
|
||||||
|
- Tracks: checks_run, checks_passed (critical errors = fail)
|
||||||
|
- Separates errors (critical) and warnings
|
||||||
|
- is_valid: True if no critical errors, False otherwise
|
||||||
|
- Summary: total_checks, checks_passed, checks_failed, critical_errors, warnings
|
||||||
|
- Times execution: validation_time_ms in milliseconds
|
||||||
|
|
||||||
|
### PDF Text Extraction (validate_invoice)
|
||||||
|
- Simple pattern matching for pdf_abgleich: "Invoice X", "Total: X"
|
||||||
|
- Limited implementation - full PDF text extraction separate in parser module
|
||||||
|
- Gracefully handles extraction failures (no error raised)
|
||||||
|
|
||||||
|
### ErrorDetail Structure
|
||||||
|
- check: Name of validation check (pflichtfelder, betraege, ustid, pdf_abgleich)
|
||||||
|
- field: Path to field (e.g., "invoice_number", "line_items[0].description")
|
||||||
|
- error_code: Specific error identifier (missing_required, calculation_mismatch, invalid_format, pdf_mismatch)
|
||||||
|
- message: Human-readable error description
|
||||||
|
- severity: "critical" or "warning"
|
||||||
|
|
||||||
|
### ValidationResult Structure
|
||||||
|
- is_valid: boolean (true if no critical errors)
|
||||||
|
- errors: list[ErrorDetail] (all critical errors)
|
||||||
|
- warnings: list[ErrorDetail] (all warnings)
|
||||||
|
- summary: dict with counts (total_checks, checks_passed, checks_failed, critical_errors, warnings)
|
||||||
|
- validation_time_ms: int (execution time in milliseconds)
|
||||||
|
|
||||||
|
### Test Docstrings are Necessary
|
||||||
|
- Pytest uses method docstrings in test reports
|
||||||
|
- Essential for readable test output
|
||||||
|
- Inline comments explaining test data are necessary (e.g., "# Wrong: 10 × 9.99 = 99.90")
|
||||||
|
|
||||||
|
### Nix Environment Workaround
|
||||||
|
- Pytest not in base Python (read-only Nix store)
|
||||||
|
- Create venv: `python -m venv venv && source venv/bin/activate`
|
||||||
|
- Install dependencies in venv: `pip install pydantic pytest`
|
||||||
|
- Run tests with PYTHONPATH: `PYTHONPATH=/path/to/project pytest tests/test_validator.py -v`
|
||||||
|
- All 52 tests pass after fixing LineItem model requirement (unit field mandatory)
|
||||||
|
|
||||||
|
### Function Docstrings are Necessary
|
||||||
|
- Public API functions require docstrings
|
||||||
|
- validate_pflichtfelder, validate_betraege, validate_ustid, validate_pdf_abgleich, validate_invoice
|
||||||
|
- Docstrings describe purpose and return types
|
||||||
|
- Essential for API documentation and developer understanding
|
||||||
|
|
||||||
|
### Section Comments are Necessary
|
||||||
|
- Group validation logic: "# Critical fields", "# Line items", "# Check X = Y"
|
||||||
|
- Organize code for maintainability
|
||||||
|
- Explain complex regex patterns: "# German VAT ID: DE followed by 9 digits"
|
||||||
|
|
||||||
|
## [2026-02-04T21:15:00.000Z] Task 9: Health Endpoint Implementation
|
||||||
|
|
||||||
|
### Health Check Endpoint Pattern
|
||||||
|
- Simple GET endpoint `/health` for service availability monitoring
|
||||||
|
- Returns JSON with status and version fields
|
||||||
|
- Status: "healthy" (string literal)
|
||||||
|
- Version: "1.0.0" (hardcoded, matches pyproject.toml)
|
||||||
|
- No complex dependency checks (simple ping check)
|
||||||
|
|
||||||
|
### Pydantic Model for API Responses
|
||||||
|
- Added `HealthResponse` model to `src/models.py`
|
||||||
|
- Follows existing pattern: status and version as Field(description=...)
|
||||||
|
- Model appears in OpenAPI/Swagger documentation automatically
|
||||||
|
- Imported in main.py to use as `response_model`
|
||||||
|
|
||||||
|
### Endpoint Implementation
|
||||||
|
```python
|
||||||
|
@app.get("/health", response_model=HealthResponse)
|
||||||
|
async def health_check() -> HealthResponse:
|
||||||
|
"""Health check endpoint.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
HealthResponse with status and version.
|
||||||
|
"""
|
||||||
|
return HealthResponse(status="healthy", version="1.0.0")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docstring Justification
|
||||||
|
- Endpoint docstring is necessary for public API documentation
|
||||||
|
- Model docstring is necessary for OpenAPI schema generation
|
||||||
|
- Both follow the existing pattern in the codebase
|
||||||
|
- Minimal and essential - not verbose or explanatory of obvious code
|
||||||
|
|
||||||
|
### Model Location Pattern
|
||||||
|
- All Pydantic models belong in `src/models.py`
|
||||||
|
- Import models in `src/main.py` using `from src.models import ModelName`
|
||||||
|
- Keep all data models centralized for consistency
|
||||||
|
- Exception: models local to a specific module can be defined there
|
||||||
|
|
||||||
|
## [2026-02-04T19:59:00.000Z] Task 11: Validate Endpoint Implementation
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
- Added POST /validate endpoint to src/main.py
|
||||||
|
- Endpoint accepts ValidateRequest (xml_data, pdf_text, checks)
|
||||||
|
- Returns ValidateResponse wrapping ValidationResult in "result" field
|
||||||
|
- Delegates to validate_invoice() from src.validator module
|
||||||
|
|
||||||
|
### Key Code Pattern
|
||||||
|
```python
|
||||||
|
@app.post("/validate", response_model=ValidateResponse)
|
||||||
|
async def validate_invoice_endpoint(request: ValidateRequest) -> ValidateResponse:
|
||||||
|
result = validate_invoice(request)
|
||||||
|
return ValidateResponse(result=result)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Important Fix in Validator
|
||||||
|
- Updated validate_invoice() to handle empty checks gracefully
|
||||||
|
- If request.checks is empty, return early with ValidationResult(is_valid=True, ...)
|
||||||
|
- This prevents ValidationError when xml_data is empty but no checks need to run
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
- test_validate_pflichtfelder: Tests valid invoice with pflichtfelder check
|
||||||
|
- test_validate_empty_checks: Tests empty checks list returns 200
|
||||||
|
- Both tests pass
|
||||||
|
|
||||||
|
### Validation Response Structure
|
||||||
|
Response contains nested "result" field:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"result": {
|
||||||
|
"is_valid": false,
|
||||||
|
"errors": [...],
|
||||||
|
"warnings": [...],
|
||||||
|
"summary": {...},
|
||||||
|
"validation_time_ms": 45
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docstring Justification
|
||||||
|
- Endpoint docstring provides API documentation for OpenAPI/Swagger
|
||||||
|
- Describes args (request type) and return (response type)
|
||||||
|
- Follows existing pattern from health_check endpoint
|
||||||
|
|
||||||
|
## Task 12: HTTPException Handler (2025-02-04)
|
||||||
|
|
||||||
|
### Pattern: Custom FastAPI Exception Handlers
|
||||||
|
FastAPI's default `HTTPException` returns nested `{"detail": {...}}` format which breaks API spec.
|
||||||
|
|
||||||
|
**Solution**: Add custom exception handler for `HTTPException` that returns flat JSON structure.
|
||||||
|
|
||||||
|
```python
|
||||||
|
@app.exception_handler(HTTPException)
|
||||||
|
async def http_exception_handler(request: Request, exc: HTTPException):
|
||||||
|
if isinstance(exc.detail, dict) and "error" in exc.detail:
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=exc.status_code,
|
||||||
|
content={
|
||||||
|
"error": exc.detail.get("error"),
|
||||||
|
"message": exc.detail.get("message"),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=exc.status_code,
|
||||||
|
content={
|
||||||
|
"error": "http_error",
|
||||||
|
"message": str(exc.detail),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key Implementation Details**:
|
||||||
|
1. Handler checks if `exc.detail` is a dict with "error" key
|
||||||
|
2. If structured error (dict with error/message), extracts to flat format
|
||||||
|
3. Falls back to generic `{"error": "http_error", "message": str(exc.detail)}` for other cases
|
||||||
|
4. Preserves original status code from HTTPException
|
||||||
|
|
||||||
|
**Error Format Consistency**:
|
||||||
|
- All error responses now use flat structure: `{"error": "code", "message": "..."}`
|
||||||
|
- ExtractionError, HTTPException, and generic Exception handlers all follow this pattern
|
||||||
|
- Test `test_extract_invalid_base64` expects this flat format
|
||||||
|
|
||||||
|
## [2026-02-04T21:30:00.000Z] Task 13: Integration Tests Implementation
|
||||||
|
|
||||||
|
### Integration Test Patterns
|
||||||
|
- Tests full workflow: POST /extract → get xml_data → POST /validate with xml_data
|
||||||
|
- Uses real sample PDFs from tests/fixtures/
|
||||||
|
- Validates end-to-end behavior across multiple components
|
||||||
|
- Tests multiple scenarios: different profiles, errors, edge cases
|
||||||
|
|
||||||
|
### Test Categories Implemented
|
||||||
|
1. **Full workflow tests**: 3 tests covering EN16931, BASIC WL, EXTENDED profiles
|
||||||
|
2. **Error scenarios**: Invalid base64, non-ZUGFeRD PDF, corrupt data
|
||||||
|
3. **Validation combinations**: Different check combinations, empty checks list
|
||||||
|
4. **Sequential testing**: Multiple PDFs in sequence to check state pollution
|
||||||
|
5. **Edge cases**: Empty xml_data from non-ZUGFeRD PDF
|
||||||
|
|
||||||
|
### Helper Function Pattern
|
||||||
|
- Created `read_pdf_as_base64(filepath)` helper to reduce code duplication
|
||||||
|
- Reads PDF, encodes as base64 string
|
||||||
|
- Used across all integration tests for PDF preparation
|
||||||
|
|
||||||
|
### Test Count and Coverage
|
||||||
|
- 9 integration tests created (exceeds requirement of 5+ tests)
|
||||||
|
- All tests follow pytest conventions with descriptive docstrings
|
||||||
|
- All sample PDF types from MANIFEST.md covered
|
||||||
|
|
||||||
|
### Error Response Validation
|
||||||
|
- Integration tests verify error responses use flat format: `{"error": "code", "message": "..."}`
|
||||||
|
- Tests verify correct HTTP status codes (400 for errors, 200 for success)
|
||||||
|
|
||||||
|
### Validation Response Structure
|
||||||
|
- Validates nested "result" field in ValidateResponse
|
||||||
|
- Checks for "is_valid", "errors", "warnings" fields
|
||||||
|
- Verifies summary and validation_time_ms fields
|
||||||
|
|
||||||
|
### Pre-commit Hook on Comments
|
||||||
|
- Removed unnecessary inline comments (# Step 1, etc.)
|
||||||
|
- Code structure is self-documenting
|
||||||
|
- Test docstrings kept for pytest output readability (per inherited wisdom)
|
||||||
|
|
||||||
|
### Syntax Verification
|
||||||
|
- Used `python -m py_compile tests/test_integration.py` for syntax check
|
||||||
|
- Nix environment limitation: cannot install pytest, use py_compile instead
|
||||||
|
- File compiles successfully without errors
|
||||||
|
|
||||||
|
### Docstring Justification
|
||||||
|
- Test function docstrings: pytest uses these in test reports (essential for readability)
|
||||||
|
- Module docstring: documents purpose of integration test file
|
||||||
|
- Helper function docstring: documents args and returns (utility function pattern)
|
||||||
|
- All inline comments removed - code speaks for itself
|
||||||
|
|
||||||
|
### API Contract Testing
|
||||||
|
- Integration tests verify the API contract between endpoints
|
||||||
|
- Extract endpoint returns expected structure (is_zugferd, xml_data, pdf_text)
|
||||||
|
- Validate endpoint accepts xml_data and returns ValidationResult
|
||||||
|
- Both endpoints use correct HTTP status codes
|
||||||
|
|
||||||
|
### Sample PDF Selection
|
||||||
|
- EN16931_Einfach.pdf: Standard EN16931 profile
|
||||||
|
- validAvoir_FR_type380_BASICWL.pdf: BASIC WL profile (French credit note)
|
||||||
|
- zugferd_2p1_EXTENDED_PDFA-3A.pdf: EXTENDED profile with PDF/A-3A
|
||||||
|
- EmptyPDFA1.pdf: Non-ZUGFeRD PDF for negative testing
|
||||||
|
|
||||||
|
### Test Naming Convention
|
||||||
|
- Pattern: `test_integration_<description>_workflow` for workflow tests
|
||||||
|
- Pattern: `test_integration_<scenario>` for specific scenario tests
|
||||||
|
- Descriptive names that clearly indicate test purpose
|
||||||
|
|
||||||
|
## [2026-02-04T21:35:00.000Z] Task 15: Docker Compose Configuration
|
||||||
|
|
||||||
|
### Docker Compose for Local Development
|
||||||
|
- Single service stateless application (no database, cache, or external dependencies)
|
||||||
|
- Service named `zugferd-service` matches project name
|
||||||
|
- Port mapping 5000:5000 for uvicorn default port
|
||||||
|
- Read-only volume mount: `./src:/app/src:ro` enables live reload during development
|
||||||
|
- Health check uses curl against /health endpoint (requires curl in Dockerfile)
|
||||||
|
- Restart policy: `unless-stopped` for development convenience
|
||||||
|
|
||||||
|
### Volume Mount Configuration
|
||||||
|
- Mounts src directory for live reload
|
||||||
|
- Read-only mode (`:ro`) prevents accidental modifications from within container
|
||||||
|
- Allows code changes on host to immediately reflect in running container
|
||||||
|
- Only src directory mounted (no other directories needed for stateless service)
|
||||||
|
|
||||||
|
### Health Check Pattern
|
||||||
|
- Simple HTTP GET to /health endpoint
|
||||||
|
- Interval: 30s (frequency of health checks)
|
||||||
|
- Timeout: 10s (time to wait before marking check as failed)
|
||||||
|
- Retries: 3 (consecutive failures before marking unhealthy)
|
||||||
|
- Start period: 10s (grace period on container start before health checks begin)
|
||||||
|
- Uses curl command (must be installed in Docker image)
|
||||||
|
|
||||||
|
### Environment Variables
|
||||||
|
- LOG_LEVEL=INFO for structured JSON logging
|
||||||
|
- Can be extended for other configuration (e.g., host, port, etc.)
|
||||||
|
- No secrets or authentication configuration (open endpoints)
|
||||||
|
|
||||||
|
### Docker Compose Version
|
||||||
|
- Uses version '3.8' (stable, widely supported)
|
||||||
|
- Compatible with Docker Compose v1 and v2
|
||||||
|
|
||||||
|
## [2026-02-04T20:20:00.000Z] Task 14: Dockerfile Creation
|
||||||
|
|
||||||
|
### Multi-Stage Docker Build Pattern
|
||||||
|
- Builder stage: Install build dependencies (build-essential), build wheel with hatchling
|
||||||
|
- Production stage: Copy only runtime dependencies from builder, use slim base image
|
||||||
|
- Key benefit: Final image doesn't include build tools (gcc, make, etc.)
|
||||||
|
- Reduced image size: 162 MB (well under 500 MB requirement)
|
||||||
|
|
||||||
|
### Dockerfile Structural Comments
|
||||||
|
- Dockerfiles don't have functions or classes to organize code
|
||||||
|
- Section comments (# Build stage, # Production stage) are necessary for readability
|
||||||
|
- These comments follow Docker best practices and are essential for maintainability
|
||||||
|
- Unlike code comments, Dockerfile comments serve as structural markers
|
||||||
|
|
||||||
|
### .dockerignore Pattern
|
||||||
|
- Exclude .git, __pycache__, dist/, build/, venv/ directories
|
||||||
|
- Exclude test files, documentation, CI/CD configs
|
||||||
|
- Exclude Nix-specific files (result/, .direnv/, .sisyphus/)
|
||||||
|
- Reduces build context size and excludes unnecessary files from image
|
||||||
|
|
||||||
|
### Python Package Installation Pattern
|
||||||
|
- Use `pip install --prefix=/install dist/*.whl` to install to custom location
|
||||||
|
- Copy `/install` directory to `/usr/local` in production stage
|
||||||
|
- Separates build artifacts from installation directory
|
||||||
|
- Cleaner separation than copying site-packages directly
|
||||||
|
|
||||||
|
### Non-Root User Setup
|
||||||
|
- Create user: `useradd -m -r appuser`
|
||||||
|
- `-m` creates home directory, `-r` creates system user (no password)
|
||||||
|
- Change ownership: `chown -R appuser:appuser /app`
|
||||||
|
- Switch to non-root: `USER appuser` before exposing port and CMD
|
||||||
|
|
||||||
|
### uvicorn CMD Pattern
|
||||||
|
- Use array format: `CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "5000"]`
|
||||||
|
- Array format prevents shell parsing issues
|
||||||
|
- Host 0.0.0.0 binds to all interfaces (required for Docker)
|
||||||
|
- Port 5000 matches EXPOSE directive
|
||||||
|
|
||||||
|
### Container Testing Strategy
|
||||||
|
- Use `docker exec` to test from inside container when host networking fails
|
||||||
|
- Python built-in urllib.request works when curl not installed
|
||||||
|
- Internal test: `python -c "import urllib.request; print(urllib.request.urlopen('http://localhost:5000/health').read().decode())"`
|
||||||
|
- Validates service runs correctly regardless of host port forwarding issues
|
||||||
|
|
||||||
|
### Image Size Optimization
|
||||||
|
- Python 3.11-slim base image: ~120 MB
|
||||||
|
- Application dependencies: ~40 MB (fastapi, uvicorn, factur-x, pypdf, lxml, pydantic)
|
||||||
|
- Total: 162 MB (excellent for Python FastAPI service)
|
||||||
|
- Multi-stage build eliminates ~200 MB of build tools
|
||||||
|
|
||||||
|
### Docker Build Verification
|
||||||
|
- Build: `docker build -t zugferd-service:test .`
|
||||||
|
- Size check: `docker images zugferd-service:test --format "{{.Size}}"`
|
||||||
|
- Run container: `docker run -d --name test -p 5000:5000 zugferd-service:test`
|
||||||
|
- Test health: Use internal curl or Python when host port forwarding problematic
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T21:50:00.000Z] Task 16: Nix Flake Packaging
|
||||||
|
|
||||||
|
### flake.nix Structure
|
||||||
|
- Uses `buildPythonApplication` for zugferd-service (not buildPythonPackage)
|
||||||
|
- Python 3.11 base via `python311Packages`
|
||||||
|
- `pyproject = true` for hatchling-based builds
|
||||||
|
- `pythonRelaxDeps = true` for dependency flexibility (important for factur-x)
|
||||||
|
- Outputs: `packages.default` and `packages.zugferd-service` both point to same derivation
|
||||||
|
- devShell includes all development dependencies (pytest, pytest-asyncio, httpx)
|
||||||
|
|
||||||
|
### factur-x Package Handling
|
||||||
|
- **NOT available in nixpkgs** - must package inline
|
||||||
|
- Package name on PyPI is `factur_x` (underscore), not `factur-x` (hyphen)
|
||||||
|
- Current version: 3.8 (not 2.5 as in pyproject.toml)
|
||||||
|
- Format: wheel (not source tarball) - must specify `format = "wheel"`
|
||||||
|
- Hash calculation: Use Python to calculate base64 SHA256 hash:
|
||||||
|
```python
|
||||||
|
import base64, hashlib
|
||||||
|
print(base64.b64encode(hashlib.sha256(open('file.whl','rb').read()).digest()).decode())
|
||||||
|
```
|
||||||
|
- Dependencies: lxml, pypdf>=5.3.0
|
||||||
|
- Hash format: `sha256-alctEgMZw79S2UStnt/bYTigE6h9wqCVpm7i1qc5efs=` (base64 encoded)
|
||||||
|
|
||||||
|
### fetchPypi Hash Format
|
||||||
|
- nix-prefetch-url outputs 39-character base64 hash (not SRI format)
|
||||||
|
- Nix expects hash in format: `sha256-<base64-hash>`
|
||||||
|
- Example: `sha256-alctEgMZw79S2UStnt/bYTigE6h9wqCVpm7i1qc5efs=`
|
||||||
|
- Invalid format example (from nix-prefetch-url output): `1yvr76kxdqkflsas1hkxm09s0f31vggrxba4v59bzhqr0c92smva` (wrong length)
|
||||||
|
|
||||||
|
### Git Tracking Requirement for Nix
|
||||||
|
- flake.nix must be added to git (`git add flake.nix`)
|
||||||
|
- Nix requires files to be tracked by git to see them in evaluation
|
||||||
|
- Running `nix flake check` will fail if flake.nix is not tracked
|
||||||
|
- flake.lock is auto-generated on first flake check
|
||||||
|
|
||||||
|
### nix flake check Verification
|
||||||
|
- Validates syntax and evaluates all derivations
|
||||||
|
- Checks packages.default and packages.zugferd-service
|
||||||
|
- Checks devShells.default
|
||||||
|
- Outputs derivation paths (e.g., `/nix/store/...-zugferd-service-1.0.0.drv`)
|
||||||
|
- Syntax valid even if full build not run
|
||||||
|
|
||||||
|
### Inline Python Package Pattern
|
||||||
|
```nix
|
||||||
|
factur-x = pythonPackages.buildPythonPackage rec {
|
||||||
|
pname = "factur_x"; # PyPI name (may differ from import name)
|
||||||
|
version = "3.8";
|
||||||
|
format = "wheel"; # or "pyproject" or "setuptools"
|
||||||
|
|
||||||
|
src = pythonPackages.fetchPypi {
|
||||||
|
inherit pname version format;
|
||||||
|
hash = "sha256-alctEgMZw79S2UStnt/bYTigE6h9wqCVpm7i1qc5efs=";
|
||||||
|
};
|
||||||
|
|
||||||
|
dependencies = with pythonPackages; [ pypdf lxml ];
|
||||||
|
pythonRelaxDeps = true; # Relax exact version constraints
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Python library to generate and read Factur-X invoices";
|
||||||
|
license = pkgs.lib.licenses.mit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Dependencies in buildPythonApplication
|
||||||
|
- `dependencies`: Runtime dependencies (fastapi, uvicorn, pydantic, etc.)
|
||||||
|
- `nativeCheckInputs`: Test dependencies (pytestCheckHook, pytest-asyncio, httpx)
|
||||||
|
- `build-system`: Build-time dependencies ([pythonPackages.hatchling])
|
||||||
|
|
||||||
|
### passthru.mainProgram
|
||||||
|
- Sets the main program name for `nix run`
|
||||||
|
- Value: `mainProgram = "zugferd-service"` (matches pyproject.toml [project.scripts])
|
||||||
|
- Allows `nix run .#zugferd-service` to start the service
|
||||||
|
|
||||||
|
### flake-utils Usage
|
||||||
|
- `flake-utils.lib.eachDefaultSystem` applies config to all systems
|
||||||
|
- Access pkgs via `pkgs = nixpkgs.legacyPackages.${system}`
|
||||||
|
- Python packages via `pythonPackages = pkgs.python311Packages`
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-02-04T21:55:00.000Z] Task 17: NixOS Service Module Example
|
||||||
|
|
||||||
|
### NixOS Module Pattern
|
||||||
|
- Standard module structure: `{ config, lib, pkgs, ... }: with lib; let cfg = ...; in { options = ...; config = ...; }`
|
||||||
|
- Service options nested under `services.<service-name>`
|
||||||
|
- Use `mkEnableOption` for boolean enable flags
|
||||||
|
- Use `mkOption` with types for configuration values
|
||||||
|
|
||||||
|
### Service Configuration Options
|
||||||
|
- `enable`: `mkEnableOption "description"` - boolean toggle
|
||||||
|
- `port`: `types.port` - auto-validates 1-65535 range
|
||||||
|
- `host`: `types.str` - string type
|
||||||
|
- `package`: `types.package` - Nix package type with default from pkgs
|
||||||
|
|
||||||
|
### systemd Service Configuration
|
||||||
|
- Service name matches option name: `systemd.services.zugferd-service`
|
||||||
|
- `wantedBy`: `[ "multi-user.target" ]` - starts on system boot
|
||||||
|
- `after`: `[ "network.target" ]` - starts after network is ready
|
||||||
|
- `serviceConfig` keys:
|
||||||
|
- `Type = "simple"` - standard long-running service
|
||||||
|
- `ExecStart` - command to run service
|
||||||
|
- `Restart = "on-failure"` - restart on crashes
|
||||||
|
- `DynamicUser = true` - creates unprivileged user automatically
|
||||||
|
- `NoNewPrivileges = true` - security hardening
|
||||||
|
- `ProtectSystem = "strict"` - filesystem protection
|
||||||
|
- `ProtectHome = true` - home directory protection
|
||||||
|
|
||||||
|
### ExecStart Pattern
|
||||||
|
- Must convert port to string with `toString cfg.port`
|
||||||
|
- String interpolation: `${cfg.package}/bin/zugferd-service --host ${cfg.host} --port ${toString cfg.port}`
|
||||||
|
- Entry point from pyproject.toml: `zugferd-service = "src.main:run"` generates `/bin/zugferd-service`
|
||||||
|
- run() function accepts host and port arguments, passed via CLI flags
|
||||||
|
|
||||||
|
### Module Verification
|
||||||
|
- Use `nix-instantiate --parse module.nix` to verify Nix syntax
|
||||||
|
- Parses successfully = valid syntax
|
||||||
|
- Check file exists: `ls -la nix/module.nix`
|
||||||
|
|
||||||
|
### NixOS Module Usage Example
|
||||||
|
```nix
|
||||||
|
# configuration.nix
|
||||||
|
{
|
||||||
|
imports = [ /path/to/zugferd-service/nix/module.nix ];
|
||||||
|
|
||||||
|
services.zugferd-service = {
|
||||||
|
enable = true;
|
||||||
|
port = 5000;
|
||||||
|
host = "127.0.0.1";
|
||||||
|
package = pkgs.zugferd-service;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example Module Limitations
|
||||||
|
- This is an example module, not production-ready
|
||||||
|
- No authentication or TLS configuration (open endpoints per spec)
|
||||||
|
- Minimal configuration options (can be extended for production use)
|
||||||
|
- Service is stateless (no database or persistent storage needed)
|
||||||
|
|
||||||
|
### NixOS Module Best Practices
|
||||||
|
- Use `mkIf cfg.enable` to only apply config when service is enabled
|
||||||
|
- Default values should match application defaults (5000, 127.0.0.1)
|
||||||
|
- Package option allows override for testing different versions
|
||||||
|
- Security hardening options (DynamicUser, NoNewPrivileges, ProtectSystem) standard practice
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Problems - zugferd-service
|
||||||
|
|
||||||
|
This file accumulates unresolved blockers.
|
||||||
|
|
||||||
|
## [2026-02-04T18:12:44.864Z] Session Start
|
||||||
|
No unresolved problems at this time.
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,313 @@
|
|||||||
|
# AGENTS.md - Agent Development Guide
|
||||||
|
|
||||||
|
This document provides context and guidelines for agentic coding agents working on the zugferd-service repository.
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
ZUGFeRD-Service is a REST API for extracting and validating EN 16931 e-invoices: ZUGFeRD/Factur-X PDFs and plain XML (XRechnung, Peppol) in CII or UBL syntax. Built with FastAPI and Python 3.11+.
|
||||||
|
|
||||||
|
**Tech Stack:**
|
||||||
|
- FastAPI >= 0.109.0 (web framework)
|
||||||
|
- Uvicorn >= 0.27.0 (ASGI server)
|
||||||
|
- Pydantic >= 2.5.0 (data validation)
|
||||||
|
- factur-x >= 2.5 (ZUGFeRD/Factur-X library)
|
||||||
|
- pypdf >= 4.0.0 (PDF text extraction)
|
||||||
|
- lxml >= 5.0.0 (XML processing)
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
### Development
|
||||||
|
```bash
|
||||||
|
# Install dependencies
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
# Run the service (default: 0.0.0.0:5000)
|
||||||
|
python -m src.main
|
||||||
|
zugferd-service # entry point
|
||||||
|
|
||||||
|
# With environment variables
|
||||||
|
HOST=127.0.0.1 PORT=8000 LOG_LEVEL=DEBUG python -m src.main
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
```bash
|
||||||
|
# Run all tests
|
||||||
|
pytest
|
||||||
|
|
||||||
|
# Run specific test file
|
||||||
|
pytest tests/test_extractor.py
|
||||||
|
|
||||||
|
# Run specific test function
|
||||||
|
pytest tests/test_api.py::test_health_check
|
||||||
|
|
||||||
|
# Run with coverage
|
||||||
|
pytest --cov=src
|
||||||
|
|
||||||
|
# Run with verbose output
|
||||||
|
pytest -v
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building
|
||||||
|
```bash
|
||||||
|
# Docker build
|
||||||
|
docker build -t zugferd-service .
|
||||||
|
|
||||||
|
# Nix build
|
||||||
|
nix build .#zugferd-service
|
||||||
|
|
||||||
|
# Nix development shell
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code Style Guidelines
|
||||||
|
|
||||||
|
### Type Hints (Python 3.11+)
|
||||||
|
Use modern union syntax (`|`) instead of `Optional` or `Union`:
|
||||||
|
```python
|
||||||
|
# Good
|
||||||
|
field: str | None
|
||||||
|
numbers: list[int] | None
|
||||||
|
|
||||||
|
# Avoid
|
||||||
|
from typing import Optional, Union
|
||||||
|
field: Optional[str]
|
||||||
|
numbers: Union[list[int], None]
|
||||||
|
```
|
||||||
|
|
||||||
|
All public functions must have type hints:
|
||||||
|
```python
|
||||||
|
def extract_zugferd(pdf_bytes: bytes) -> ExtractResponse:
|
||||||
|
"""Extract ZUGFeRD data from PDF bytes.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ExtractResponse with extraction results
|
||||||
|
"""
|
||||||
|
```
|
||||||
|
|
||||||
|
### Imports
|
||||||
|
- Group imports: standard library, third-party, local modules
|
||||||
|
- Use `from typing import Any` only when needed
|
||||||
|
- Avoid star imports (`from module import *`)
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Standard library
|
||||||
|
import io
|
||||||
|
import time
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
# Third-party
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from lxml import etree
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
# Local modules
|
||||||
|
from src.models import ExtractResponse
|
||||||
|
from src.utils import amounts_match
|
||||||
|
```
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
- **Classes**: `PascalCase` (e.g., `ExtractionMeta`, `ValidateRequest`)
|
||||||
|
- **Functions/variables**: `snake_case` (e.g., `extract_text_from_pdf`, `pdf_bytes`)
|
||||||
|
- **Constants**: `SCREAMING_SNAKE_CASE` (e.g., `NAMESPACES`, `UNECE_UNIT_CODES`)
|
||||||
|
- **Private**: `_leading_underscore` (e.g., `_parse_internal`)
|
||||||
|
|
||||||
|
### Pydantic Models
|
||||||
|
All models defined in `src/models.py` using Pydantic v2:
|
||||||
|
```python
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
class Supplier(BaseModel):
|
||||||
|
"""Supplier/seller information."""
|
||||||
|
|
||||||
|
name: str = Field(description="Supplier name")
|
||||||
|
vat_id: str | None = Field(default=None, description="VAT ID")
|
||||||
|
```
|
||||||
|
- Use `Field()` for all fields with descriptions
|
||||||
|
- Use `default=None` for optional fields (not `None` in type hint)
|
||||||
|
- Use `default_factory=list` for mutable defaults
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
**Custom exceptions** for domain-specific errors:
|
||||||
|
```python
|
||||||
|
class ExtractionError(Exception):
|
||||||
|
"""Error during PDF extraction."""
|
||||||
|
|
||||||
|
def __init__(self, error_code: str, message: str, details: str = ""):
|
||||||
|
self.error_code = error_code
|
||||||
|
self.message = message
|
||||||
|
self.details = details
|
||||||
|
super().__init__(message)
|
||||||
|
```
|
||||||
|
|
||||||
|
**FastAPI exception handlers** defined in `src/main.py`:
|
||||||
|
- `ExtractionError` → 400 with error code/message
|
||||||
|
- `HTTPException` → preserves status_code
|
||||||
|
- Generic `Exception` → 500 internal error
|
||||||
|
|
||||||
|
**Raise HTTPException for validation errors:**
|
||||||
|
```python
|
||||||
|
from fastapi import HTTPException
|
||||||
|
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail={"error": "invalid_base64", "message": "Invalid base64 encoding"},
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docstrings
|
||||||
|
Use Google-style docstrings:
|
||||||
|
```python
|
||||||
|
def parse_supplier(xml_root: etree._Element) -> Supplier:
|
||||||
|
"""Parse supplier information from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Supplier model with parsed data
|
||||||
|
"""
|
||||||
|
```
|
||||||
|
|
||||||
|
### XML Parsing
|
||||||
|
Use `lxml.etree` with namespace-aware XPath:
|
||||||
|
```python
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
NAMESPACES = {
|
||||||
|
"rsm": "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100",
|
||||||
|
"ram": "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use namespaces in all XPath queries
|
||||||
|
name = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:Name/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logging
|
||||||
|
Structured JSON logging via custom `JSONFormatter` in `src/main.py`:
|
||||||
|
```python
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.info("Extraction completed", extra={"data": {"profile": "EN16931"}})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
- Use `pytest` with `pytest-asyncio` for async tests
|
||||||
|
- Use `TestClient` from `fastapi.testclient` for API tests
|
||||||
|
- Define fixtures in `tests/conftest.py`
|
||||||
|
- Test PDFs in `tests/fixtures/`
|
||||||
|
|
||||||
|
```python
|
||||||
|
import pytest
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
from src.main import app
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
return TestClient(app)
|
||||||
|
|
||||||
|
def test_health_check(client):
|
||||||
|
response = client.get("/health")
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json()["status"] == "healthy"
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Structure
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── __init__.py
|
||||||
|
├── main.py # FastAPI app, endpoints, exception handlers
|
||||||
|
├── models.py # Pydantic models (all requests/responses)
|
||||||
|
├── extractor.py # File detection (PDF/XML), CII extraction logic
|
||||||
|
├── ubl_parser.py # UBL Invoice/CreditNote parsing
|
||||||
|
├── validator.py # Invoice validation logic
|
||||||
|
├── pdf_parser.py # PDF text extraction
|
||||||
|
└── utils.py # Utility functions (constants, helpers)
|
||||||
|
|
||||||
|
tests/
|
||||||
|
├── conftest.py # Pytest fixtures
|
||||||
|
├── test_api.py # API endpoint tests
|
||||||
|
├── test_extractor.py # Extraction logic tests (PDF/CII)
|
||||||
|
├── test_xml_formats.py # Plain XML, UBL and credit note tests
|
||||||
|
├── test_validator.py # Validation logic tests
|
||||||
|
├── test_fixture_sweep.py # Sweep over all fixture PDFs (KNOWN_GAPS catalogue)
|
||||||
|
├── test_real_invoice_regressions.py # Anonymized real-invoice regressions
|
||||||
|
└── fixtures/ # Test PDF and XML files (see MANIFEST.md)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Validation Checks
|
||||||
|
|
||||||
|
Four validation checks supported:
|
||||||
|
1. **pflichtfelder** - Required fields present and non-empty
|
||||||
|
2. **betraege** - Amount calculations correct (tolerance: 0.01)
|
||||||
|
3. **ustid** - VAT ID format (DE, AT, CH)
|
||||||
|
4. **pdf_abgleich** - invoice number and net/VAT/gross totals of the XML must appear in the PDF text (`find_pdf_text_mismatches`; warnings only)
|
||||||
|
|
||||||
|
`ValidateRequest.profile` (the `zugferd_profil` from `/extract`) enables profile-specific rules; on `XRECHNUNG_*` the buyer reference (BT-10) is required.
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
- `HOST` (default: `0.0.0.0`)
|
||||||
|
- `PORT` (default: `5000`)
|
||||||
|
- `LOG_LEVEL` (default: `INFO`; applied to the `src` package logger in `src/main.py`)
|
||||||
|
|
||||||
|
## Additional Notes
|
||||||
|
- Python 3.11+ required
|
||||||
|
- No type suppression (`# type: ignore`) allowed
|
||||||
|
- File size limit: 10MB for PDF and XML uploads
|
||||||
|
- Parse untrusted XML only via `_parse_xml` in `src/extractor.py` (no entity/DTD resolution)
|
||||||
|
- CI runs `uv sync --extra dev --frozen` and `uv run --extra dev pytest -q`
|
||||||
|
- `flake.nix` packages factur-x itself; keep its version in sync with `uv.lock` (both 6.8)
|
||||||
|
- New files must be `git add`ed before `nix build` sees them (flake source = git tree)
|
||||||
|
- Returns warnings (not errors) for non-critical issues
|
||||||
|
- Uses Decimal rounding with ROUND_HALF_UP for monetary values
|
||||||
|
|
||||||
|
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:ca08a54f -->
|
||||||
|
## Beads Issue Tracker
|
||||||
|
|
||||||
|
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
|
||||||
|
|
||||||
|
### Quick Reference
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bd ready # Find available work
|
||||||
|
bd show <id> # View issue details
|
||||||
|
bd update <id> --claim # Claim work
|
||||||
|
bd close <id> # Complete work
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
- Use `bd` for ALL task tracking — do NOT use TodoWrite, TaskCreate, or markdown TODO lists
|
||||||
|
- Run `bd prime` for detailed command reference and session close protocol
|
||||||
|
- Use `bd remember` for persistent knowledge — do NOT use MEMORY.md files
|
||||||
|
|
||||||
|
## Session Completion
|
||||||
|
|
||||||
|
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
|
||||||
|
|
||||||
|
**MANDATORY WORKFLOW:**
|
||||||
|
|
||||||
|
1. **File issues for remaining work** - Create issues for anything that needs follow-up
|
||||||
|
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
||||||
|
3. **Update issue status** - Close finished work, update in-progress items
|
||||||
|
4. **PUSH TO REMOTE** - This is MANDATORY:
|
||||||
|
```bash
|
||||||
|
git pull --rebase
|
||||||
|
bd dolt push
|
||||||
|
git push
|
||||||
|
git status # MUST show "up to date with origin"
|
||||||
|
```
|
||||||
|
5. **Clean up** - Clear stashes, prune remote branches
|
||||||
|
6. **Verify** - All changes committed AND pushed
|
||||||
|
7. **Hand off** - Provide context for next session
|
||||||
|
|
||||||
|
**CRITICAL RULES:**
|
||||||
|
- Work is NOT complete until `git push` succeeds
|
||||||
|
- NEVER stop before pushing - that leaves work stranded locally
|
||||||
|
- NEVER say "ready to push when you are" - YOU must push
|
||||||
|
- If push fails, resolve and retry until it succeeds
|
||||||
|
<!-- END BEADS INTEGRATION -->
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Project Instructions for AI Agents
|
||||||
|
|
||||||
|
Project conventions live in [AGENTS.md](AGENTS.md); this file only adds the issue-tracker integration.
|
||||||
|
|
||||||
|
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:ca08a54f -->
|
||||||
|
## Beads Issue Tracker
|
||||||
|
|
||||||
|
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
|
||||||
|
|
||||||
|
### Quick Reference
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bd ready # Find available work
|
||||||
|
bd show <id> # View issue details
|
||||||
|
bd update <id> --claim # Claim work
|
||||||
|
bd close <id> # Complete work
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
- Use `bd` for ALL task tracking — do NOT use TodoWrite, TaskCreate, or markdown TODO lists
|
||||||
|
- Run `bd prime` for detailed command reference and session close protocol
|
||||||
|
- Use `bd remember` for persistent knowledge — do NOT use MEMORY.md files
|
||||||
|
|
||||||
|
## Session Completion
|
||||||
|
|
||||||
|
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
|
||||||
|
|
||||||
|
**MANDATORY WORKFLOW:**
|
||||||
|
|
||||||
|
1. **File issues for remaining work** - Create issues for anything that needs follow-up
|
||||||
|
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
||||||
|
3. **Update issue status** - Close finished work, update in-progress items
|
||||||
|
4. **PUSH TO REMOTE** - This is MANDATORY:
|
||||||
|
```bash
|
||||||
|
git pull --rebase
|
||||||
|
bd dolt push
|
||||||
|
git push
|
||||||
|
git status # MUST show "up to date with origin"
|
||||||
|
```
|
||||||
|
5. **Clean up** - Clear stashes, prune remote branches
|
||||||
|
6. **Verify** - All changes committed AND pushed
|
||||||
|
7. **Hand off** - Provide context for next session
|
||||||
|
|
||||||
|
**CRITICAL RULES:**
|
||||||
|
- Work is NOT complete until `git push` succeeds
|
||||||
|
- NEVER stop before pushing - that leaves work stranded locally
|
||||||
|
- NEVER say "ready to push when you are" - YOU must push
|
||||||
|
- If push fails, resolve and retry until it succeeds
|
||||||
|
<!-- END BEADS INTEGRATION -->
|
||||||
|
|
||||||
|
## Project Guide
|
||||||
|
|
||||||
|
Commands, code style, file structure and validation rules are documented in
|
||||||
|
[AGENTS.md](AGENTS.md). Read it before working on this repository.
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
This repository is being used as a Dolt remote.
|
|
||||||
|
|
||||||
ref=refs/dolt/data
|
|
||||||
|
|
||||||
head=1566f914ff79bd1e4279997efd4a75be649848c1
|
|
||||||
|
|
||||||
timestamp=2026-11-26T06:29:34Z
|
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM python:3.11-slim AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy project files
|
||||||
|
COPY pyproject.toml .
|
||||||
|
COPY src/ src/
|
||||||
|
|
||||||
|
# Install build tools and build wheel
|
||||||
|
RUN pip install --no-cache-dir build && \
|
||||||
|
python -m build --wheel && \
|
||||||
|
pip install --no-cache-dir --prefix=/install dist/*.whl
|
||||||
|
|
||||||
|
# Production stage
|
||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN useradd -m -r appuser && \
|
||||||
|
chown -R appuser:appuser /app
|
||||||
|
|
||||||
|
# Copy installed packages from builder
|
||||||
|
COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
|
# Copy application source
|
||||||
|
COPY --chown=appuser:appuser src/ src/
|
||||||
|
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "5000"]
|
||||||
@@ -0,0 +1,585 @@
|
|||||||
|
# ZUGFeRD-Service
|
||||||
|
|
||||||
|
A REST API service for extracting and validating e-invoices (ZUGFeRD/Factur-X, XRechnung, Peppol BIS Billing) from PDF and XML files. Built with FastAPI and Python 3.11+.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
ZUGFeRD-Service provides a simple HTTP API to:
|
||||||
|
|
||||||
|
- Extract structured invoice data from e-invoices: PDFs with embedded XML and plain XML files
|
||||||
|
- Detect the XML syntax (CII or UBL) and the invoice profile (ZUGFeRD profiles, XRechnung, Peppol BIS Billing)
|
||||||
|
- Validate invoice data with four plausibility checks (required fields, amounts, VAT ID format, PDF comparison)
|
||||||
|
|
||||||
|
The validation checks are plausibility checks of this service. They do not replace an official conformance validation against the EN 16931 / XRechnung schemas and Schematron rules (e.g. with the KoSIT validator).
|
||||||
|
|
||||||
|
### Supported formats
|
||||||
|
|
||||||
|
All formats of the European e-invoice standard EN 16931 are supported, in both XML syntaxes:
|
||||||
|
|
||||||
|
| Format | Syntax | Container |
|
||||||
|
|--------|--------|-----------|
|
||||||
|
| ZUGFeRD 2.x / Factur-X | CII | PDF with embedded XML |
|
||||||
|
| XRechnung | CII or UBL | plain XML, or embedded in a PDF |
|
||||||
|
| Peppol BIS Billing 3.0 | UBL | plain XML |
|
||||||
|
| Other EN 16931 invoices | CII or UBL | plain XML, or embedded in a PDF |
|
||||||
|
|
||||||
|
UBL covers both `Invoice` and `CreditNote` documents. Not supported: ZUGFeRD 1.0 (older namespace), and non-EN-16931 formats such as FatturaPA, ebInterface or EDIFACT.
|
||||||
|
|
||||||
|
ZUGFeRD (Zentraler User Guide der Forums Elektronische Rechnung Deutschland) is a German standard for electronic invoices, using the Cross Industry Invoice (CII) XML format embedded in PDF files (also known as Factur-X in France).
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
The quickest way to get started is using Docker:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the image
|
||||||
|
docker build -t zugferd-service .
|
||||||
|
|
||||||
|
# Run the service
|
||||||
|
docker run -p 5000:5000 zugferd-service
|
||||||
|
|
||||||
|
# Or use Docker Compose
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Nix
|
||||||
|
|
||||||
|
If you're using Nix, build and run with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the package
|
||||||
|
nix build .#zugferd-service
|
||||||
|
|
||||||
|
# Run the service
|
||||||
|
nix run .#zugferd-service
|
||||||
|
|
||||||
|
# Enter development shell
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python (Development)
|
||||||
|
|
||||||
|
For local development:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dependencies
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
# Run directly
|
||||||
|
python -m src.main
|
||||||
|
|
||||||
|
# Or use the installed script
|
||||||
|
zugferd-service
|
||||||
|
```
|
||||||
|
|
||||||
|
The service starts on `http://0.0.0.0:5000` by default.
|
||||||
|
|
||||||
|
## API Reference
|
||||||
|
|
||||||
|
### GET /health
|
||||||
|
|
||||||
|
Check if the service is running.
|
||||||
|
|
||||||
|
**Response:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": "healthy",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```bash
|
||||||
|
curl http://localhost:5000/health
|
||||||
|
```
|
||||||
|
|
||||||
|
### POST /extract
|
||||||
|
|
||||||
|
Extract invoice data from a base64-encoded PDF or XML file.
|
||||||
|
|
||||||
|
**Request (PDF):**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"pdf_base64": "JVBERi0xLjQKJeLjz9MK..."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Request (plain XML, e.g. XRechnung):**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"xml_base64": "PD94bWwgdmVyc2lvbj0iMS4wIi..."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Send exactly one of the two fields. The file type is detected from the content, so an XML file sent as `pdf_base64` works as well.
|
||||||
|
|
||||||
|
The response field `xml_syntax` tells which syntax was found (`"CII"` or `"UBL"`). `is_zugferd` is `true` whenever structured invoice data was found, regardless of format. For plain XML input, `pdf_text` is `null` and `extraction_meta.pages` is `0`.
|
||||||
|
|
||||||
|
`invoice_date` and `due_date` are always returned as `YYYY-MM-DD`, regardless of the source syntax. `buyer_reference` holds the buyer reference (BT-10), which is the Leitweg-ID on XRechnung invoices.
|
||||||
|
|
||||||
|
**Response (ZUGFeRD PDF):**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"is_zugferd": true,
|
||||||
|
"zugferd_profil": "EN16931",
|
||||||
|
"xml_syntax": "CII",
|
||||||
|
"xml_raw": "<?xml version=\"1.0\"...?>",
|
||||||
|
"xml_data": {
|
||||||
|
"invoice_number": "RE-2024-001",
|
||||||
|
"invoice_date": "2024-02-01",
|
||||||
|
"due_date": "2024-02-28",
|
||||||
|
"buyer_reference": null,
|
||||||
|
"supplier": {
|
||||||
|
"name": "Acme Corp",
|
||||||
|
"street": "Main Street 123",
|
||||||
|
"postal_code": "12345",
|
||||||
|
"city": "Berlin",
|
||||||
|
"country": "DE",
|
||||||
|
"vat_id": "DE123456789",
|
||||||
|
"tax_number": null,
|
||||||
|
"email": "billing@acme-corp.de"
|
||||||
|
},
|
||||||
|
"buyer": {
|
||||||
|
"name": "Customer GmbH",
|
||||||
|
"street": "Market Square 5",
|
||||||
|
"postal_code": "54321",
|
||||||
|
"city": "Hamburg",
|
||||||
|
"country": "DE",
|
||||||
|
"vat_id": "DE987654321",
|
||||||
|
"tax_number": null
|
||||||
|
},
|
||||||
|
"line_items": [
|
||||||
|
{
|
||||||
|
"position": 1,
|
||||||
|
"article_number": "ART-001",
|
||||||
|
"article_number_buyer": null,
|
||||||
|
"description": "Consulting Services",
|
||||||
|
"quantity": 10.0,
|
||||||
|
"unit": "HUR",
|
||||||
|
"unit_price": 100.0,
|
||||||
|
"line_total": 1000.0,
|
||||||
|
"vat_rate": 19.0,
|
||||||
|
"vat_amount": 190.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"totals": {
|
||||||
|
"line_total_sum": 1000.0,
|
||||||
|
"net": 1000.0,
|
||||||
|
"vat_total": 190.0,
|
||||||
|
"gross": 1190.0,
|
||||||
|
"vat_breakdown": [
|
||||||
|
{
|
||||||
|
"rate": 19.0,
|
||||||
|
"base": 1000.0,
|
||||||
|
"amount": 190.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"currency": "EUR",
|
||||||
|
"payment_terms": {
|
||||||
|
"iban": "DE89370400440532013000",
|
||||||
|
"bic": "COBADEFFXXX",
|
||||||
|
"account_holder": "Acme Corp"
|
||||||
|
},
|
||||||
|
"notes": "Payment due within 30 days"
|
||||||
|
},
|
||||||
|
"pdf_text": "Invoice RE-2024-001\nAcme Corp...",
|
||||||
|
"extraction_meta": {
|
||||||
|
"pages": 2,
|
||||||
|
"xml_attachment_name": "factur-x.xml",
|
||||||
|
"extraction_time_ms": 45
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response (Non-ZUGFeRD PDF):**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"is_zugferd": false,
|
||||||
|
"zugferd_profil": null,
|
||||||
|
"xml_syntax": null,
|
||||||
|
"xml_raw": null,
|
||||||
|
"xml_data": null,
|
||||||
|
"pdf_text": "Regular PDF content...",
|
||||||
|
"extraction_meta": {
|
||||||
|
"pages": 1,
|
||||||
|
"xml_attachment_name": null,
|
||||||
|
"extraction_time_ms": 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```bash
|
||||||
|
# Convert PDF to base64 and extract
|
||||||
|
PDF_BASE64=$(base64 -w 0 invoice.pdf)
|
||||||
|
|
||||||
|
curl -X POST http://localhost:5000/extract \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"pdf_base64\": \"$PDF_BASE64\"}"
|
||||||
|
|
||||||
|
# Plain XRechnung XML
|
||||||
|
curl -X POST http://localhost:5000/extract \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"xml_base64\": \"$(base64 -w 0 xrechnung.xml)\"}"
|
||||||
|
```
|
||||||
|
|
||||||
|
### POST /validate
|
||||||
|
|
||||||
|
Validate invoice data against business rules and regulatory requirements.
|
||||||
|
|
||||||
|
**Request:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"xml_data": {
|
||||||
|
"invoice_number": "RE-2024-001",
|
||||||
|
"invoice_date": "2024-02-01",
|
||||||
|
"due_date": "2024-02-28",
|
||||||
|
"supplier": {
|
||||||
|
"name": "Acme Corp",
|
||||||
|
"vat_id": "DE123456789"
|
||||||
|
},
|
||||||
|
"buyer": {
|
||||||
|
"name": "Customer GmbH",
|
||||||
|
"vat_id": "DE987654321"
|
||||||
|
},
|
||||||
|
"line_items": [
|
||||||
|
{
|
||||||
|
"position": 1,
|
||||||
|
"description": "Consulting Services",
|
||||||
|
"quantity": 10.0,
|
||||||
|
"unit": "HUR",
|
||||||
|
"unit_price": 100.0,
|
||||||
|
"line_total": 1000.0,
|
||||||
|
"vat_rate": 19.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"totals": {
|
||||||
|
"line_total_sum": 1000.0,
|
||||||
|
"net": 1000.0,
|
||||||
|
"vat_total": 190.0,
|
||||||
|
"gross": 1190.0,
|
||||||
|
"vat_breakdown": [
|
||||||
|
{
|
||||||
|
"rate": 19.0,
|
||||||
|
"base": 1000.0,
|
||||||
|
"amount": 190.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"pdf_text": "Invoice RE-2024-001\nNet 1000.00 VAT 190.00 Total: 1190.00 EUR",
|
||||||
|
"checks": ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"],
|
||||||
|
"profile": "EN16931"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`profile` is optional. Pass the `zugferd_profil` value from `/extract` to enable profile-specific rules (currently: the mandatory buyer reference on XRechnung invoices).
|
||||||
|
|
||||||
|
**Response:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"result": {
|
||||||
|
"is_valid": true,
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [],
|
||||||
|
"summary": {
|
||||||
|
"total_checks": 4,
|
||||||
|
"checks_passed": 4,
|
||||||
|
"checks_failed": 0,
|
||||||
|
"critical_errors": 0,
|
||||||
|
"warnings": 0
|
||||||
|
},
|
||||||
|
"validation_time_ms": 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```bash
|
||||||
|
curl -X POST http://localhost:5000/validate \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"xml_data": {"invoice_number": "RE-001", ...},
|
||||||
|
"checks": ["pflichtfelder", "betraege"]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Validation Checks
|
||||||
|
|
||||||
|
The service supports four validation checks:
|
||||||
|
|
||||||
|
### 1. pflichtfelder (Required Fields)
|
||||||
|
|
||||||
|
Validates that all critical invoice fields are present and non-empty:
|
||||||
|
|
||||||
|
- **Critical errors:** invoice_number, invoice_date, supplier.name, supplier.vat_id (or supplier.tax_number), buyer.name, totals.net, totals.gross, totals.vat_total (each must be non-zero), line_items array, and per line item: description, quantity, unit_price, line_total
|
||||||
|
- **Critical on XRechnung only:** buyer_reference (BT-10, the Leitweg-ID), when `profile` is an `XRECHNUNG_*` profile
|
||||||
|
- **Warnings:** due_date or payment_terms.iban present but empty, line item without vat_rate
|
||||||
|
|
||||||
|
A line item quantity of 0 is accepted on text-only positions whose line total is 0 (e.g. a delivery note reference). It is an error only when the line bills an amount.
|
||||||
|
|
||||||
|
### 2. betraege (Amount Calculations)
|
||||||
|
|
||||||
|
Verifies all monetary calculations are correct:
|
||||||
|
|
||||||
|
- Line total = quantity × unit_price (for each line item)
|
||||||
|
- totals.net = sum of all line totals
|
||||||
|
- VAT breakdown amount = base × (rate/100) (for each VAT entry)
|
||||||
|
- totals.vat_total = sum of VAT breakdown amounts
|
||||||
|
- totals.gross = totals.net + totals.vat_total
|
||||||
|
|
||||||
|
Uses a tolerance of 0.01 for floating-point comparison.
|
||||||
|
|
||||||
|
### 3. ustid (VAT ID Format)
|
||||||
|
|
||||||
|
Validates VAT ID format for supported countries:
|
||||||
|
|
||||||
|
- **Germany (DE):** DE followed by 9 digits (e.g., `DE123456789`)
|
||||||
|
- **Austria (AT):** ATU followed by 8 digits (e.g., `ATU12345678`)
|
||||||
|
- **Switzerland (CH):** CHE followed by 9 digits and MWST/TVA/IVA suffix (e.g., `CHE123456789MWST`)
|
||||||
|
|
||||||
|
### 4. pdf_abgleich (PDF Comparison)
|
||||||
|
|
||||||
|
Checks that the key values of the XML are also visible in the PDF, using the text passed in `pdf_text`:
|
||||||
|
|
||||||
|
- Invoice number (whitespace and case are ignored)
|
||||||
|
- Net total, VAT total and gross total, in the usual notations (`1234.56`, `1234,56`, `1.234,56`, `1,234.56`, space or apostrophe as thousands separator)
|
||||||
|
|
||||||
|
Every value that appears nowhere in the PDF text is returned as a warning (`pdf_mismatch`), never as an error.
|
||||||
|
|
||||||
|
The check searches the whole text and does not locate labelled fields, because PDF text extraction loses the layout. It therefore detects values that are missing from the PDF, but not a value that is printed under the wrong label. It is skipped when `pdf_text` is empty, as with plain XML input or scanned PDFs without a text layer.
|
||||||
|
|
||||||
|
## Invoice Profiles
|
||||||
|
|
||||||
|
The detected profile is returned in `zugferd_profil`. ZUGFeRD 2.x / Factur-X profiles:
|
||||||
|
|
||||||
|
| Profile | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| MINIMUM | Minimal profile with basic invoice data |
|
||||||
|
| BASIC | Basic profile for simple B2B invoicing |
|
||||||
|
| BASIC WL | Basic profile with additional buyer data |
|
||||||
|
| EN16931 | Full profile compliant with EN 16931 standard |
|
||||||
|
| EXTENDED | Extended profile with additional optional fields |
|
||||||
|
|
||||||
|
Other profiles are derived from the specification identifier (BT-24) in the XML:
|
||||||
|
|
||||||
|
| Value | Meaning |
|
||||||
|
|-------|---------|
|
||||||
|
| `XRECHNUNG_<version>` | XRechnung, e.g. `XRECHNUNG_3.0` (CII or UBL) |
|
||||||
|
| `PEPPOL_BIS_BILLING_<version>` | Peppol BIS Billing, e.g. `PEPPOL_BIS_BILLING_3.0` |
|
||||||
|
| `EN16931` | Plain EN 16931 invoice in UBL syntax |
|
||||||
|
| `UNKNOWN` | No specification identifier found |
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Environment Variables
|
||||||
|
|
||||||
|
The service supports the following environment variables:
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `HOST` | `0.0.0.0` | Host address to bind to |
|
||||||
|
| `PORT` | `5000` | Port to listen on |
|
||||||
|
| `LOG_LEVEL` | `INFO` | Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL); invalid values fall back to INFO |
|
||||||
|
|
||||||
|
`HOST` and `PORT` apply when the service is started via `python -m src.main` or the `zugferd-service` script (also available as `--host` / `--port` arguments). The Docker image starts uvicorn directly on `0.0.0.0:5000`.
|
||||||
|
|
||||||
|
### Docker Compose
|
||||||
|
|
||||||
|
The provided `docker-compose.yml` includes:
|
||||||
|
|
||||||
|
- Port mapping: `5000:5000`
|
||||||
|
- Health check endpoint
|
||||||
|
- Read-only source mount for development
|
||||||
|
- Restart policy: `unless-stopped`
|
||||||
|
|
||||||
|
### Nix
|
||||||
|
|
||||||
|
The flake provides:
|
||||||
|
|
||||||
|
- `packages.zugferd-service`: Production build
|
||||||
|
- `devShells.default`: Development shell with all dependencies
|
||||||
|
- `nixosModules.default`: NixOS module (see below)
|
||||||
|
|
||||||
|
## NixOS Deployment
|
||||||
|
|
||||||
|
The flake ships a NixOS module (`nix/module.nix`). Add the flake as input and enable the service:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ inputs, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ inputs.zugferd-service.nixosModules.default ];
|
||||||
|
|
||||||
|
services.zugferd-service = {
|
||||||
|
enable = true;
|
||||||
|
host = "127.0.0.1"; # default
|
||||||
|
port = 5000; # default
|
||||||
|
package = inputs.zugferd-service.packages.${pkgs.system}.zugferd-service;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The module runs the service as a hardened systemd unit (`DynamicUser`, `ProtectSystem=strict`, `ProtectHome`, `NoNewPrivileges`). `package` defaults to `pkgs.zugferd-service`, which only exists if you provide it through an overlay — otherwise set it as shown.
|
||||||
|
|
||||||
|
For production, consider adding:
|
||||||
|
|
||||||
|
- Reverse proxy (nginx/caddy) with HTTPS
|
||||||
|
- Authentication middleware
|
||||||
|
- Rate limiting
|
||||||
|
- Logging aggregation
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all tests
|
||||||
|
pytest
|
||||||
|
|
||||||
|
# Run with coverage
|
||||||
|
pytest --cov=src
|
||||||
|
|
||||||
|
# Run specific test file
|
||||||
|
pytest tests/test_extractor.py
|
||||||
|
```
|
||||||
|
|
||||||
|
CI (`.github/workflows/ci.yml`) runs the tests from the committed lockfile and builds the Docker image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv sync --extra dev --frozen
|
||||||
|
uv run --extra dev pytest -q
|
||||||
|
```
|
||||||
|
|
||||||
|
The test suite includes a regression sweep over all fixture invoices (`tests/test_fixture_sweep.py`) with an explicit catalogue of known gaps, and regression tests from anonymized real invoices (`tests/test_real_invoice_regressions.py`). See `tests/fixtures/MANIFEST.md` for the fixtures.
|
||||||
|
|
||||||
|
### Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
zugferd-service/
|
||||||
|
├── src/
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── main.py # FastAPI application and endpoints
|
||||||
|
│ ├── models.py # Pydantic models for requests/responses
|
||||||
|
│ ├── extractor.py # File detection, CII/ZUGFeRD XML extraction
|
||||||
|
│ ├── ubl_parser.py # UBL invoice/credit note parsing
|
||||||
|
│ ├── validator.py # Invoice validation logic
|
||||||
|
│ ├── pdf_parser.py # PDF text extraction
|
||||||
|
│ └── utils.py # Utility functions
|
||||||
|
├── tests/
|
||||||
|
│ ├── test_api.py # API endpoints
|
||||||
|
│ ├── test_extractor.py # PDF/CII extraction
|
||||||
|
│ ├── test_xml_formats.py # Plain XML, UBL, credit notes
|
||||||
|
│ ├── test_validator.py # Validation checks
|
||||||
|
│ ├── test_fixture_sweep.py # Sweep over all fixture PDFs
|
||||||
|
│ ├── test_real_invoice_regressions.py # Anonymized real invoices
|
||||||
|
│ ├── test_integration.py, test_models.py, test_pdf_parser.py, test_utils.py
|
||||||
|
│ └── fixtures/ # Test PDFs and XML files (see MANIFEST.md)
|
||||||
|
├── nix/module.nix # NixOS module
|
||||||
|
├── validator_schema.json # JSON schema of the /validate request (for LLM/OCR pipelines)
|
||||||
|
├── pyproject.toml # Project metadata and dependencies
|
||||||
|
├── uv.lock # Locked dependency versions (used by CI)
|
||||||
|
├── Dockerfile # Multi-stage Docker build
|
||||||
|
├── docker-compose.yml # Docker Compose configuration
|
||||||
|
└── flake.nix # Nix flake for reproducible builds
|
||||||
|
```
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
**Core:**
|
||||||
|
- fastapi>=0.109.0 - Web framework
|
||||||
|
- uvicorn>=0.27.0 - ASGI server
|
||||||
|
- pydantic>=2.5.0 - Data validation
|
||||||
|
- factur-x>=2.5 - ZUGFeRD/Factur-X library (lockfile pins 6.8)
|
||||||
|
- pypdf>=4.0.0 - PDF text extraction
|
||||||
|
- lxml>=5.0.0 - XML processing
|
||||||
|
|
||||||
|
**Development:**
|
||||||
|
- pytest>=8.0.0 - Testing framework
|
||||||
|
- pytest-asyncio>=0.23.0 - Async test support
|
||||||
|
- httpx>=0.27.0 - HTTP client for testing
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
**Service fails to start with "Address already in use"**
|
||||||
|
|
||||||
|
Change the port:
|
||||||
|
```bash
|
||||||
|
# Docker
|
||||||
|
docker run -p 8000:5000 zugferd-service
|
||||||
|
|
||||||
|
# Nix/Python
|
||||||
|
PORT=8000 python -m src.main
|
||||||
|
```
|
||||||
|
|
||||||
|
**Extraction returns "is_zugferd: false"**
|
||||||
|
|
||||||
|
- Verify the PDF contains an embedded invoice XML attachment
|
||||||
|
- Check that the file is not password-protected
|
||||||
|
- Ensure the file is a valid PDF (not corrupt)
|
||||||
|
|
||||||
|
**Validation fails with "missing_required" errors**
|
||||||
|
|
||||||
|
Check that all required fields are present:
|
||||||
|
- invoice_number
|
||||||
|
- invoice_date (YYYY-MM-DD format)
|
||||||
|
- supplier.name and supplier.vat_id (or supplier.tax_number — EN 16931 BR-CO-26 requires one of both)
|
||||||
|
- buyer.name
|
||||||
|
- Non-zero totals (net, gross, vat_total)
|
||||||
|
- At least one line item with description, unit_price and line_total; quantity may only be 0 when the line total is 0
|
||||||
|
|
||||||
|
**VAT ID validation fails**
|
||||||
|
|
||||||
|
Verify the VAT ID format:
|
||||||
|
- German: `DE` + 9 digits
|
||||||
|
- Austrian: `ATU` + 8 digits
|
||||||
|
- Swiss: `CHE` + 9 digits + `MWST`/`TVA`/`IVA`
|
||||||
|
|
||||||
|
**Docker build is slow**
|
||||||
|
|
||||||
|
Use BuildKit for faster builds:
|
||||||
|
```bash
|
||||||
|
DOCKER_BUILDKIT=1 docker build -t zugferd-service .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Error Codes
|
||||||
|
|
||||||
|
| Error Code | Description |
|
||||||
|
|------------|-------------|
|
||||||
|
| `invalid_base64` | Invalid base64 encoding in request |
|
||||||
|
| `file_too_large` | File (PDF or XML) exceeds 10MB limit |
|
||||||
|
| `password_protected_pdf` | PDF is password-protected |
|
||||||
|
| `invalid_pdf` | File is not a valid PDF |
|
||||||
|
| `corrupt_pdf` | PDF file is corrupted or unreadable |
|
||||||
|
| `invalid_xml` | Plain XML input is not well-formed |
|
||||||
|
| `unsupported_xml_format` | XML is well-formed but not a CII or UBL invoice |
|
||||||
|
|
||||||
|
Extraction errors are returned with HTTP 400. A request without a file, or with both `pdf_base64` and `xml_base64`, is rejected with HTTP 422.
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
Service modules log structured JSON at the level set by `LOG_LEVEL`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"timestamp": "2024-02-01T10:30:00Z",
|
||||||
|
"level": "ERROR",
|
||||||
|
"message": "Internal error: ..."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Currently only internal errors (HTTP 500) are logged at the default level; `DEBUG` adds details about how an embedded XML attachment was found. Requests are logged by uvicorn in its own format.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
For issues, questions, or contributions, please refer to the project repository.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
zugferd-service:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
volumes:
|
||||||
|
- ./src:/app/src:ro
|
||||||
|
environment:
|
||||||
|
- LOG_LEVEL=INFO
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 10s
|
||||||
|
restart: unless-stopped
|
||||||
Generated
+170
@@ -0,0 +1,170 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"agents": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1771353084,
|
||||||
|
"narHash": "sha256-QsrA7+md+bw1ACQeuvDn2mE5X11gM0hqVGse58spedA=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "5b204c95e419eb75b04c5f85e1bd56ed56a5abe4",
|
||||||
|
"revCount": 60,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.m3ta.dev/m3tam3re/AGENTS"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.m3ta.dev/m3tam3re/AGENTS"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"m3ta-nixpkgs": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"nixpkgs-master": "nixpkgs-master",
|
||||||
|
"opencode": "opencode"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1771355771,
|
||||||
|
"narHash": "sha256-Uhq6aMCuzKqC2UIAbEkx+LQS77MGEVDEL7zpfoW6VB8=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "dc206b13e256941298868d559fff9be31d7e0e34",
|
||||||
|
"revCount": 119,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.m3ta.dev/m3tam3re/nixpkgs"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.m3ta.dev/m3tam3re/nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1770562336,
|
||||||
|
"narHash": "sha256-ub1gpAONMFsT/GU2hV6ZWJjur8rJ6kKxdm9IlCT0j84=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d6c71932130818840fc8fe9509cf50be8c64634f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-beads": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1794042290,
|
||||||
|
"narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-master": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1770917518,
|
||||||
|
"narHash": "sha256-XSwv/tVrNo/L8SPH8Lx9xZH1PrZd/3Z3J/0SH7Xertg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "3f4a3c08f2f318ee29fc8a2689f390071a94aaf0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "master",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1770115704,
|
||||||
|
"narHash": "sha256-KHFT9UWOF2yRPlAnSXQJh6uVcgNcWlFqqiAZ7OVlHNc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "e6eae2ee2110f3d31110d5c222cd395303343b08",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"opencode": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"m3ta-nixpkgs",
|
||||||
|
"nixpkgs-master"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1771271829,
|
||||||
|
"narHash": "sha256-43vPMyO7DsAgKrh0Wmt7jLDYCWUsaj30nBITreyYgX8=",
|
||||||
|
"owner": "anomalyco",
|
||||||
|
"repo": "opencode",
|
||||||
|
"rev": "d8c25bfeb44771cc3a3ba17bf8de6ad2add9de2c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "anomalyco",
|
||||||
|
"ref": "v1.2.6",
|
||||||
|
"repo": "opencode",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"agents": "agents",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"m3ta-nixpkgs": "m3ta-nixpkgs",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"nixpkgs-beads": "nixpkgs-beads"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
description = "ZUGFeRD REST API Service";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
# Newer nixpkgs only for the beads issue tracker (bd >= 1.0): the pinned
|
||||||
|
# nixpkgs ships bd 0.42, which cannot read the .beads database.
|
||||||
|
# Drop this input once nixpkgs itself is updated.
|
||||||
|
nixpkgs-beads.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
|
||||||
|
agents = {
|
||||||
|
url = "git+https://code.m3ta.dev/m3tam3re/AGENTS";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
nixpkgs-beads,
|
||||||
|
flake-utils,
|
||||||
|
m3ta-nixpkgs,
|
||||||
|
agents,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
nixosModules.default = import ./nix/module.nix;
|
||||||
|
}
|
||||||
|
// flake-utils.lib.eachDefaultSystem (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
pythonPackages = pkgs.python311Packages;
|
||||||
|
|
||||||
|
# factur-x package - not available in nixpkgs, so we package it inline
|
||||||
|
factur-x = pythonPackages.buildPythonPackage rec {
|
||||||
|
pname = "factur_x";
|
||||||
|
# Keep in sync with uv.lock (CI and Docker install from the lockfile)
|
||||||
|
version = "6.8";
|
||||||
|
format = "pyproject";
|
||||||
|
|
||||||
|
src = pythonPackages.fetchPypi {
|
||||||
|
inherit pname version;
|
||||||
|
hash = "sha256-0AcenHIXZm6tAl9EJ2Xh4u9KC6jiZ3urZAQn6wi7s0k=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pythonPackages; [
|
||||||
|
hatchling
|
||||||
|
hatch-requirements-txt
|
||||||
|
hatch-vcs
|
||||||
|
];
|
||||||
|
|
||||||
|
dependencies = with pythonPackages; [pypdf lxml python-stdnum requests];
|
||||||
|
|
||||||
|
pythonRelaxDeps = true;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Python library to generate and read Factur-X invoices";
|
||||||
|
license = pkgs.lib.licenses.mit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
zugferd-service = pythonPackages.buildPythonApplication {
|
||||||
|
pname = "zugferd-service";
|
||||||
|
version = "1.0.0";
|
||||||
|
pyproject = true;
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
pythonRelaxDeps = true;
|
||||||
|
|
||||||
|
build-system = [pythonPackages.hatchling];
|
||||||
|
|
||||||
|
dependencies = with pythonPackages; [
|
||||||
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
pydantic
|
||||||
|
python-multipart
|
||||||
|
factur-x
|
||||||
|
pypdf
|
||||||
|
lxml
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeCheckInputs = with pythonPackages; [
|
||||||
|
pytestCheckHook
|
||||||
|
pytest-asyncio
|
||||||
|
httpx
|
||||||
|
];
|
||||||
|
|
||||||
|
passthru = {mainProgram = "zugferd-service";};
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "REST API for ZUGFeRD invoice extraction";
|
||||||
|
license = pkgs.lib.licenses.mit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
m3taLib = m3ta-nixpkgs.lib.x86_64-linux;
|
||||||
|
rules = m3taLib.opencode-rules.mkOpencodeRules {
|
||||||
|
inherit agents;
|
||||||
|
languages = ["python"];
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
packages.default = zugferd-service;
|
||||||
|
packages.zugferd-service = zugferd-service;
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
(pkgs.python311.withPackages (ps:
|
||||||
|
with ps; [
|
||||||
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
pydantic
|
||||||
|
python-multipart
|
||||||
|
pypdf
|
||||||
|
lxml
|
||||||
|
pytest
|
||||||
|
pytest-asyncio
|
||||||
|
httpx
|
||||||
|
factur-x
|
||||||
|
# factur-x - install via pip if not available
|
||||||
|
]))
|
||||||
|
pkgs.python311Packages.pip
|
||||||
|
# Issue tracker (bd); issues live in .beads/
|
||||||
|
nixpkgs-beads.legacyPackages.${system}.beads
|
||||||
|
];
|
||||||
|
|
||||||
|
inherit (rules) instructions;
|
||||||
|
shellHook = ''
|
||||||
|
${rules.shellHook}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let cfg = config.services.zugferd-service;
|
||||||
|
in {
|
||||||
|
options.services.zugferd-service = {
|
||||||
|
enable = mkEnableOption "ZUGFeRD REST API service";
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
default = 5000;
|
||||||
|
description = "Port to listen on";
|
||||||
|
};
|
||||||
|
|
||||||
|
host = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
description = "Host to bind to";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.zugferd-service;
|
||||||
|
description = "Package to use for the service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
systemd.services.zugferd-service = {
|
||||||
|
description = "ZUGFeRD REST API Service";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart =
|
||||||
|
"${cfg.package}/bin/zugferd-service --host ${cfg.host} --port ${
|
||||||
|
toString cfg.port
|
||||||
|
}";
|
||||||
|
Restart = "on-failure";
|
||||||
|
DynamicUser = true;
|
||||||
|
NoNewPrivileges = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
ProtectHome = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "zugferd-service"
|
||||||
|
version = "1.0.0"
|
||||||
|
description = "REST API for ZUGFeRD invoice extraction and validation"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = [
|
||||||
|
"fastapi>=0.109.0",
|
||||||
|
"uvicorn>=0.27.0",
|
||||||
|
"python-multipart>=0.0.6",
|
||||||
|
"factur-x>=2.5",
|
||||||
|
"pypdf>=4.0.0",
|
||||||
|
"pydantic>=2.5.0",
|
||||||
|
"lxml>=5.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
"pytest>=8.0.0",
|
||||||
|
"pytest-asyncio>=0.23.0",
|
||||||
|
"httpx>=0.27.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
zugferd-service = "src.main:run"
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.wheel]
|
||||||
|
packages = ["src"]
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
asyncio_mode = "auto"
|
||||||
|
testpaths = ["tests"]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
"""ZUGFeRD Service Package."""
|
||||||
|
|
||||||
|
__version__ = "1.0.0"
|
||||||
@@ -0,0 +1,842 @@
|
|||||||
|
"""E-invoice extractor.
|
||||||
|
|
||||||
|
Extracts structured invoice data from EN 16931 e-invoices in both syntaxes:
|
||||||
|
|
||||||
|
- CII (UN/CEFACT Cross Industry Invoice): ZUGFeRD 2.x / Factur-X profiles
|
||||||
|
MINIMUM, BASIC, BASIC WL, EN16931, EXTENDED and XRechnung CII
|
||||||
|
- UBL 2.1 (Invoice and CreditNote): XRechnung UBL, Peppol BIS Billing
|
||||||
|
|
||||||
|
Input is either a hybrid PDF with embedded XML or the plain XML file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
|
from facturx import get_flavor, get_level, get_xml_from_pdf
|
||||||
|
import lxml.etree as etree
|
||||||
|
from pypdf import PdfReader
|
||||||
|
from pypdf.errors import PdfReadError, PyPdfError
|
||||||
|
|
||||||
|
from src.models import (
|
||||||
|
Buyer,
|
||||||
|
ExtractionMeta,
|
||||||
|
ExtractResponse,
|
||||||
|
LineItem,
|
||||||
|
PaymentTerms,
|
||||||
|
Supplier,
|
||||||
|
Totals,
|
||||||
|
VatBreakdown,
|
||||||
|
XmlData,
|
||||||
|
)
|
||||||
|
from src.ubl_parser import UBL_NAMESPACES, is_ubl_root, parse_ubl_xml
|
||||||
|
|
||||||
|
|
||||||
|
MAX_FILE_SIZE = 10 * 1024 * 1024
|
||||||
|
|
||||||
|
CII_ROOT_TAG = (
|
||||||
|
"{urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100}"
|
||||||
|
"CrossIndustryInvoice"
|
||||||
|
)
|
||||||
|
|
||||||
|
NAMESPACES = {
|
||||||
|
"rsm": "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100",
|
||||||
|
"ram": "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100",
|
||||||
|
"udt": "urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractionError(Exception):
|
||||||
|
"""Error during PDF extraction."""
|
||||||
|
|
||||||
|
def __init__(self, error_code: str, message: str, details: str = ""):
|
||||||
|
self.error_code = error_code
|
||||||
|
self.message = message
|
||||||
|
self.details = details
|
||||||
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_xml(xml_bytes: bytes) -> etree._Element:
|
||||||
|
"""Parse untrusted invoice XML without resolving entities or DTDs.
|
||||||
|
|
||||||
|
Invoice XML arrives from outside (API upload or PDF attachment), so
|
||||||
|
external entities and network access are disabled (XXE protection).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_bytes: Raw XML content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
XML root element
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
etree.XMLSyntaxError: If the content is not well-formed XML
|
||||||
|
"""
|
||||||
|
parser = etree.XMLParser(resolve_entities=False, no_network=True, load_dtd=False)
|
||||||
|
return etree.fromstring(xml_bytes, parser=parser)
|
||||||
|
|
||||||
|
|
||||||
|
def extract_text_from_pdf(pdf_bytes: bytes) -> str:
|
||||||
|
"""Extract text from PDF using pypdf.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Extracted text from all pages
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
pdf_stream = io.BytesIO(pdf_bytes)
|
||||||
|
reader = PdfReader(pdf_stream)
|
||||||
|
text_parts = []
|
||||||
|
for page in reader.pages:
|
||||||
|
text = page.extract_text()
|
||||||
|
if text:
|
||||||
|
text_parts.append(text)
|
||||||
|
return "\n".join(text_parts)
|
||||||
|
except (PdfReadError, PyPdfError) as e:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="corrupt_pdf", message="Failed to read PDF", details=str(e)
|
||||||
|
) from e
|
||||||
|
|
||||||
|
|
||||||
|
def parse_supplier(xml_root: etree._Element) -> Supplier:
|
||||||
|
"""Parse supplier information from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Supplier model
|
||||||
|
"""
|
||||||
|
name = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:Name/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
street = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:LineOne/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
postal_code = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:PostcodeCode/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
city = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:CityName/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
country = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:CountryID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_id = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:SpecifiedTaxRegistration/"
|
||||||
|
"ram:ID[@schemeID='VA']/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
tax_number = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:SpecifiedTaxRegistration/"
|
||||||
|
"ram:ID[@schemeID='FC']/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
email = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:URIUniversalCommunication/ram:URIID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
# Fallback: email address from the seller's defined trade contact (BT-42)
|
||||||
|
if not email:
|
||||||
|
email = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/"
|
||||||
|
"ram:DefinedTradeContact/ram:EmailURIUniversalCommunication/ram:URIID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Supplier(
|
||||||
|
name=name[0] if name else "",
|
||||||
|
street=street[0] if street else None,
|
||||||
|
postal_code=postal_code[0] if postal_code else None,
|
||||||
|
city=city[0] if city else None,
|
||||||
|
country=country[0] if country else None,
|
||||||
|
vat_id=vat_id[0] if vat_id else None,
|
||||||
|
tax_number=tax_number[0] if tax_number else None,
|
||||||
|
email=email[0] if email else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_buyer(xml_root: etree._Element) -> Buyer:
|
||||||
|
"""Parse buyer information from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Buyer model
|
||||||
|
"""
|
||||||
|
name = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/ram:Name/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
street = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:LineOne/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
postal_code = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:PostcodeCode/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
city = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:CityName/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
country = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/"
|
||||||
|
"ram:PostalTradeAddress/ram:CountryID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_id = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/ram:SpecifiedTaxRegistration/"
|
||||||
|
"ram:ID[@schemeID='VA']/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
tax_number = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/ram:SpecifiedTaxRegistration/"
|
||||||
|
"ram:ID[@schemeID='FC']/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Buyer(
|
||||||
|
name=name[0] if name else "",
|
||||||
|
street=street[0] if street else None,
|
||||||
|
postal_code=postal_code[0] if postal_code else None,
|
||||||
|
city=city[0] if city else None,
|
||||||
|
country=country[0] if country else None,
|
||||||
|
vat_id=vat_id[0] if vat_id else None,
|
||||||
|
tax_number=tax_number[0] if tax_number else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_line_items(xml_root: etree._Element) -> list[LineItem]:
|
||||||
|
"""Parse line items from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of LineItem models
|
||||||
|
"""
|
||||||
|
line_items_nodes = xml_root.xpath(
|
||||||
|
"//ram:IncludedSupplyChainTradeLineItem", namespaces=NAMESPACES
|
||||||
|
)
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for idx, item_node in enumerate(line_items_nodes, start=1):
|
||||||
|
position = idx
|
||||||
|
article_number = item_node.xpath(
|
||||||
|
"./ram:SpecifiedTradeProduct/ram:SellerAssignedID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
article_number_buyer = item_node.xpath(
|
||||||
|
"./ram:SpecifiedTradeProduct/ram:BuyerAssignedID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
description = item_node.xpath(
|
||||||
|
"./ram:SpecifiedTradeProduct/ram:Name/text()", namespaces=NAMESPACES
|
||||||
|
)
|
||||||
|
quantity = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeDelivery/ram:BilledQuantity/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
unit_code = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeDelivery/ram:BilledQuantity/@unitCode",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
unit_price = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
basis_quantity = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/"
|
||||||
|
"ram:BasisQuantity/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
line_total = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/"
|
||||||
|
"ram:LineTotalAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_rate = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:RateApplicablePercent/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_amount = item_node.xpath(
|
||||||
|
"./ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:CalculatedAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
unit = unit_code[0] if unit_code else "Stück"
|
||||||
|
|
||||||
|
# Basis quantity (BT-149): charge amount applies to N units (e.g. price per 100)
|
||||||
|
effective_unit_price = float(unit_price[0]) if unit_price else None
|
||||||
|
if effective_unit_price is not None and basis_quantity:
|
||||||
|
base = float(basis_quantity[0])
|
||||||
|
if base > 0:
|
||||||
|
effective_unit_price = effective_unit_price / base
|
||||||
|
|
||||||
|
items.append(
|
||||||
|
LineItem(
|
||||||
|
position=position,
|
||||||
|
article_number=article_number[0] if article_number else None,
|
||||||
|
article_number_buyer=article_number_buyer[0]
|
||||||
|
if article_number_buyer
|
||||||
|
else None,
|
||||||
|
description=description[0] if description else "",
|
||||||
|
quantity=float(quantity[0]) if quantity else 0.0,
|
||||||
|
unit=unit,
|
||||||
|
unit_price=effective_unit_price,
|
||||||
|
line_total=float(line_total[0]) if line_total else None,
|
||||||
|
vat_rate=float(vat_rate[0]) if vat_rate else None,
|
||||||
|
vat_amount=float(vat_amount[0]) if vat_amount else None,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def parse_totals(xml_root: etree._Element) -> Totals:
|
||||||
|
"""Parse invoice totals from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Totals model
|
||||||
|
"""
|
||||||
|
line_total_sum = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:LineTotalAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
net = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxBasisTotalAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_total = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxTotalAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
gross = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:GrandTotalAmount/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
vat_breakdown_nodes = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
vat_breakdown = []
|
||||||
|
|
||||||
|
for vat_node in vat_breakdown_nodes:
|
||||||
|
rate = vat_node.xpath(
|
||||||
|
"./ram:RateApplicablePercent/text()", namespaces=NAMESPACES
|
||||||
|
)
|
||||||
|
base = vat_node.xpath("./ram:BasisAmount/text()", namespaces=NAMESPACES)
|
||||||
|
amount = vat_node.xpath("./ram:CalculatedAmount/text()", namespaces=NAMESPACES)
|
||||||
|
|
||||||
|
if rate and base and amount:
|
||||||
|
vat_breakdown.append(
|
||||||
|
VatBreakdown(
|
||||||
|
rate=float(rate[0]),
|
||||||
|
base=float(base[0]),
|
||||||
|
amount=float(amount[0]),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return Totals(
|
||||||
|
line_total_sum=float(line_total_sum[0]) if line_total_sum else 0.0,
|
||||||
|
net=float(net[0]) if net else 0.0,
|
||||||
|
vat_total=float(vat_total[0]) if vat_total else 0.0,
|
||||||
|
gross=float(gross[0]) if gross else 0.0,
|
||||||
|
vat_breakdown=vat_breakdown,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_payment_terms(xml_root: etree._Element) -> PaymentTerms | None:
|
||||||
|
"""Parse payment terms from XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
PaymentTerms model or None
|
||||||
|
"""
|
||||||
|
iban = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialAccount/"
|
||||||
|
"ram:IBANID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
bic = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialInstitution/"
|
||||||
|
"ram:BICID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
account_holder = xml_root.xpath(
|
||||||
|
"//ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialAccount/"
|
||||||
|
"ram:ProprietaryAccountName/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not (iban or bic or account_holder):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return PaymentTerms(
|
||||||
|
iban=iban[0] if iban else None,
|
||||||
|
bic=bic[0] if bic else None,
|
||||||
|
account_holder=account_holder[0] if account_holder else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_cii_date(value: str) -> str:
|
||||||
|
"""Convert a CII date in format 102 (YYYYMMDD) to ISO notation.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value: Date string from a udt:DateTimeString element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Date as YYYY-MM-DD; values that are not eight digits are returned
|
||||||
|
stripped but otherwise unchanged
|
||||||
|
"""
|
||||||
|
value = value.strip()
|
||||||
|
if re.fullmatch(r"\d{8}", value):
|
||||||
|
return f"{value[:4]}-{value[4:6]}-{value[6:]}"
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_zugferd_xml(xml_bytes: bytes) -> XmlData:
|
||||||
|
"""Parse ZUGFeRD XML bytes to structured XmlData.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_bytes: Raw XML bytes from PDF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
XmlData model with all invoice fields
|
||||||
|
"""
|
||||||
|
xml_root = _parse_xml(xml_bytes)
|
||||||
|
|
||||||
|
invoice_number = xml_root.xpath(
|
||||||
|
"//rsm:ExchangedDocument/ram:ID/text()", namespaces=NAMESPACES
|
||||||
|
)
|
||||||
|
invoice_date = xml_root.xpath(
|
||||||
|
"//rsm:ExchangedDocument/ram:IssueDateTime/udt:DateTimeString[@format='102']/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
# BT-9 payment due date
|
||||||
|
due_date = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradePaymentTerms/"
|
||||||
|
"ram:DueDateDateTime/udt:DateTimeString/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
# BT-10 buyer reference (Leitweg-ID on XRechnung invoices)
|
||||||
|
buyer_reference = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeAgreement/ram:BuyerReference/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
notes = xml_root.xpath(
|
||||||
|
"//rsm:ExchangedDocument/ram:IncludedNote/ram:Content/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
currency = xml_root.xpath(
|
||||||
|
"//ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
|
||||||
|
return XmlData(
|
||||||
|
invoice_number=invoice_number[0] if invoice_number else "",
|
||||||
|
invoice_date=_normalize_cii_date(invoice_date[0]) if invoice_date else "",
|
||||||
|
due_date=_normalize_cii_date(due_date[0]) if due_date else None,
|
||||||
|
buyer_reference=(buyer_reference[0].strip() or None)
|
||||||
|
if buyer_reference
|
||||||
|
else None,
|
||||||
|
supplier=parse_supplier(xml_root),
|
||||||
|
buyer=parse_buyer(xml_root),
|
||||||
|
line_items=parse_line_items(xml_root),
|
||||||
|
totals=parse_totals(xml_root),
|
||||||
|
currency=currency[0] if currency else "EUR",
|
||||||
|
payment_terms=parse_payment_terms(xml_root),
|
||||||
|
notes=notes[0] if notes else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_pdf_page_count(pdf_bytes: bytes) -> int:
|
||||||
|
"""Get number of pages in PDF.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Number of pages
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
pdf_stream = io.BytesIO(pdf_bytes)
|
||||||
|
reader = PdfReader(pdf_stream)
|
||||||
|
return len(reader.pages)
|
||||||
|
except (PdfReadError, PyPdfError):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def _find_xml_attachment_fallback(pdf_bytes: bytes) -> tuple[str | None, bytes | None]:
|
||||||
|
"""Find XML attachment by MIME type or filename extension (fallback mechanism).
|
||||||
|
|
||||||
|
This handles XRechnung and other XML-based invoices with non-standard
|
||||||
|
filenames (e.g., 'xrechnung.xml' instead of 'factur-x.xml') that the
|
||||||
|
factur-x library does not recognize.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple of (filename, xml_bytes) or (None, None) if not found.
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
pdf_stream = io.BytesIO(pdf_bytes)
|
||||||
|
reader = PdfReader(pdf_stream)
|
||||||
|
except (PdfReadError, PyPdfError) as e:
|
||||||
|
logger.debug(
|
||||||
|
"Failed to read PDF for XML attachment fallback search: %s",
|
||||||
|
str(e),
|
||||||
|
)
|
||||||
|
return (None, None)
|
||||||
|
except Exception as e:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="fallback_pdf_read_error",
|
||||||
|
message="Unexpected error reading PDF for XML attachment fallback",
|
||||||
|
details=str(e),
|
||||||
|
) from e
|
||||||
|
|
||||||
|
# First pass: check MIME type via Subtype in Filespec or by content type
|
||||||
|
# Common XML MIME types: application/xml, text/xml
|
||||||
|
for att in reader.attachment_list:
|
||||||
|
if not att.content:
|
||||||
|
continue
|
||||||
|
|
||||||
|
subtype = getattr(att, "subtype", None) or getattr(att, "mediatype", None)
|
||||||
|
|
||||||
|
if subtype and ("xml" in str(subtype).lower() or "xml" in att.name.lower()):
|
||||||
|
try:
|
||||||
|
_parse_xml(att.content)
|
||||||
|
logger.debug(
|
||||||
|
"Found XML attachment via MIME fallback: %s",
|
||||||
|
att.name,
|
||||||
|
)
|
||||||
|
return (att.name, att.content)
|
||||||
|
except etree.XMLSyntaxError:
|
||||||
|
logger.debug(
|
||||||
|
"Attachment '%s' has XML MIME but invalid XML content",
|
||||||
|
att.name,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Second pass: check by filename extension for any XML file
|
||||||
|
for att in reader.attachment_list:
|
||||||
|
if not att.content:
|
||||||
|
continue
|
||||||
|
if att.name.lower().endswith(".xml"):
|
||||||
|
try:
|
||||||
|
_parse_xml(att.content)
|
||||||
|
logger.debug(
|
||||||
|
"Found XML attachment via extension fallback: %s",
|
||||||
|
att.name,
|
||||||
|
)
|
||||||
|
return (att.name, att.content)
|
||||||
|
except etree.XMLSyntaxError:
|
||||||
|
logger.debug(
|
||||||
|
"Attachment '%s' has .xml extension but invalid XML content",
|
||||||
|
att.name,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
|
|
||||||
|
def _profile_from_urn(urn: str) -> str:
|
||||||
|
"""Extract a short profile name from a Factur-X/ZUGFeRD URN.
|
||||||
|
|
||||||
|
Falls back to the last segment of the URN after '#', or 'unknown'.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
urn: The full profile URN (e.g.
|
||||||
|
'urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0')
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Short profile name (e.g. 'xrechnung_3.0')
|
||||||
|
"""
|
||||||
|
if not urn:
|
||||||
|
return "unknown"
|
||||||
|
return urn.rsplit("#", maxsplit=1)[-1].rsplit(":", maxsplit=1)[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def _profile_from_customization_id(urn: str) -> str:
|
||||||
|
"""Derive a readable profile name from a UBL CustomizationID (BT-24).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
urn: The specification identifier (e.g.
|
||||||
|
'urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0')
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Short profile name (e.g. 'xrechnung_3.0', 'peppol_bis_billing_3.0',
|
||||||
|
'en16931'), or 'unknown'
|
||||||
|
"""
|
||||||
|
lowered = urn.strip().lower()
|
||||||
|
|
||||||
|
xrechnung = re.search(r"xrechnung_(\d+(?:\.\d+)*)", lowered)
|
||||||
|
if xrechnung:
|
||||||
|
return f"xrechnung_{xrechnung.group(1)}"
|
||||||
|
|
||||||
|
peppol = re.search(r"peppol.*billing:(\d+(?:\.\d+)*)", lowered)
|
||||||
|
if peppol:
|
||||||
|
return f"peppol_bis_billing_{peppol.group(1)}"
|
||||||
|
|
||||||
|
if lowered == "urn:cen.eu:en16931:2017":
|
||||||
|
return "en16931"
|
||||||
|
|
||||||
|
return _profile_from_urn(lowered)
|
||||||
|
|
||||||
|
|
||||||
|
def _interpret_invoice_xml(xml_bytes: bytes) -> tuple[str, str, XmlData]:
|
||||||
|
"""Detect syntax and profile of invoice XML and parse it.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_bytes: Raw invoice XML (CII or UBL)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple of (syntax, profile, parsed data); syntax is 'CII' or 'UBL'
|
||||||
|
"""
|
||||||
|
xml_root = _parse_xml(xml_bytes)
|
||||||
|
|
||||||
|
if is_ubl_root(xml_root):
|
||||||
|
urn_nodes = xml_root.xpath(
|
||||||
|
"./cbc:CustomizationID/text()", namespaces=UBL_NAMESPACES
|
||||||
|
)
|
||||||
|
urn = urn_nodes[0] if urn_nodes else ""
|
||||||
|
return "UBL", _profile_from_customization_id(urn), parse_ubl_xml(xml_root)
|
||||||
|
|
||||||
|
# GuidelineSpecifiedDocumentContextParameter uses ram: namespace
|
||||||
|
urn_nodes = xml_root.xpath(
|
||||||
|
"//rsm:ExchangedDocumentContext/"
|
||||||
|
"ram:GuidelineSpecifiedDocumentContextParameter/ram:ID/text()",
|
||||||
|
namespaces=NAMESPACES,
|
||||||
|
)
|
||||||
|
urn = urn_nodes[0] if urn_nodes else ""
|
||||||
|
|
||||||
|
# XRechnung first: depending on its version, factur-x either rejects the
|
||||||
|
# XRechnung URN or reports it as plain EN16931.
|
||||||
|
xrechnung = re.search(r"xrechnung_(\d+(?:\.\d+)*)", urn.lower())
|
||||||
|
if xrechnung:
|
||||||
|
level = f"xrechnung_{xrechnung.group(1)}"
|
||||||
|
else:
|
||||||
|
flavor = get_flavor(xml_root)
|
||||||
|
try:
|
||||||
|
level = get_level(xml_root, flavor)
|
||||||
|
except ValueError:
|
||||||
|
level = _profile_from_urn(urn)
|
||||||
|
|
||||||
|
return "CII", level, parse_zugferd_xml(xml_bytes)
|
||||||
|
|
||||||
|
|
||||||
|
def _xml_to_text(xml_bytes: bytes) -> str:
|
||||||
|
"""Decode raw XML bytes to a string for the xml_raw response field.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_bytes: Raw XML content in any encoding XML allows
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
XML document as string
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return xml_bytes.decode("utf-8-sig")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return etree.tostring(_parse_xml(xml_bytes), encoding="unicode")
|
||||||
|
|
||||||
|
|
||||||
|
def _check_file_size(data: bytes) -> None:
|
||||||
|
"""Reject uploads above the size limit.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data: Raw file content
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ExtractionError: If the file exceeds 10MB
|
||||||
|
"""
|
||||||
|
if len(data) > MAX_FILE_SIZE:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="file_too_large",
|
||||||
|
message="File exceeds 10MB limit",
|
||||||
|
details=f"Size: {len(data)} bytes",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def extract_from_xml(xml_bytes: bytes) -> ExtractResponse:
|
||||||
|
"""Extract invoice data from a plain e-invoice XML file.
|
||||||
|
|
||||||
|
Handles XRechnung and other EN 16931 invoices delivered without a PDF,
|
||||||
|
in CII or UBL syntax.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_bytes: Raw XML file content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ExtractResponse with is_zugferd, profile, xml_syntax and xml_data
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ExtractionError: For malformed XML or unsupported document types
|
||||||
|
"""
|
||||||
|
start_time = time.time()
|
||||||
|
_check_file_size(xml_bytes)
|
||||||
|
|
||||||
|
try:
|
||||||
|
xml_root = _parse_xml(xml_bytes)
|
||||||
|
except etree.XMLSyntaxError as e:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="invalid_xml", message="Invalid XML file", details=str(e)
|
||||||
|
) from e
|
||||||
|
|
||||||
|
if not is_ubl_root(xml_root) and xml_root.tag != CII_ROOT_TAG:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="unsupported_xml_format",
|
||||||
|
message="XML is not a supported e-invoice (CII or UBL)",
|
||||||
|
details=f"Root element: {xml_root.tag}",
|
||||||
|
)
|
||||||
|
|
||||||
|
syntax, level, xml_data = _interpret_invoice_xml(xml_bytes)
|
||||||
|
|
||||||
|
return ExtractResponse(
|
||||||
|
is_zugferd=True,
|
||||||
|
zugferd_profil=level.upper(),
|
||||||
|
xml_syntax=syntax,
|
||||||
|
xml_raw=_xml_to_text(xml_bytes),
|
||||||
|
xml_data=xml_data,
|
||||||
|
pdf_text=None,
|
||||||
|
extraction_meta=ExtractionMeta(
|
||||||
|
pages=0,
|
||||||
|
xml_attachment_name=None,
|
||||||
|
extraction_time_ms=int((time.time() - start_time) * 1000),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def extract_invoice(data: bytes) -> ExtractResponse:
|
||||||
|
"""Extract invoice data from any supported e-invoice file.
|
||||||
|
|
||||||
|
The file type is detected from the content: PDFs (ZUGFeRD/Factur-X or
|
||||||
|
any PDF with an embedded invoice XML) and plain XML files (CII or UBL).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data: Raw file content (PDF or XML)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ExtractResponse with extraction results
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ExtractionError: For unreadable or unsupported files
|
||||||
|
"""
|
||||||
|
_check_file_size(data)
|
||||||
|
|
||||||
|
if b"%PDF-" in data[:1024]:
|
||||||
|
return extract_zugferd(data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
_parse_xml(data)
|
||||||
|
except etree.XMLSyntaxError:
|
||||||
|
if b"<" in data[:200]:
|
||||||
|
return extract_from_xml(data)
|
||||||
|
# Neither PDF nor XML: let the PDF path report the error
|
||||||
|
return extract_zugferd(data)
|
||||||
|
|
||||||
|
return extract_from_xml(data)
|
||||||
|
|
||||||
|
|
||||||
|
def extract_zugferd(pdf_bytes: bytes) -> ExtractResponse:
|
||||||
|
"""Extract e-invoice data from PDF bytes.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content as bytes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ExtractResponse with is_zugferd, profile, xml_data, pdf_text
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ExtractionError: For PDF processing errors
|
||||||
|
"""
|
||||||
|
start_time = time.time()
|
||||||
|
_check_file_size(pdf_bytes)
|
||||||
|
|
||||||
|
xml_filename = None
|
||||||
|
xml_bytes = None
|
||||||
|
try:
|
||||||
|
xml_filename, xml_bytes = get_xml_from_pdf(pdf_bytes, check_xsd=False)
|
||||||
|
except Exception as e:
|
||||||
|
error_msg = str(e).lower()
|
||||||
|
if "password" in error_msg or "encrypted" in error_msg:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="password_protected_pdf",
|
||||||
|
message="PDF is password protected",
|
||||||
|
details=str(e),
|
||||||
|
) from e
|
||||||
|
if "pdf" in error_msg or "trailer" in error_msg or "xref" in error_msg:
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="invalid_pdf", message="Invalid PDF file", details=str(e)
|
||||||
|
) from e
|
||||||
|
raise ExtractionError(
|
||||||
|
error_code="corrupt_pdf",
|
||||||
|
message="Failed to extract XML from PDF",
|
||||||
|
details=str(e),
|
||||||
|
) from e
|
||||||
|
|
||||||
|
# Fallback: If factur-x library didn't find XML, check attachments by MIME type
|
||||||
|
# This handles XRechnung and other XML attachments with non-standard filenames
|
||||||
|
if not xml_bytes:
|
||||||
|
xml_filename, xml_bytes = _find_xml_attachment_fallback(pdf_bytes)
|
||||||
|
|
||||||
|
if not xml_bytes:
|
||||||
|
pdf_text = extract_text_from_pdf(pdf_bytes)
|
||||||
|
pages = get_pdf_page_count(pdf_bytes)
|
||||||
|
extraction_time_ms = int((time.time() - start_time) * 1000)
|
||||||
|
|
||||||
|
return ExtractResponse(
|
||||||
|
is_zugferd=False,
|
||||||
|
pdf_text=pdf_text,
|
||||||
|
extraction_meta=ExtractionMeta(
|
||||||
|
pages=pages,
|
||||||
|
xml_attachment_name=None,
|
||||||
|
extraction_time_ms=extraction_time_ms,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
syntax, level, xml_data = _interpret_invoice_xml(xml_bytes)
|
||||||
|
pdf_text = extract_text_from_pdf(pdf_bytes)
|
||||||
|
pages = get_pdf_page_count(pdf_bytes)
|
||||||
|
extraction_time_ms = int((time.time() - start_time) * 1000)
|
||||||
|
|
||||||
|
return ExtractResponse(
|
||||||
|
is_zugferd=True,
|
||||||
|
zugferd_profil=level.upper(),
|
||||||
|
xml_syntax=syntax,
|
||||||
|
xml_raw=_xml_to_text(xml_bytes),
|
||||||
|
xml_data=xml_data,
|
||||||
|
pdf_text=pdf_text,
|
||||||
|
extraction_meta=ExtractionMeta(
|
||||||
|
pages=pages,
|
||||||
|
xml_attachment_name=xml_filename or "factur-x.xml",
|
||||||
|
extraction_time_ms=extraction_time_ms,
|
||||||
|
),
|
||||||
|
)
|
||||||
+199
@@ -0,0 +1,199 @@
|
|||||||
|
"""FastAPI application for ZUGFeRD invoice processing."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import base64
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import uvicorn
|
||||||
|
from fastapi import FastAPI, HTTPException, Request
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
from src.extractor import ExtractionError, extract_from_xml, extract_invoice
|
||||||
|
from src.models import (
|
||||||
|
ExtractRequest,
|
||||||
|
ExtractResponse,
|
||||||
|
HealthResponse,
|
||||||
|
ValidateRequest,
|
||||||
|
ValidateResponse,
|
||||||
|
)
|
||||||
|
from src.validator import validate_invoice
|
||||||
|
|
||||||
|
|
||||||
|
class JSONFormatter(logging.Formatter):
|
||||||
|
def format(self, record):
|
||||||
|
log_data = {
|
||||||
|
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||||
|
"level": record.levelname,
|
||||||
|
"message": record.getMessage(),
|
||||||
|
}
|
||||||
|
if hasattr(record, "data"):
|
||||||
|
log_data["data"] = record.data
|
||||||
|
return json.dumps(log_data)
|
||||||
|
|
||||||
|
|
||||||
|
def get_log_level() -> str:
|
||||||
|
"""Read the log level from the LOG_LEVEL environment variable.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Upper-case level name; 'INFO' when unset or not a valid level
|
||||||
|
"""
|
||||||
|
level = os.environ.get("LOG_LEVEL", "INFO").strip().upper()
|
||||||
|
if level not in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"):
|
||||||
|
return "INFO"
|
||||||
|
return level
|
||||||
|
|
||||||
|
|
||||||
|
def configure_logging() -> None:
|
||||||
|
"""Attach the JSON handler to the 'src' package logger and set its level.
|
||||||
|
|
||||||
|
Configuring the package logger makes all service modules (extractor,
|
||||||
|
validator, ...) log in the same format and at the same level.
|
||||||
|
"""
|
||||||
|
package_logger = logging.getLogger("src")
|
||||||
|
if not package_logger.handlers:
|
||||||
|
handler = logging.StreamHandler()
|
||||||
|
handler.setFormatter(JSONFormatter())
|
||||||
|
package_logger.addHandler(handler)
|
||||||
|
package_logger.setLevel(get_log_level())
|
||||||
|
|
||||||
|
|
||||||
|
# Fixed name: __name__ is '__main__' when started via `python -m src.main`
|
||||||
|
logger = logging.getLogger("src.main")
|
||||||
|
configure_logging()
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title="ZUGFeRD Service",
|
||||||
|
version="1.0.0",
|
||||||
|
description="REST API for ZUGFeRD invoice extraction and validation",
|
||||||
|
)
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["*"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.exception_handler(ExtractionError)
|
||||||
|
async def extraction_error_handler(request: Request, exc: ExtractionError):
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=400,
|
||||||
|
content={
|
||||||
|
"error": exc.error_code,
|
||||||
|
"message": exc.message,
|
||||||
|
"details": exc.details,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.exception_handler(HTTPException)
|
||||||
|
async def http_exception_handler(request: Request, exc: HTTPException):
|
||||||
|
if isinstance(exc.detail, dict) and "error" in exc.detail:
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=exc.status_code,
|
||||||
|
content={
|
||||||
|
"error": exc.detail.get("error"),
|
||||||
|
"message": exc.detail.get("message"),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=exc.status_code,
|
||||||
|
content={
|
||||||
|
"error": "http_error",
|
||||||
|
"message": str(exc.detail),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.exception_handler(Exception)
|
||||||
|
async def generic_error_handler(request: Request, exc: Exception):
|
||||||
|
logger.error(f"Internal error: {exc}")
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=500,
|
||||||
|
content={
|
||||||
|
"error": "internal_error",
|
||||||
|
"message": "An internal error occurred",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health", response_model=HealthResponse)
|
||||||
|
async def health_check() -> HealthResponse:
|
||||||
|
"""Health check endpoint.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
HealthResponse with status and version.
|
||||||
|
"""
|
||||||
|
return HealthResponse(status="healthy", version="1.0.0")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/extract", response_model=ExtractResponse)
|
||||||
|
async def extract_pdf(request: ExtractRequest) -> ExtractResponse:
|
||||||
|
"""Extract e-invoice data from a PDF or a plain invoice XML.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: ExtractRequest with pdf_base64 or xml_base64 field
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ExtractResponse with extraction results
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
file_bytes = base64.b64decode(request.xml_base64 or request.pdf_base64 or "")
|
||||||
|
except Exception:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail={"error": "invalid_base64", "message": "Invalid base64 encoding"},
|
||||||
|
)
|
||||||
|
|
||||||
|
if request.xml_base64 is not None:
|
||||||
|
return extract_from_xml(file_bytes)
|
||||||
|
return extract_invoice(file_bytes)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/validate", response_model=ValidateResponse)
|
||||||
|
async def validate_invoice_endpoint(request: ValidateRequest) -> ValidateResponse:
|
||||||
|
"""Validate ZUGFeRD invoice data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: ValidateRequest with xml_data, pdf_text, checks
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ValidateResponse with validation results
|
||||||
|
"""
|
||||||
|
result = validate_invoice(request)
|
||||||
|
return ValidateResponse(result=result)
|
||||||
|
|
||||||
|
|
||||||
|
def run(host: str = "0.0.0.0", port: int = 5000) -> None:
|
||||||
|
"""Run the FastAPI application.
|
||||||
|
|
||||||
|
Priority: CLI args > env vars > defaults
|
||||||
|
|
||||||
|
Args:
|
||||||
|
host: Host to bind to (default from env HOST or 0.0.0.0).
|
||||||
|
port: Port to listen on (default from env PORT or 5000).
|
||||||
|
"""
|
||||||
|
parser = argparse.ArgumentParser(description="ZUGFeRD REST API Service")
|
||||||
|
parser.add_argument(
|
||||||
|
"--host",
|
||||||
|
default=os.environ.get("HOST", host),
|
||||||
|
help="Host to bind to (default: 0.0.0.0)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--port",
|
||||||
|
type=int,
|
||||||
|
default=int(os.environ.get("PORT", port)),
|
||||||
|
help="Port to listen on (default: 5000)",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
uvicorn.run(
|
||||||
|
app, host=args.host, port=args.port, log_level=get_log_level().lower()
|
||||||
|
)
|
||||||
+212
@@ -0,0 +1,212 @@
|
|||||||
|
"""Pydantic models for ZUGFeRD service."""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field, model_validator
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractionMeta(BaseModel):
|
||||||
|
"""Metadata about the extraction process."""
|
||||||
|
|
||||||
|
pages: int = Field(description="Number of pages in the PDF")
|
||||||
|
xml_attachment_name: str | None = Field(
|
||||||
|
default=None, description="Name of the XML attachment"
|
||||||
|
)
|
||||||
|
extraction_time_ms: int = Field(description="Extraction time in milliseconds")
|
||||||
|
|
||||||
|
|
||||||
|
class Supplier(BaseModel):
|
||||||
|
"""Supplier/seller information."""
|
||||||
|
|
||||||
|
name: str = Field(description="Supplier name")
|
||||||
|
street: str | None = Field(default=None, description="Street address")
|
||||||
|
postal_code: str | None = Field(default=None, description="Postal code")
|
||||||
|
city: str | None = Field(default=None, description="City")
|
||||||
|
country: str | None = Field(default=None, description="Country code")
|
||||||
|
vat_id: str | None = Field(default=None, description="VAT ID")
|
||||||
|
tax_number: str | None = Field(
|
||||||
|
default=None, description="Tax number (Steuernummer, BT-32)"
|
||||||
|
)
|
||||||
|
email: str | None = Field(default=None, description="Email address")
|
||||||
|
|
||||||
|
|
||||||
|
class Buyer(BaseModel):
|
||||||
|
"""Buyer/customer information."""
|
||||||
|
|
||||||
|
name: str = Field(description="Buyer name")
|
||||||
|
street: str | None = Field(default=None, description="Street address")
|
||||||
|
postal_code: str | None = Field(default=None, description="Postal code")
|
||||||
|
city: str | None = Field(default=None, description="City")
|
||||||
|
country: str | None = Field(default=None, description="Country code")
|
||||||
|
vat_id: str | None = Field(default=None, description="VAT ID")
|
||||||
|
tax_number: str | None = Field(
|
||||||
|
default=None, description="Tax number (Steuernummer, BT-49)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class VatBreakdown(BaseModel):
|
||||||
|
"""VAT breakdown entry."""
|
||||||
|
|
||||||
|
rate: float = Field(description="VAT rate percentage")
|
||||||
|
base: float = Field(description="Tax base amount")
|
||||||
|
amount: float = Field(description="VAT amount")
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentTerms(BaseModel):
|
||||||
|
"""Payment terms information."""
|
||||||
|
|
||||||
|
iban: str | None = Field(default=None, description="IBAN")
|
||||||
|
bic: str | None = Field(default=None, description="BIC/SWIFT")
|
||||||
|
account_holder: str | None = Field(default=None, description="Account holder name")
|
||||||
|
|
||||||
|
|
||||||
|
class Totals(BaseModel):
|
||||||
|
"""Invoice totals."""
|
||||||
|
|
||||||
|
line_total_sum: float = Field(description="Sum of all line totals")
|
||||||
|
net: float = Field(description="Net amount")
|
||||||
|
vat_total: float = Field(description="Total VAT amount")
|
||||||
|
gross: float = Field(description="Gross amount")
|
||||||
|
vat_breakdown: list[VatBreakdown] = Field(
|
||||||
|
default_factory=list, description="VAT breakdown"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class LineItem(BaseModel):
|
||||||
|
"""Invoice line item."""
|
||||||
|
|
||||||
|
position: int = Field(description="Line position number")
|
||||||
|
article_number: str | None = Field(default=None, description="Article number")
|
||||||
|
article_number_buyer: str | None = Field(
|
||||||
|
default=None, description="Buyer's article number"
|
||||||
|
)
|
||||||
|
description: str = Field(description="Item description")
|
||||||
|
quantity: float = Field(description="Quantity")
|
||||||
|
unit: str = Field(description="Unit (human-readable)")
|
||||||
|
unit_price: float | None = Field(default=None, description="Unit price")
|
||||||
|
line_total: float | None = Field(default=None, description="Line total amount")
|
||||||
|
vat_rate: float | None = Field(default=None, description="VAT rate percentage")
|
||||||
|
vat_amount: float | None = Field(
|
||||||
|
default=None, description="VAT amount for this line"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class XmlData(BaseModel):
|
||||||
|
"""Structured XML data extracted from ZUGFeRD invoice."""
|
||||||
|
|
||||||
|
invoice_number: str = Field(description="Invoice number")
|
||||||
|
invoice_date: str = Field(description="Invoice date (YYYY-MM-DD)")
|
||||||
|
due_date: str | None = Field(default=None, description="Due date (YYYY-MM-DD)")
|
||||||
|
buyer_reference: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Buyer reference (BT-10); the Leitweg-ID on XRechnung invoices",
|
||||||
|
)
|
||||||
|
supplier: Supplier = Field(description="Supplier information")
|
||||||
|
buyer: Buyer = Field(description="Buyer information")
|
||||||
|
line_items: list[LineItem] = Field(description="Line items")
|
||||||
|
totals: Totals = Field(description="Invoice totals")
|
||||||
|
currency: str = Field(default="EUR", description="Currency code")
|
||||||
|
payment_terms: PaymentTerms | None = Field(
|
||||||
|
default=None, description="Payment terms"
|
||||||
|
)
|
||||||
|
notes: str | None = Field(default=None, description="Invoice notes")
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractRequest(BaseModel):
|
||||||
|
"""Request body for /extract endpoint."""
|
||||||
|
|
||||||
|
pdf_base64: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Base64-encoded invoice file (PDF, or plain invoice XML)",
|
||||||
|
)
|
||||||
|
xml_base64: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Base64-encoded plain invoice XML (XRechnung, CII or UBL)",
|
||||||
|
)
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def _exactly_one_file(self) -> "ExtractRequest":
|
||||||
|
if (self.pdf_base64 is None) == (self.xml_base64 is None):
|
||||||
|
raise ValueError("Provide exactly one of 'pdf_base64' or 'xml_base64'")
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractResponse(BaseModel):
|
||||||
|
"""Response from /extract endpoint."""
|
||||||
|
|
||||||
|
is_zugferd: bool = Field(
|
||||||
|
description="Whether the file contains structured e-invoice data"
|
||||||
|
)
|
||||||
|
zugferd_profil: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Invoice profile (e.g., EN16931, XRECHNUNG_3.0)",
|
||||||
|
)
|
||||||
|
xml_syntax: str | None = Field(
|
||||||
|
default=None, description="XML syntax of the invoice: 'CII' or 'UBL'"
|
||||||
|
)
|
||||||
|
xml_raw: str | None = Field(default=None, description="Raw XML string")
|
||||||
|
xml_data: XmlData | None = Field(default=None, description="Parsed XML data")
|
||||||
|
pdf_text: str | None = Field(default=None, description="Extracted PDF text")
|
||||||
|
extraction_meta: ExtractionMeta = Field(description="Extraction metadata")
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorDetail(BaseModel):
|
||||||
|
"""Error or warning detail from validation."""
|
||||||
|
|
||||||
|
check: str = Field(description="Validation check that produced this error")
|
||||||
|
field: str | None = Field(default=None, description="Field with the issue")
|
||||||
|
error_code: str = Field(description="Error code")
|
||||||
|
message: str = Field(description="Human-readable error message")
|
||||||
|
severity: str = Field(description="Severity level: 'critical' or 'warning'")
|
||||||
|
|
||||||
|
|
||||||
|
class ValidationResult(BaseModel):
|
||||||
|
"""Result of invoice validation."""
|
||||||
|
|
||||||
|
is_valid: bool = Field(description="Whether invoice passed all validation checks")
|
||||||
|
errors: list[ErrorDetail] = Field(
|
||||||
|
default_factory=list, description="Critical errors"
|
||||||
|
)
|
||||||
|
warnings: list[ErrorDetail] = Field(default_factory=list, description="Warnings")
|
||||||
|
summary: dict[str, Any] | None = Field(
|
||||||
|
default=None, description="Validation summary"
|
||||||
|
)
|
||||||
|
validation_time_ms: int = Field(description="Validation time in milliseconds")
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateRequest(BaseModel):
|
||||||
|
"""Request body for /validate endpoint."""
|
||||||
|
|
||||||
|
xml_data: dict[str, Any] = Field(description="XML data to validate")
|
||||||
|
pdf_text: str | None = Field(
|
||||||
|
default=None, description="Extracted PDF text for comparison"
|
||||||
|
)
|
||||||
|
checks: list[str] = Field(description="List of validation checks to run")
|
||||||
|
profile: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description=(
|
||||||
|
"Invoice profile as returned by /extract in 'zugferd_profil'. "
|
||||||
|
"Enables profile-specific rules, e.g. the mandatory buyer "
|
||||||
|
"reference on XRechnung invoices."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateResponse(BaseModel):
|
||||||
|
"""Response from /validate endpoint."""
|
||||||
|
|
||||||
|
result: ValidationResult = Field(description="Validation result")
|
||||||
|
|
||||||
|
|
||||||
|
class HealthResponse(BaseModel):
|
||||||
|
"""Health check response."""
|
||||||
|
|
||||||
|
status: str = Field(description="Service status")
|
||||||
|
version: str = Field(description="Service version")
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorResponse(BaseModel):
|
||||||
|
"""Error response."""
|
||||||
|
|
||||||
|
error: str = Field(description="Error code")
|
||||||
|
message: str = Field(description="Error message")
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
"""
|
||||||
|
PDF text extraction and invoice field parsing.
|
||||||
|
|
||||||
|
Extracts text from PDFs and parses invoice fields using regex patterns.
|
||||||
|
Handles German number and date formats.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
|
import re
|
||||||
|
from pypdf import PdfReader
|
||||||
|
|
||||||
|
|
||||||
|
EXTRACTION_PATTERNS = {
|
||||||
|
"invoice_number": [
|
||||||
|
r"Rechnungs?-?(?:Nr|Nummer)[.:\s]*([A-Z0-9\-]+)",
|
||||||
|
r"Invoice\s*(?:No|Number)?[.:\s]*([A-Z0-9\-]+)",
|
||||||
|
r"Beleg-?Nr[.:\s]*([A-Z0-9\-]+)",
|
||||||
|
r"Rechnung\s+[0-9]+/([A-Z0-9\-]+)",
|
||||||
|
],
|
||||||
|
"gross_amount": [
|
||||||
|
r"Brutto[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
r"Gesamtbetrag[:\s]*([0-9]+(?:[.,][0-9]+)*)",
|
||||||
|
r"Total[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
r"Endbetrag[:\s]*([0-9]+(?:[.,][0-9]+)*)",
|
||||||
|
r"Summe[:\s]*([0-9]+(?:[.,][0-9]+)*)",
|
||||||
|
],
|
||||||
|
"net_amount": [
|
||||||
|
r"Netto[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
r"Rechnungsbetrag[:\s]*([0-9]+(?:[.,][0-9]+)*)",
|
||||||
|
],
|
||||||
|
"vat_amount": [
|
||||||
|
r"MwSt\s*[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
r"USt\s*[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
r"Steuer[:\s]*([0-9]+(?:[.,][0-9]+)*)\s*(?:EUR|€)?",
|
||||||
|
],
|
||||||
|
"invoice_date": [
|
||||||
|
r"Rechnungsdatum[:\s]*(\d{1,2}\.\d{1,2}\.\d{4})",
|
||||||
|
r"Datum[:\s]*(\d{1,2}\.\d{1,2}\.\d{4})",
|
||||||
|
r"Invoice\s*Date[:\s]*(\d{4}-\d{2}-\d{2})",
|
||||||
|
],
|
||||||
|
"supplier_name": [
|
||||||
|
r"Lieferant[:\s]+(.+?)(?:\n|$)",
|
||||||
|
r"Verkäufer[:\s]+(.+?)(?:\n|$)",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def extract_text_from_pdf(pdf_bytes: bytes) -> str:
|
||||||
|
"""Extract all text content from PDF bytes.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pdf_bytes: Raw PDF file content as bytes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Full text content from all PDF pages
|
||||||
|
"""
|
||||||
|
pdf_stream = io.BytesIO(pdf_bytes)
|
||||||
|
reader = PdfReader(pdf_stream)
|
||||||
|
text_parts = []
|
||||||
|
for page in reader.pages:
|
||||||
|
text = page.extract_text()
|
||||||
|
if text:
|
||||||
|
text_parts.append(text)
|
||||||
|
return "\n".join(text_parts)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_german_number(num_str: str) -> float:
|
||||||
|
"""Convert number string to float, handling German and international formats.
|
||||||
|
|
||||||
|
German format: 1.234,56 (thousands separator = dot, decimal separator = comma)
|
||||||
|
International: 1,234.56 (thousands separator = comma, decimal separator = dot)
|
||||||
|
"""
|
||||||
|
if "," in num_str and num_str.rfind(",") > num_str.rfind("."):
|
||||||
|
return float(num_str.replace(".", "").replace(",", "."))
|
||||||
|
else:
|
||||||
|
return float(num_str.replace(",", ""))
|
||||||
|
|
||||||
|
|
||||||
|
def parse_german_date(date_str: str) -> str:
|
||||||
|
"""Convert German date (04.02.2025) to ISO format (2025-02-04)."""
|
||||||
|
if "." in date_str and len(date_str.split(".")) == 3:
|
||||||
|
day, month, year = date_str.split(".")
|
||||||
|
return f"{year}-{month.zfill(2)}-{day.zfill(2)}"
|
||||||
|
return date_str
|
||||||
|
|
||||||
|
|
||||||
|
def extract_from_text(text: str) -> dict:
|
||||||
|
"""Extract invoice key values from text using regex patterns.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
text: PDF text content
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dictionary with extracted values and confidence scores
|
||||||
|
"""
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
for field_name, patterns in EXTRACTION_PATTERNS.items():
|
||||||
|
value = None
|
||||||
|
confidence = 0.0
|
||||||
|
|
||||||
|
for pattern in patterns:
|
||||||
|
match = re.search(pattern, text, re.IGNORECASE | re.MULTILINE)
|
||||||
|
if match:
|
||||||
|
raw_value = match.group(1).strip()
|
||||||
|
|
||||||
|
if field_name.endswith("_amount"):
|
||||||
|
value = parse_german_number(raw_value)
|
||||||
|
elif field_name == "invoice_date":
|
||||||
|
value = parse_german_date(raw_value)
|
||||||
|
else:
|
||||||
|
value = raw_value
|
||||||
|
|
||||||
|
pattern_index = patterns.index(pattern)
|
||||||
|
confidence = 1.0 - (pattern_index * 0.1)
|
||||||
|
break
|
||||||
|
|
||||||
|
result[field_name] = value
|
||||||
|
result[f"{field_name}_confidence"] = confidence
|
||||||
|
|
||||||
|
return result
|
||||||
@@ -0,0 +1,319 @@
|
|||||||
|
"""UBL 2.1 invoice parser.
|
||||||
|
|
||||||
|
Maps EN 16931 invoices in UBL syntax (XRechnung UBL, Peppol BIS Billing)
|
||||||
|
to the same XmlData structure the CII/ZUGFeRD parser produces. Supports the
|
||||||
|
Invoice and CreditNote document types.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from src.models import (
|
||||||
|
Buyer,
|
||||||
|
LineItem,
|
||||||
|
PaymentTerms,
|
||||||
|
Supplier,
|
||||||
|
Totals,
|
||||||
|
VatBreakdown,
|
||||||
|
XmlData,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
UBL_INVOICE_NS = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
|
||||||
|
UBL_CREDIT_NOTE_NS = "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
|
||||||
|
|
||||||
|
UBL_ROOT_TAGS = {
|
||||||
|
f"{{{UBL_INVOICE_NS}}}Invoice",
|
||||||
|
f"{{{UBL_CREDIT_NOTE_NS}}}CreditNote",
|
||||||
|
}
|
||||||
|
|
||||||
|
UBL_NAMESPACES = {
|
||||||
|
"cac": "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
|
||||||
|
"cbc": "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def is_ubl_root(xml_root: etree._Element) -> bool:
|
||||||
|
"""Check whether an XML root element is a UBL Invoice or CreditNote.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: XML root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True for UBL Invoice-2 / CreditNote-2 documents
|
||||||
|
"""
|
||||||
|
return xml_root.tag in UBL_ROOT_TAGS
|
||||||
|
|
||||||
|
|
||||||
|
def _text(node: etree._Element, path: str) -> str | None:
|
||||||
|
"""Return the stripped text of the first XPath match, or None.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
node: Context element
|
||||||
|
path: XPath expression using the cac/cbc prefixes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Stripped text, or None when absent or empty
|
||||||
|
"""
|
||||||
|
result = node.xpath(path, namespaces=UBL_NAMESPACES)
|
||||||
|
if not result:
|
||||||
|
return None
|
||||||
|
first = result[0]
|
||||||
|
value = first if isinstance(first, str) else (first.text or "")
|
||||||
|
value = value.strip()
|
||||||
|
return value or None
|
||||||
|
|
||||||
|
|
||||||
|
def _number(node: etree._Element, path: str) -> float | None:
|
||||||
|
"""Return the first XPath match as float, or None.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
node: Context element
|
||||||
|
path: XPath expression using the cac/cbc prefixes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Parsed number, or None when absent or not numeric
|
||||||
|
"""
|
||||||
|
value = _text(node, path)
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
return float(value)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _party_fields(party: etree._Element | None) -> dict[str, str | None]:
|
||||||
|
"""Extract the fields shared by seller and buyer from a cac:Party.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
party: cac:Party element, or None when the party is missing
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict with name, address, VAT ID, tax number and email
|
||||||
|
"""
|
||||||
|
if party is None:
|
||||||
|
return {
|
||||||
|
"name": "",
|
||||||
|
"street": None,
|
||||||
|
"postal_code": None,
|
||||||
|
"city": None,
|
||||||
|
"country": None,
|
||||||
|
"vat_id": None,
|
||||||
|
"tax_number": None,
|
||||||
|
"email": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
# BT-27/BT-44 legal name; trading name (BT-28/BT-45) as fallback
|
||||||
|
name = _text(party, "./cac:PartyLegalEntity/cbc:RegistrationName") or _text(
|
||||||
|
party, "./cac:PartyName/cbc:Name"
|
||||||
|
)
|
||||||
|
email = _text(party, "./cac:Contact/cbc:ElectronicMail") or _text(
|
||||||
|
party, "./cbc:EndpointID[@schemeID='EM']"
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"name": name or "",
|
||||||
|
"street": _text(party, "./cac:PostalAddress/cbc:StreetName"),
|
||||||
|
"postal_code": _text(party, "./cac:PostalAddress/cbc:PostalZone"),
|
||||||
|
"city": _text(party, "./cac:PostalAddress/cbc:CityName"),
|
||||||
|
"country": _text(
|
||||||
|
party, "./cac:PostalAddress/cac:Country/cbc:IdentificationCode"
|
||||||
|
),
|
||||||
|
# BT-31/BT-48: tax scheme 'VAT'; BT-32: any other scheme (e.g. 'FC')
|
||||||
|
"vat_id": _text(
|
||||||
|
party, "./cac:PartyTaxScheme[cac:TaxScheme/cbc:ID='VAT']/cbc:CompanyID"
|
||||||
|
),
|
||||||
|
"tax_number": _text(
|
||||||
|
party,
|
||||||
|
"./cac:PartyTaxScheme[not(cac:TaxScheme/cbc:ID='VAT')]/cbc:CompanyID",
|
||||||
|
),
|
||||||
|
"email": email,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _first(node: etree._Element, path: str) -> etree._Element | None:
|
||||||
|
"""Return the first element matching an XPath, or None.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
node: Context element
|
||||||
|
path: XPath expression using the cac/cbc prefixes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
First matching element, or None
|
||||||
|
"""
|
||||||
|
result = node.xpath(path, namespaces=UBL_NAMESPACES)
|
||||||
|
return result[0] if result else None
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_supplier(xml_root: etree._Element) -> Supplier:
|
||||||
|
"""Parse the seller (cac:AccountingSupplierParty) from a UBL document.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Supplier model
|
||||||
|
"""
|
||||||
|
party = _first(xml_root, "./cac:AccountingSupplierParty/cac:Party")
|
||||||
|
return Supplier(**_party_fields(party))
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_buyer(xml_root: etree._Element) -> Buyer:
|
||||||
|
"""Parse the buyer (cac:AccountingCustomerParty) from a UBL document.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Buyer model
|
||||||
|
"""
|
||||||
|
party = _first(xml_root, "./cac:AccountingCustomerParty/cac:Party")
|
||||||
|
fields = _party_fields(party)
|
||||||
|
fields.pop("email")
|
||||||
|
return Buyer(**fields)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_line_items(xml_root: etree._Element) -> list[LineItem]:
|
||||||
|
"""Parse invoice lines from a UBL document.
|
||||||
|
|
||||||
|
Only top-level lines are returned; nested sub-lines (XRechnung extension)
|
||||||
|
are already contained in their parent's amounts.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of LineItem models
|
||||||
|
"""
|
||||||
|
line_nodes = xml_root.xpath(
|
||||||
|
"./cac:InvoiceLine | ./cac:CreditNoteLine", namespaces=UBL_NAMESPACES
|
||||||
|
)
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for idx, line in enumerate(line_nodes, start=1):
|
||||||
|
quantity_path = "./cbc:InvoicedQuantity | ./cbc:CreditedQuantity"
|
||||||
|
quantity_node = _first(line, quantity_path)
|
||||||
|
unit = quantity_node.get("unitCode") if quantity_node is not None else None
|
||||||
|
|
||||||
|
# Base quantity (BT-149): price amount applies to N units
|
||||||
|
unit_price = _number(line, "./cac:Price/cbc:PriceAmount")
|
||||||
|
base_quantity = _number(line, "./cac:Price/cbc:BaseQuantity")
|
||||||
|
if unit_price is not None and base_quantity is not None and base_quantity > 0:
|
||||||
|
unit_price = unit_price / base_quantity
|
||||||
|
|
||||||
|
items.append(
|
||||||
|
LineItem(
|
||||||
|
position=idx,
|
||||||
|
article_number=_text(
|
||||||
|
line, "./cac:Item/cac:SellersItemIdentification/cbc:ID"
|
||||||
|
),
|
||||||
|
article_number_buyer=_text(
|
||||||
|
line, "./cac:Item/cac:BuyersItemIdentification/cbc:ID"
|
||||||
|
),
|
||||||
|
description=_text(line, "./cac:Item/cbc:Name") or "",
|
||||||
|
quantity=_number(line, quantity_path) or 0.0,
|
||||||
|
unit=unit or "Stück",
|
||||||
|
unit_price=unit_price,
|
||||||
|
line_total=_number(line, "./cbc:LineExtensionAmount"),
|
||||||
|
vat_rate=_number(
|
||||||
|
line, "./cac:Item/cac:ClassifiedTaxCategory/cbc:Percent"
|
||||||
|
),
|
||||||
|
vat_amount=None,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_totals(xml_root: etree._Element, currency: str | None) -> Totals:
|
||||||
|
"""Parse document totals and the VAT breakdown from a UBL document.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
currency: Document currency code, used to pick the right cac:TaxTotal
|
||||||
|
when a second one in the tax accounting currency is present
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Totals model
|
||||||
|
"""
|
||||||
|
tax_totals = xml_root.xpath("./cac:TaxTotal", namespaces=UBL_NAMESPACES)
|
||||||
|
tax_total = None
|
||||||
|
for candidate in tax_totals:
|
||||||
|
amount_node = _first(candidate, "./cbc:TaxAmount")
|
||||||
|
if amount_node is not None and amount_node.get("currencyID") == currency:
|
||||||
|
tax_total = candidate
|
||||||
|
break
|
||||||
|
if tax_total is None and tax_totals:
|
||||||
|
tax_total = tax_totals[0]
|
||||||
|
|
||||||
|
vat_total = None
|
||||||
|
vat_breakdown = []
|
||||||
|
if tax_total is not None:
|
||||||
|
vat_total = _number(tax_total, "./cbc:TaxAmount")
|
||||||
|
for subtotal in tax_total.xpath("./cac:TaxSubtotal", namespaces=UBL_NAMESPACES):
|
||||||
|
base = _number(subtotal, "./cbc:TaxableAmount")
|
||||||
|
amount = _number(subtotal, "./cbc:TaxAmount")
|
||||||
|
if base is None or amount is None:
|
||||||
|
continue
|
||||||
|
# Percent is omitted for categories without a rate (e.g. 'O')
|
||||||
|
rate = _number(subtotal, "./cac:TaxCategory/cbc:Percent") or 0.0
|
||||||
|
vat_breakdown.append(VatBreakdown(rate=rate, base=base, amount=amount))
|
||||||
|
|
||||||
|
monetary = "./cac:LegalMonetaryTotal"
|
||||||
|
return Totals(
|
||||||
|
line_total_sum=_number(xml_root, f"{monetary}/cbc:LineExtensionAmount") or 0.0,
|
||||||
|
net=_number(xml_root, f"{monetary}/cbc:TaxExclusiveAmount") or 0.0,
|
||||||
|
vat_total=vat_total or 0.0,
|
||||||
|
gross=_number(xml_root, f"{monetary}/cbc:TaxInclusiveAmount") or 0.0,
|
||||||
|
vat_breakdown=vat_breakdown,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_payment_terms(xml_root: etree._Element) -> PaymentTerms | None:
|
||||||
|
"""Parse credit transfer details from a UBL document.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
PaymentTerms model, or None when no account data is present
|
||||||
|
"""
|
||||||
|
account = "./cac:PaymentMeans/cac:PayeeFinancialAccount"
|
||||||
|
iban = _text(xml_root, f"{account}/cbc:ID")
|
||||||
|
bic = _text(xml_root, f"{account}/cac:FinancialInstitutionBranch/cbc:ID")
|
||||||
|
account_holder = _text(xml_root, f"{account}/cbc:Name")
|
||||||
|
|
||||||
|
if not (iban or bic or account_holder):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return PaymentTerms(iban=iban, bic=bic, account_holder=account_holder)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ubl_xml(xml_root: etree._Element) -> XmlData:
|
||||||
|
"""Parse a UBL Invoice or CreditNote to structured XmlData.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_root: UBL Invoice or CreditNote root element
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
XmlData model with all invoice fields
|
||||||
|
"""
|
||||||
|
currency = _text(xml_root, "./cbc:DocumentCurrencyCode")
|
||||||
|
# BT-9: cbc:DueDate on invoices, PaymentMeans/PaymentDueDate on credit notes
|
||||||
|
due_date = _text(xml_root, "./cbc:DueDate") or _text(
|
||||||
|
xml_root, "./cac:PaymentMeans/cbc:PaymentDueDate"
|
||||||
|
)
|
||||||
|
|
||||||
|
return XmlData(
|
||||||
|
invoice_number=_text(xml_root, "./cbc:ID") or "",
|
||||||
|
invoice_date=_text(xml_root, "./cbc:IssueDate") or "",
|
||||||
|
due_date=due_date,
|
||||||
|
buyer_reference=_text(xml_root, "./cbc:BuyerReference"),
|
||||||
|
supplier=parse_ubl_supplier(xml_root),
|
||||||
|
buyer=parse_ubl_buyer(xml_root),
|
||||||
|
line_items=parse_ubl_line_items(xml_root),
|
||||||
|
totals=parse_ubl_totals(xml_root, currency),
|
||||||
|
currency=currency or "EUR",
|
||||||
|
payment_terms=parse_ubl_payment_terms(xml_root),
|
||||||
|
notes=_text(xml_root, "./cbc:Note"),
|
||||||
|
)
|
||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
"""Utility functions for ZUGFeRD service."""
|
||||||
|
|
||||||
|
from decimal import Decimal, ROUND_HALF_UP
|
||||||
|
|
||||||
|
UNECE_UNIT_CODES = {
|
||||||
|
"C62": "Stück",
|
||||||
|
"H87": "Stück",
|
||||||
|
"KGM": "Kilogramm",
|
||||||
|
"GRM": "Gramm",
|
||||||
|
"TNE": "Tonne",
|
||||||
|
"MTR": "Meter",
|
||||||
|
"KMT": "Kilometer",
|
||||||
|
"MTK": "Quadratmeter",
|
||||||
|
"LTR": "Liter",
|
||||||
|
"MLT": "Milliliter",
|
||||||
|
"DAY": "Tag",
|
||||||
|
"HUR": "Stunde",
|
||||||
|
"MON": "Monat",
|
||||||
|
"ANN": "Jahr",
|
||||||
|
"SET": "Set",
|
||||||
|
"PCE": "Stück",
|
||||||
|
"EA": "Stück",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def translate_unit_code(code: str) -> str:
|
||||||
|
"""Map UN/ECE unit code to human-readable German name.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
code: UN/ECE unit code (e.g., "C62", "KGM")
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Human-readable German name or original code if not found
|
||||||
|
"""
|
||||||
|
return UNECE_UNIT_CODES.get(code, code)
|
||||||
|
|
||||||
|
|
||||||
|
def amounts_match(actual: float, expected: float, tolerance: float = 0.01) -> bool:
|
||||||
|
"""Check if two amounts match within tolerance.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
actual: Actual value
|
||||||
|
expected: Expected value
|
||||||
|
tolerance: Allowed difference (default: 0.01 EUR)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True if |actual - expected| <= tolerance
|
||||||
|
"""
|
||||||
|
# Add small epsilon to handle floating point precision issues
|
||||||
|
return abs(actual - expected) <= tolerance + 1e-10
|
||||||
|
|
||||||
|
|
||||||
|
def parse_german_number(num_str: str) -> float:
|
||||||
|
"""Convert German number format to float.
|
||||||
|
|
||||||
|
German: 1.234,56 (dot = thousands, comma = decimal)
|
||||||
|
Result: 1234.56
|
||||||
|
|
||||||
|
Args:
|
||||||
|
num_str: German formatted number string
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Float value
|
||||||
|
"""
|
||||||
|
# Remove thousands separator (dots)
|
||||||
|
# Replace decimal separator (comma) with dot
|
||||||
|
return float(num_str.replace(".", "").replace(",", "."))
|
||||||
|
|
||||||
|
|
||||||
|
def parse_german_date(date_str: str) -> str:
|
||||||
|
"""Convert German date to ISO format (YYYY-MM-DD).
|
||||||
|
|
||||||
|
German: 04.02.2025
|
||||||
|
Result: 2025-02-04
|
||||||
|
|
||||||
|
Args:
|
||||||
|
date_str: German formatted date string
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ISO formatted date string
|
||||||
|
"""
|
||||||
|
if "." in date_str and len(date_str.split(".")) == 3:
|
||||||
|
day, month, year = date_str.split(".")
|
||||||
|
return f"{year}-{month.zfill(2)}-{day.zfill(2)}"
|
||||||
|
return date_str
|
||||||
|
|
||||||
|
|
||||||
|
def round_decimal(amount: float, places: int = 2) -> float:
|
||||||
|
"""Round decimal to specified places using standard rounding.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
amount: Amount to round
|
||||||
|
places: Decimal places (default: 2)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Rounded float
|
||||||
|
"""
|
||||||
|
# Use Decimal with ROUND_HALF_UP for standard rounding (not banker's rounding)
|
||||||
|
if places > 0:
|
||||||
|
quantizer = Decimal(f"1.{'0' * (places - 1)}1" if places > 1 else "0.1")
|
||||||
|
return float(Decimal(str(amount)).quantize(quantizer, rounding=ROUND_HALF_UP))
|
||||||
|
else:
|
||||||
|
return round(amount, places)
|
||||||
@@ -0,0 +1,503 @@
|
|||||||
|
"""Validation functions for ZUGFeRD invoices."""
|
||||||
|
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
from decimal import ROUND_HALF_UP, Decimal
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
|
from src.models import (
|
||||||
|
ErrorDetail,
|
||||||
|
ValidateRequest,
|
||||||
|
ValidationResult,
|
||||||
|
XmlData,
|
||||||
|
)
|
||||||
|
from src.utils import amounts_match
|
||||||
|
|
||||||
|
|
||||||
|
def is_xrechnung_profile(profile: str | None) -> bool:
|
||||||
|
"""Check whether a profile name denotes an XRechnung invoice.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
profile: Profile as returned by /extract (e.g. 'XRECHNUNG_3.0')
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True for XRechnung profiles
|
||||||
|
"""
|
||||||
|
return bool(profile) and profile.strip().upper().startswith("XRECHNUNG")
|
||||||
|
|
||||||
|
|
||||||
|
def validate_pflichtfelder(
|
||||||
|
xml_data: XmlData, profile: str | None = None
|
||||||
|
) -> list[ErrorDetail]:
|
||||||
|
"""Check required fields are present.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_data: Parsed invoice data
|
||||||
|
profile: Invoice profile; enables profile-specific required fields
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of errors and warnings for missing fields
|
||||||
|
"""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def add_error(field: str, severity: str, message: str | None = None) -> None:
|
||||||
|
errors.append(
|
||||||
|
ErrorDetail(
|
||||||
|
check="pflichtfelder",
|
||||||
|
field=field,
|
||||||
|
error_code="missing_required",
|
||||||
|
message=message or f"Required field '{field}' is missing or empty",
|
||||||
|
severity=severity,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Critical fields
|
||||||
|
if not xml_data.invoice_number or not xml_data.invoice_number.strip():
|
||||||
|
add_error("invoice_number", "critical")
|
||||||
|
|
||||||
|
if not xml_data.invoice_date or not xml_data.invoice_date.strip():
|
||||||
|
add_error("invoice_date", "critical")
|
||||||
|
|
||||||
|
if not xml_data.supplier.name or not xml_data.supplier.name.strip():
|
||||||
|
add_error("supplier.name", "critical")
|
||||||
|
|
||||||
|
# EN 16931 BR-CO-26: seller identified by VAT ID (BT-31) OR tax number (BT-32)
|
||||||
|
has_vat_id = bool(xml_data.supplier.vat_id and xml_data.supplier.vat_id.strip())
|
||||||
|
has_tax_number = bool(
|
||||||
|
xml_data.supplier.tax_number and xml_data.supplier.tax_number.strip()
|
||||||
|
)
|
||||||
|
if not has_vat_id and not has_tax_number:
|
||||||
|
add_error(
|
||||||
|
"supplier.vat_id",
|
||||||
|
"critical",
|
||||||
|
message=(
|
||||||
|
"Supplier must have a VAT ID (supplier.vat_id) "
|
||||||
|
"or a tax number (supplier.tax_number)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if not xml_data.buyer.name or not xml_data.buyer.name.strip():
|
||||||
|
add_error("buyer.name", "critical")
|
||||||
|
|
||||||
|
# XRechnung BR-DE-15: the buyer reference (BT-10, Leitweg-ID) is mandatory
|
||||||
|
if is_xrechnung_profile(profile) and not (
|
||||||
|
xml_data.buyer_reference and xml_data.buyer_reference.strip()
|
||||||
|
):
|
||||||
|
add_error(
|
||||||
|
"buyer_reference",
|
||||||
|
"critical",
|
||||||
|
message=(
|
||||||
|
"XRechnung requires a buyer reference (BT-10, Leitweg-ID) "
|
||||||
|
"in 'buyer_reference'"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if xml_data.totals.net == 0:
|
||||||
|
add_error("totals.net", "critical")
|
||||||
|
|
||||||
|
if xml_data.totals.gross == 0:
|
||||||
|
add_error("totals.gross", "critical")
|
||||||
|
|
||||||
|
if xml_data.totals.vat_total == 0:
|
||||||
|
add_error("totals.vat_total", "critical")
|
||||||
|
|
||||||
|
# Warning fields
|
||||||
|
if xml_data.due_date is not None and not xml_data.due_date.strip():
|
||||||
|
add_error("due_date", "warning")
|
||||||
|
|
||||||
|
if (
|
||||||
|
xml_data.payment_terms is not None
|
||||||
|
and xml_data.payment_terms.iban is not None
|
||||||
|
and not xml_data.payment_terms.iban.strip()
|
||||||
|
):
|
||||||
|
add_error("payment_terms.iban", "warning")
|
||||||
|
|
||||||
|
# Line items
|
||||||
|
if not xml_data.line_items or len(xml_data.line_items) == 0:
|
||||||
|
add_error("line_items", "critical")
|
||||||
|
else:
|
||||||
|
for idx, item in enumerate(xml_data.line_items):
|
||||||
|
field_prefix = f"line_items[{idx}]"
|
||||||
|
|
||||||
|
if not item.description or not item.description.strip():
|
||||||
|
add_error(f"{field_prefix}.description", "critical")
|
||||||
|
|
||||||
|
# Quantity 0 is legitimate on text-only positions (e.g. a delivery
|
||||||
|
# note reference) that carry no amount; it is only a defect when
|
||||||
|
# the line bills something.
|
||||||
|
if item.quantity == 0 and item.line_total != 0:
|
||||||
|
add_error(f"{field_prefix}.quantity", "critical")
|
||||||
|
|
||||||
|
if item.unit_price is None:
|
||||||
|
add_error(f"{field_prefix}.unit_price", "critical")
|
||||||
|
|
||||||
|
if item.line_total is None:
|
||||||
|
add_error(f"{field_prefix}.line_total", "critical")
|
||||||
|
|
||||||
|
if item.vat_rate is None:
|
||||||
|
add_error(f"{field_prefix}.vat_rate", "warning")
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def validate_betraege(xml_data: XmlData) -> list[ErrorDetail]:
|
||||||
|
"""Check amount calculations are correct."""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def add_mismatch(field: str, expected: float, actual: float | None) -> None:
|
||||||
|
errors.append(
|
||||||
|
ErrorDetail(
|
||||||
|
check="betraege",
|
||||||
|
field=field,
|
||||||
|
error_code="calculation_mismatch",
|
||||||
|
message=f"Calculation mismatch for '{field}': expected {expected}, got {actual}",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check line_total = quantity × unit_price
|
||||||
|
for idx, item in enumerate(xml_data.line_items):
|
||||||
|
unit_price = item.unit_price
|
||||||
|
line_total = item.line_total
|
||||||
|
if unit_price is None or line_total is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
expected_line_total = item.quantity * unit_price
|
||||||
|
if not amounts_match(line_total, expected_line_total):
|
||||||
|
add_mismatch(
|
||||||
|
f"line_items[{idx}].line_total",
|
||||||
|
expected_line_total,
|
||||||
|
line_total,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check totals.net = sum(line_items.line_total)
|
||||||
|
line_total_sum = 0.0
|
||||||
|
for item in xml_data.line_items:
|
||||||
|
if item.line_total is not None:
|
||||||
|
line_total_sum += item.line_total
|
||||||
|
if not amounts_match(xml_data.totals.net, line_total_sum):
|
||||||
|
add_mismatch("totals.net", line_total_sum, xml_data.totals.net)
|
||||||
|
|
||||||
|
# Check vat_breakdown.amount = base × (rate/100)
|
||||||
|
for idx, vat_breakdown in enumerate(xml_data.totals.vat_breakdown):
|
||||||
|
expected_amount = vat_breakdown.base * (vat_breakdown.rate / 100)
|
||||||
|
if not amounts_match(vat_breakdown.amount, expected_amount):
|
||||||
|
add_mismatch(
|
||||||
|
f"totals.vat_breakdown[{idx}].amount",
|
||||||
|
expected_amount,
|
||||||
|
vat_breakdown.amount,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check totals.vat_total = sum(vat_breakdown.amount)
|
||||||
|
vat_breakdown_sum = sum(vb.amount for vb in xml_data.totals.vat_breakdown)
|
||||||
|
if not amounts_match(xml_data.totals.vat_total, vat_breakdown_sum):
|
||||||
|
add_mismatch("totals.vat_total", vat_breakdown_sum, xml_data.totals.vat_total)
|
||||||
|
|
||||||
|
# Check totals.gross = totals.net + totals.vat_total
|
||||||
|
expected_gross = xml_data.totals.net + xml_data.totals.vat_total
|
||||||
|
if not amounts_match(xml_data.totals.gross, expected_gross):
|
||||||
|
add_mismatch("totals.gross", expected_gross, xml_data.totals.gross)
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def validate_ustid(vat_id: str) -> ErrorDetail | None:
|
||||||
|
"""Check VAT ID format (returns None if valid)."""
|
||||||
|
if not vat_id or not vat_id.strip():
|
||||||
|
return ErrorDetail(
|
||||||
|
check="ustid",
|
||||||
|
field="vat_id",
|
||||||
|
error_code="invalid_format",
|
||||||
|
message="VAT ID is empty",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Whitespace inside VAT IDs is formatting only (e.g. "DE 140 978 617")
|
||||||
|
vat_id = re.sub(r"\s+", "", vat_id)
|
||||||
|
|
||||||
|
# German VAT ID: DE followed by 9 digits
|
||||||
|
if vat_id.startswith("DE"):
|
||||||
|
if re.match(r"^DE[0-9]{9}$", vat_id):
|
||||||
|
return None
|
||||||
|
return ErrorDetail(
|
||||||
|
check="ustid",
|
||||||
|
field="vat_id",
|
||||||
|
error_code="invalid_format",
|
||||||
|
message=f"Invalid German VAT ID format: {vat_id}",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Austrian VAT ID: ATU followed by 8 digits
|
||||||
|
if vat_id.startswith("AT"):
|
||||||
|
if re.match(r"^ATU[0-9]{8}$", vat_id):
|
||||||
|
return None
|
||||||
|
return ErrorDetail(
|
||||||
|
check="ustid",
|
||||||
|
field="vat_id",
|
||||||
|
error_code="invalid_format",
|
||||||
|
message=f"Invalid Austrian VAT ID format: {vat_id}",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Swiss VAT ID: CHE followed by 9 digits and MWST/TVA/IVA suffix
|
||||||
|
if vat_id.startswith("CH"):
|
||||||
|
if re.match(r"^CHE[0-9]{9}(MWST|TVA|IVA)$", vat_id):
|
||||||
|
return None
|
||||||
|
return ErrorDetail(
|
||||||
|
check="ustid",
|
||||||
|
field="vat_id",
|
||||||
|
error_code="invalid_format",
|
||||||
|
message=f"Invalid Swiss VAT ID format: {vat_id}",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
|
||||||
|
return ErrorDetail(
|
||||||
|
check="ustid",
|
||||||
|
field="vat_id",
|
||||||
|
error_code="invalid_format",
|
||||||
|
message=f"Unknown country code or invalid VAT ID format: {vat_id}",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_pdf_abgleich(xml_data: XmlData, pdf_values: dict) -> list[ErrorDetail]:
|
||||||
|
"""Compare XML values to PDF extracted values."""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def add_mismatch(field: str, xml_value: Any, pdf_value: Any) -> None:
|
||||||
|
errors.append(
|
||||||
|
ErrorDetail(
|
||||||
|
check="pdf_abgleich",
|
||||||
|
field=field,
|
||||||
|
error_code="pdf_mismatch",
|
||||||
|
message=f"PDF mismatch for '{field}': XML has {xml_value}, PDF has {pdf_value}",
|
||||||
|
severity="warning",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Invoice number (exact match)
|
||||||
|
if "invoice_number" in pdf_values:
|
||||||
|
pdf_invoice = pdf_values["invoice_number"]
|
||||||
|
if xml_data.invoice_number != pdf_invoice:
|
||||||
|
add_mismatch("invoice_number", xml_data.invoice_number, pdf_invoice)
|
||||||
|
|
||||||
|
# Totals.gross (within tolerance)
|
||||||
|
if "totals.gross" in pdf_values:
|
||||||
|
try:
|
||||||
|
pdf_gross = float(pdf_values["totals.gross"])
|
||||||
|
if not amounts_match(xml_data.totals.gross, pdf_gross):
|
||||||
|
add_mismatch("totals.gross", xml_data.totals.gross, pdf_gross)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Totals.net (within tolerance)
|
||||||
|
if "totals.net" in pdf_values:
|
||||||
|
try:
|
||||||
|
pdf_net = float(pdf_values["totals.net"])
|
||||||
|
if not amounts_match(xml_data.totals.net, pdf_net):
|
||||||
|
add_mismatch("totals.net", xml_data.totals.net, pdf_net)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Totals.vat_total (within tolerance)
|
||||||
|
if "totals.vat_total" in pdf_values:
|
||||||
|
try:
|
||||||
|
pdf_vat = float(pdf_values["totals.vat_total"])
|
||||||
|
if not amounts_match(xml_data.totals.vat_total, pdf_vat):
|
||||||
|
add_mismatch("totals.vat_total", xml_data.totals.vat_total, pdf_vat)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def _amount_notations(amount: float) -> set[str]:
|
||||||
|
"""Build the common written forms of a monetary amount.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
amount: Monetary amount; the sign is ignored
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Notations with two decimals, e.g. for 1234.5: '1234.50', '1234,50',
|
||||||
|
'1.234,50', '1,234.50', '1 234,50', "1'234.50"
|
||||||
|
"""
|
||||||
|
quantized = Decimal(str(abs(amount))).quantize(
|
||||||
|
Decimal("0.01"), rounding=ROUND_HALF_UP
|
||||||
|
)
|
||||||
|
integer_part, decimals = f"{quantized:.2f}".split(".")
|
||||||
|
grouped = f"{int(integer_part):,}"
|
||||||
|
|
||||||
|
return {
|
||||||
|
f"{integer_part}.{decimals}",
|
||||||
|
f"{integer_part},{decimals}",
|
||||||
|
f"{grouped}.{decimals}",
|
||||||
|
f"{grouped.replace(',', '.')},{decimals}",
|
||||||
|
f"{grouped.replace(',', ' ')},{decimals}",
|
||||||
|
f"{grouped.replace(',', chr(39))}.{decimals}",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def find_pdf_text_mismatches(xml_data: XmlData, pdf_text: str) -> list[ErrorDetail]:
|
||||||
|
"""Check that the key XML values appear in the visible PDF text.
|
||||||
|
|
||||||
|
A hybrid invoice must show the same data in the PDF as in the XML. PDF
|
||||||
|
text extraction loses layout (columns run together, labels vary by
|
||||||
|
issuer), so this does not locate labelled fields. It searches the text
|
||||||
|
for the invoice number and for net, VAT and gross total in the usual
|
||||||
|
number notations and reports every value that occurs nowhere.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
xml_data: Parsed invoice data
|
||||||
|
pdf_text: Text extracted from the PDF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Warnings for XML values that are missing in the PDF text
|
||||||
|
"""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def add_missing(field: str, xml_value: Any) -> None:
|
||||||
|
errors.append(
|
||||||
|
ErrorDetail(
|
||||||
|
check="pdf_abgleich",
|
||||||
|
field=field,
|
||||||
|
error_code="pdf_mismatch",
|
||||||
|
message=(
|
||||||
|
f"PDF mismatch for '{field}': XML has {xml_value}, "
|
||||||
|
"which does not appear in the PDF text"
|
||||||
|
),
|
||||||
|
severity="warning",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Non-breaking and narrow spaces are used as thousands separators
|
||||||
|
text = re.sub(r"[\u00a0\u202f\u2009]", " ", pdf_text).replace("\u2019", "'")
|
||||||
|
compact_text = re.sub(r"\s+", "", text).lower()
|
||||||
|
|
||||||
|
invoice_number = re.sub(r"\s+", "", xml_data.invoice_number).lower()
|
||||||
|
if invoice_number and invoice_number not in compact_text:
|
||||||
|
add_missing("invoice_number", xml_data.invoice_number)
|
||||||
|
|
||||||
|
amounts = {
|
||||||
|
"totals.net": xml_data.totals.net,
|
||||||
|
"totals.vat_total": xml_data.totals.vat_total,
|
||||||
|
"totals.gross": xml_data.totals.gross,
|
||||||
|
}
|
||||||
|
for field, amount in amounts.items():
|
||||||
|
if not any(notation in text for notation in _amount_notations(amount)):
|
||||||
|
add_missing(field, amount)
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def validate_invoice(request: ValidateRequest) -> ValidationResult:
|
||||||
|
"""Run selected validation checks."""
|
||||||
|
start_time = time.time()
|
||||||
|
all_errors = []
|
||||||
|
all_warnings = []
|
||||||
|
|
||||||
|
checks_run = 0
|
||||||
|
checks_passed = 0
|
||||||
|
|
||||||
|
if not request.checks:
|
||||||
|
return ValidationResult(
|
||||||
|
is_valid=True,
|
||||||
|
errors=[],
|
||||||
|
warnings=[],
|
||||||
|
summary={
|
||||||
|
"total_checks": 0,
|
||||||
|
"checks_passed": 0,
|
||||||
|
"checks_failed": 0,
|
||||||
|
"critical_errors": 0,
|
||||||
|
"warnings": 0,
|
||||||
|
},
|
||||||
|
validation_time_ms=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
xml_data = XmlData(**request.xml_data)
|
||||||
|
except ValidationError as e:
|
||||||
|
# Convert Pydantic validation errors to ValidationResult
|
||||||
|
validation_errors: list[ErrorDetail] = []
|
||||||
|
for error in e.errors():
|
||||||
|
loc = error["loc"]
|
||||||
|
field = str(loc[0]) if loc else None
|
||||||
|
validation_errors.append(
|
||||||
|
ErrorDetail(
|
||||||
|
check="schema_validation",
|
||||||
|
field=field,
|
||||||
|
error_code=error["type"],
|
||||||
|
message=error["msg"],
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return ValidationResult(
|
||||||
|
is_valid=False,
|
||||||
|
errors=validation_errors,
|
||||||
|
warnings=[],
|
||||||
|
summary={
|
||||||
|
"total_checks": 1,
|
||||||
|
"checks_passed": 0,
|
||||||
|
"checks_failed": 1,
|
||||||
|
"critical_errors": len(validation_errors),
|
||||||
|
"warnings": 0,
|
||||||
|
},
|
||||||
|
validation_time_ms=int((time.time() - start_time) * 1000),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Run requested checks
|
||||||
|
for check_name in request.checks:
|
||||||
|
check_errors: list[ErrorDetail] = []
|
||||||
|
|
||||||
|
if check_name == "pflichtfelder":
|
||||||
|
check_errors = validate_pflichtfelder(xml_data, request.profile)
|
||||||
|
checks_run += 1
|
||||||
|
elif check_name == "betraege":
|
||||||
|
check_errors = validate_betraege(xml_data)
|
||||||
|
checks_run += 1
|
||||||
|
elif check_name == "ustid":
|
||||||
|
# Check supplier VAT ID
|
||||||
|
if xml_data.supplier.vat_id:
|
||||||
|
error = validate_ustid(xml_data.supplier.vat_id)
|
||||||
|
if error:
|
||||||
|
check_errors.append(error)
|
||||||
|
# Check buyer VAT ID if present
|
||||||
|
if xml_data.buyer.vat_id:
|
||||||
|
error = validate_ustid(xml_data.buyer.vat_id)
|
||||||
|
if error:
|
||||||
|
check_errors.append(error)
|
||||||
|
checks_run += 1
|
||||||
|
elif check_name == "pdf_abgleich":
|
||||||
|
if request.pdf_text and request.pdf_text.strip():
|
||||||
|
check_errors = find_pdf_text_mismatches(xml_data, request.pdf_text)
|
||||||
|
checks_run += 1
|
||||||
|
|
||||||
|
# Separate errors and warnings
|
||||||
|
critical_errors = [e for e in check_errors if e.severity == "critical"]
|
||||||
|
warnings = [e for e in check_errors if e.severity == "warning"]
|
||||||
|
all_errors.extend(critical_errors)
|
||||||
|
all_warnings.extend(warnings)
|
||||||
|
|
||||||
|
if len(critical_errors) == 0:
|
||||||
|
checks_passed += 1
|
||||||
|
|
||||||
|
validation_time_ms = int((time.time() - start_time) * 1000)
|
||||||
|
|
||||||
|
is_valid = len(all_errors) == 0
|
||||||
|
|
||||||
|
summary = {
|
||||||
|
"total_checks": checks_run,
|
||||||
|
"checks_passed": checks_passed,
|
||||||
|
"checks_failed": checks_run - checks_passed,
|
||||||
|
"critical_errors": len(all_errors),
|
||||||
|
"warnings": len(all_warnings),
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValidationResult(
|
||||||
|
is_valid=is_valid,
|
||||||
|
errors=all_errors,
|
||||||
|
warnings=all_warnings,
|
||||||
|
summary=summary,
|
||||||
|
validation_time_ms=validation_time_ms,
|
||||||
|
)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Test suite for ZUGFeRD service."""
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
"""Pytest configuration and shared fixtures."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def sample_pdf_bytes():
|
||||||
|
"""Fixture providing sample PDF bytes for testing."""
|
||||||
|
return b"%PDF-1.4\n%fake pdf content for testing\n%%EOF"
|
||||||
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
+74
@@ -0,0 +1,74 @@
|
|||||||
|
# ZUGFeRD Test Fixture Manifest
|
||||||
|
|
||||||
|
This directory contains sample PDFs for testing ZUGFeRD extraction and validation.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
| Filename | Profile | Description |
|
||||||
|
|-----------|----------|-------------|
|
||||||
|
| EN16931_1_Teilrechnung.pdf | EN16931 | Official FeRD test invoice - partial invoice (Teilrechnung) with full UN/CEFACT data |
|
||||||
|
| EN16931_Einfach.pdf | EN16931 | Official FeRD test invoice - simple invoice (Einfach) with UN/CEFACT data |
|
||||||
|
| attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf | EN16931 | ZUGFeRD 2.0 EN16931 profile using attribute-based XMP metadata |
|
||||||
|
| zugferd_invoice.pdf | ZUGFeRD 1.0 | Basic ZUGFeRD v1.0 invoice (likely BASIC or COMFORT profile) |
|
||||||
|
| validAvoir_FR_type380_BASICWL.pdf | BASIC WL | French credit note (avoir) with BASIC WL profile |
|
||||||
|
| zugferd_2p1_EXTENDED_PDFA-3A.pdf | EXTENDED | ZUGFeRD 2.1 EXTENDED profile with PDF/A-3A conformance |
|
||||||
|
| validXRechnung.pdf | XRechnung | German XRechnung format (similar to EN16931 but German profile) |
|
||||||
|
| ZTESTZUGFERD_1_INVDSS_012015738820PDF-1.pdf | ZUGFeRD 1.0 | Historical ZUGFeRD v1.0 test invoice from 2015 |
|
||||||
|
| MustangBeispiel20221026.pdf | EN16931 | Modern sample from Mustang project (October 2022) |
|
||||||
|
| ORDER-X_EX01_ORDER_FULL_DATA-COMFORT.pdf | ORDER-X | Order-X format (related to ZUGFeRD but for orders) |
|
||||||
|
| EmptyPDFA1.pdf | None | Empty PDF/A-1 document - no ZUGFeRD data (negative test case) |
|
||||||
|
|
||||||
|
## Real-World Invoices (anonymized) - `real/`
|
||||||
|
|
||||||
|
Anonymized XML from real production invoices that once revealed service bugs.
|
||||||
|
Each file must contain **no real names, addresses, tax numbers, bank details,
|
||||||
|
or document numbers** (verified at creation time). Never commit original
|
||||||
|
invoice PDFs here.
|
||||||
|
|
||||||
|
| Filename | Profile | Origin bug |
|
||||||
|
|-----------|----------|------------|
|
||||||
|
| extended_fc_steuernummer_basisqty.xml | EXTENDED | FC-only tax registration ignored, unit price with basis quantity 100 misread, spaced VAT ID rejected, contact email dropped (2026-09) |
|
||||||
|
|
||||||
|
## Plain XML Invoices - `xml/`
|
||||||
|
|
||||||
|
Official KoSIT XRechnung test-suite business case 01.01a, the same invoice
|
||||||
|
in both syntaxes (source: https://github.com/itplr-kosit/xrechnung-testsuite,
|
||||||
|
Apache License 2.0).
|
||||||
|
|
||||||
|
| Filename | Profile | Syntax |
|
||||||
|
|-----------|----------|--------|
|
||||||
|
| xrechnung_01.01a_cii.xml | XRechnung 3.0 | CII |
|
||||||
|
| xrechnung_01.01a_ubl.xml | XRechnung 3.0 | UBL |
|
||||||
|
|
||||||
|
## Profile Coverage
|
||||||
|
|
||||||
|
- **MINIMUM**: Not covered (future addition)
|
||||||
|
- **BASIC**: Covered by `zugferd_invoice.pdf`
|
||||||
|
- **BASIC WL**: Covered by `validAvoir_FR_type380_BASICWL.pdf`
|
||||||
|
- **EN16931**: Covered by multiple samples
|
||||||
|
- **EXTENDED**: Covered by `zugferd_2p1_EXTENDED_PDFA-3A.pdf`
|
||||||
|
- **None (negative test)**: Covered by `EmptyPDFA1.pdf`
|
||||||
|
|
||||||
|
## Version Coverage
|
||||||
|
|
||||||
|
- ZUGFeRD 1.0: `ZTESTZUGFERD_1_INVDSS_012015738820PDF-1.pdf`, `zugferd_invoice.pdf`
|
||||||
|
- ZUGFeRD 2.0: `attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf`
|
||||||
|
- ZUGFeRD 2.1: `zugferd_2p1_EXTENDED_PDFA-3A.pdf`
|
||||||
|
- XRechnung: `validXRechnung.pdf`
|
||||||
|
|
||||||
|
## Source URLs
|
||||||
|
|
||||||
|
- ZUGFeRD Mustang project: https://github.com/ZUGFeRD/mustangproject
|
||||||
|
- Library test resources: `library/src/test/resources/`
|
||||||
|
- Validator test resources: `validator/src/test/resources/`
|
||||||
|
- CLI test resources: `Mustang-CLI/src/test/resources/`
|
||||||
|
- FeRD test invoices: https://www.ferd-net.de/download/testrechnungen (URL was 404 - samples obtained from Mustang project)
|
||||||
|
- factur-x library tests: https://github.com/akretion/factur-x/tree/master/tests (no PDFs found in repository)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- All files are authentic ZUGFeRD/Factur-X samples from the reference implementation (Mustang project)
|
||||||
|
- Files cover multiple profiles and versions of the ZUGFeRD standard
|
||||||
|
- Negative test case included: `EmptyPDFA1.pdf` is a valid PDF/A-1 but contains no ZUGFeRD XML data
|
||||||
|
- ORDER-X sample included for completeness, though it's a different but related format
|
||||||
|
- File sizes range from 38KB to 684KB
|
||||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,245 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<rsm:CrossIndustryInvoice xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
|
||||||
|
<rsm:ExchangedDocumentContext>
|
||||||
|
<ram:GuidelineSpecifiedDocumentContextParameter>
|
||||||
|
<ram:ID>urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended</ram:ID>
|
||||||
|
</ram:GuidelineSpecifiedDocumentContextParameter>
|
||||||
|
</rsm:ExchangedDocumentContext>
|
||||||
|
<rsm:ExchangedDocument>
|
||||||
|
<ram:ID>4711</ram:ID>
|
||||||
|
<ram:TypeCode>380</ram:TypeCode>
|
||||||
|
<ram:IssueDateTime>
|
||||||
|
<udt:DateTimeString format="102">20260903</udt:DateTimeString>
|
||||||
|
</ram:IssueDateTime>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:Content>Beispielwerkstatt Musterland e.V.
|
||||||
|
Werkstatt Musterstadt/Musterdorf
|
||||||
|
Musterstraße 11
|
||||||
|
01234 Musterstadt
|
||||||
|
Deutschland
|
||||||
|
Steuernummer: 1112223334444</ram:Content>
|
||||||
|
<ram:SubjectCode>REG</ram:SubjectCode>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
</rsm:ExchangedDocument>
|
||||||
|
<rsm:SupplyChainTradeTransaction>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>1</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SellerAssignedID>ART-0001</ram:SellerAssignedID>
|
||||||
|
<ram:BuyerAssignedID>KUNDE-0001</ram:BuyerAssignedID>
|
||||||
|
<ram:Name>Befestigungsset Typ M100</ram:Name>
|
||||||
|
<ram:Description>KUNDE-0001</ram:Description>
|
||||||
|
</ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID>BEST-000001</ram:IssuerAssignedID>
|
||||||
|
</ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount>75.85</ram:ChargeAmount>
|
||||||
|
<ram:BasisQuantity unitCode="C62">100</ram:BasisQuantity>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="C62">140</ram:BilledQuantity>
|
||||||
|
<ram:ActualDeliverySupplyChainEvent>
|
||||||
|
<ram:OccurrenceDateTime>
|
||||||
|
<udt:DateTimeString format="102">20260804</udt:DateTimeString>
|
||||||
|
</ram:OccurrenceDateTime>
|
||||||
|
</ram:ActualDeliverySupplyChainEvent>
|
||||||
|
<ram:DeliveryNoteReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID>LS-000001</ram:IssuerAssignedID>
|
||||||
|
<ram:LineID>1</ram:LineID>
|
||||||
|
<ram:FormattedIssueDateTime>
|
||||||
|
<qdt:DateTimeString format="102">20260804</qdt:DateTimeString>
|
||||||
|
</ram:FormattedIssueDateTime>
|
||||||
|
</ram:DeliveryNoteReferencedDocument>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>true</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:Reason>GK-Zuschlag</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>false</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:ReasonCode>71</ram:ReasonCode>
|
||||||
|
<ram:Reason>Mengenrabatt</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>false</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:Reason>Kundenrabatt</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>106.19</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>2</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SellerAssignedID>ART-0001</ram:SellerAssignedID>
|
||||||
|
<ram:BuyerAssignedID>KUNDE-0001</ram:BuyerAssignedID>
|
||||||
|
<ram:Name>Befestigungsset Typ M100</ram:Name>
|
||||||
|
<ram:Description>KUNDE-0001</ram:Description>
|
||||||
|
</ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID>BEST-000001</ram:IssuerAssignedID>
|
||||||
|
</ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount>75.85</ram:ChargeAmount>
|
||||||
|
<ram:BasisQuantity unitCode="C62">100</ram:BasisQuantity>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="C62">50</ram:BilledQuantity>
|
||||||
|
<ram:ActualDeliverySupplyChainEvent>
|
||||||
|
<ram:OccurrenceDateTime>
|
||||||
|
<udt:DateTimeString format="102">20260804</udt:DateTimeString>
|
||||||
|
</ram:OccurrenceDateTime>
|
||||||
|
</ram:ActualDeliverySupplyChainEvent>
|
||||||
|
<ram:DeliveryNoteReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID>LS-000001</ram:IssuerAssignedID>
|
||||||
|
<ram:LineID>2</ram:LineID>
|
||||||
|
<ram:FormattedIssueDateTime>
|
||||||
|
<qdt:DateTimeString format="102">20260804</qdt:DateTimeString>
|
||||||
|
</ram:FormattedIssueDateTime>
|
||||||
|
</ram:DeliveryNoteReferencedDocument>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>true</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:Reason>GK-Zuschlag</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>false</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:ReasonCode>71</ram:ReasonCode>
|
||||||
|
<ram:Reason>Mengenrabatt</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:ChargeIndicator>
|
||||||
|
<udt:Indicator>false</udt:Indicator>
|
||||||
|
</ram:ChargeIndicator>
|
||||||
|
<ram:ActualAmount>0</ram:ActualAmount>
|
||||||
|
<ram:Reason>Kundenrabatt</ram:Reason>
|
||||||
|
</ram:SpecifiedTradeAllowanceCharge>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>37.93</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:SellerTradeParty>
|
||||||
|
<ram:ID>10001</ram:ID>
|
||||||
|
<ram:Name>Beispielwerkstatt Musterland e.V.
|
||||||
|
Werkstatt Musterstadt/Musterdorf</ram:Name>
|
||||||
|
<ram:DefinedTradeContact>
|
||||||
|
<ram:PersonName>Erika Mustermann</ram:PersonName>
|
||||||
|
<ram:EmailURIUniversalCommunication>
|
||||||
|
<ram:URIID>rechnung@beispielwerkstatt.example</ram:URIID>
|
||||||
|
</ram:EmailURIUniversalCommunication>
|
||||||
|
</ram:DefinedTradeContact>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>01234</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>Musterstraße 11</ram:LineOne>
|
||||||
|
<ram:CityName>Musterstadt</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
<ram:SpecifiedTaxRegistration>
|
||||||
|
<ram:ID schemeID="FC">1112223334444</ram:ID>
|
||||||
|
</ram:SpecifiedTaxRegistration>
|
||||||
|
</ram:SellerTradeParty>
|
||||||
|
<ram:BuyerTradeParty>
|
||||||
|
<ram:Name>Beispiel Kauf GmbH</ram:Name>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>05432</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>Musterweg 2</ram:LineOne>
|
||||||
|
<ram:CityName>Musterdorf</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
<ram:SpecifiedTaxRegistration>
|
||||||
|
<ram:ID schemeID="VA">DE 123 456 789</ram:ID>
|
||||||
|
</ram:SpecifiedTaxRegistration>
|
||||||
|
</ram:BuyerTradeParty>
|
||||||
|
<ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID>BEST-000001</ram:IssuerAssignedID>
|
||||||
|
</ram:BuyerOrderReferencedDocument>
|
||||||
|
</ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:ApplicableHeaderTradeDelivery>
|
||||||
|
<ram:ShipToTradeParty>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
</ram:ShipToTradeParty>
|
||||||
|
<ram:ActualDeliverySupplyChainEvent>
|
||||||
|
<ram:OccurrenceDateTime>
|
||||||
|
<udt:DateTimeString format="102">20260903</udt:DateTimeString>
|
||||||
|
</ram:OccurrenceDateTime>
|
||||||
|
</ram:ActualDeliverySupplyChainEvent>
|
||||||
|
</ram:ApplicableHeaderTradeDelivery>
|
||||||
|
<ram:ApplicableHeaderTradeSettlement>
|
||||||
|
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
|
||||||
|
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:TypeCode>58</ram:TypeCode>
|
||||||
|
<ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<ram:IBANID>DE89370400440532013000</ram:IBANID>
|
||||||
|
<ram:AccountName>Beispielwerkstatt Musterland e.V.
|
||||||
|
Werkstatt Musterstadt/Musterdorf</ram:AccountName>
|
||||||
|
</ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
|
<ram:BICID>MARKDEF1100</ram:BICID>
|
||||||
|
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
|
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:CalculatedAmount>10.09</ram:CalculatedAmount>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:BasisAmount>144.12</ram:BasisAmount>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:Description>zahlbar innerhalb 14 Tage ab Rechnungsdatum netto</ram:Description>
|
||||||
|
<ram:DueDateDateTime>
|
||||||
|
<udt:DateTimeString format="102">20260917</udt:DateTimeString>
|
||||||
|
</ram:DueDateDateTime>
|
||||||
|
</ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>144.12</ram:LineTotalAmount>
|
||||||
|
<ram:TaxBasisTotalAmount>144.12</ram:TaxBasisTotalAmount>
|
||||||
|
<ram:TaxTotalAmount currencyID="EUR">10.09</ram:TaxTotalAmount>
|
||||||
|
<ram:RoundingAmount>0</ram:RoundingAmount>
|
||||||
|
<ram:GrandTotalAmount>154.21</ram:GrandTotalAmount>
|
||||||
|
<ram:TotalPrepaidAmount>0</ram:TotalPrepaidAmount>
|
||||||
|
<ram:DuePayableAmount>154.21</ram:DuePayableAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
</ram:ApplicableHeaderTradeSettlement>
|
||||||
|
</rsm:SupplyChainTradeTransaction>
|
||||||
|
</rsm:CrossIndustryInvoice>
|
||||||
Binary file not shown.
Vendored
BIN
Binary file not shown.
+171
@@ -0,0 +1,171 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
||||||
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
|
||||||
|
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
|
||||||
|
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
|
||||||
|
<rsm:ExchangedDocumentContext>
|
||||||
|
<ram:BusinessProcessSpecifiedDocumentContextParameter>
|
||||||
|
<ram:ID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ram:ID>
|
||||||
|
</ram:BusinessProcessSpecifiedDocumentContextParameter>
|
||||||
|
<ram:GuidelineSpecifiedDocumentContextParameter>
|
||||||
|
<ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</ram:ID>
|
||||||
|
</ram:GuidelineSpecifiedDocumentContextParameter>
|
||||||
|
</rsm:ExchangedDocumentContext>
|
||||||
|
<rsm:ExchangedDocument>
|
||||||
|
<ram:ID>123456XX</ram:ID>
|
||||||
|
<ram:TypeCode>380</ram:TypeCode>
|
||||||
|
<ram:IssueDateTime>
|
||||||
|
<udt:DateTimeString format="102">20160404</udt:DateTimeString>
|
||||||
|
</ram:IssueDateTime>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:Content>Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden.</ram:Content>
|
||||||
|
<ram:SubjectCode>ADU</ram:SubjectCode>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
</rsm:ExchangedDocument>
|
||||||
|
<rsm:SupplyChainTradeTransaction>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>Zeitschrift [...]</ram:LineID>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:Content>Die letzte Lieferung im Rahmen des abgerechneten Abonnements erfolgt in 12/2016 Lieferung erfolgt / erfolgte direkt vom Verlag</ram:Content>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SellerAssignedID>246</ram:SellerAssignedID>
|
||||||
|
<ram:Name>Zeitschrift [...]</ram:Name>
|
||||||
|
<ram:Description>Zeitschrift Inland</ram:Description>
|
||||||
|
<ram:DesignatedProductClassification>
|
||||||
|
<ram:ClassCode listID="IB">0721-880X</ram:ClassCode>
|
||||||
|
</ram:DesignatedProductClassification>
|
||||||
|
</ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:LineID>6171175.1</ram:LineID>
|
||||||
|
</ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount>288.79</ram:ChargeAmount>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="XPP">1</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:BillingSpecifiedPeriod>
|
||||||
|
<ram:StartDateTime>
|
||||||
|
<udt:DateTimeString format="102">20160101</udt:DateTimeString>
|
||||||
|
</ram:StartDateTime>
|
||||||
|
<ram:EndDateTime>
|
||||||
|
<udt:DateTimeString format="102">20161231</udt:DateTimeString>
|
||||||
|
</ram:EndDateTime>
|
||||||
|
</ram:BillingSpecifiedPeriod>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>288.79</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>Porto + Versandkosten</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedTradeProduct>
|
||||||
|
<ram:Name>Porto + Versandkosten</ram:Name>
|
||||||
|
</ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount>26.07</ram:ChargeAmount>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="XPP">1</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>26.07</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:BuyerReference>04011000-12345-03</ram:BuyerReference>
|
||||||
|
<ram:SellerTradeParty>
|
||||||
|
<ram:Name>[Seller name]</ram:Name>
|
||||||
|
<ram:Description>123/456/7890, HRA-Eintrag in […]</ram:Description>
|
||||||
|
<ram:SpecifiedLegalOrganization>
|
||||||
|
<ram:ID>[HRA-Eintrag]</ram:ID>
|
||||||
|
<ram:TradingBusinessName>[Seller trading name]</ram:TradingBusinessName>
|
||||||
|
</ram:SpecifiedLegalOrganization>
|
||||||
|
<ram:DefinedTradeContact>
|
||||||
|
<ram:PersonName>nicht vorhanden</ram:PersonName>
|
||||||
|
<ram:TelephoneUniversalCommunication>
|
||||||
|
<ram:CompleteNumber>+49 1234-5678</ram:CompleteNumber>
|
||||||
|
</ram:TelephoneUniversalCommunication>
|
||||||
|
<ram:EmailURIUniversalCommunication>
|
||||||
|
<ram:URIID>seller@email.de</ram:URIID>
|
||||||
|
</ram:EmailURIUniversalCommunication>
|
||||||
|
</ram:DefinedTradeContact>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>12345</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>[Seller address line 1]</ram:LineOne>
|
||||||
|
<ram:CityName>[Seller city]</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
<ram:URIUniversalCommunication>
|
||||||
|
<ram:URIID schemeID="EM">seller@email.de</ram:URIID>
|
||||||
|
</ram:URIUniversalCommunication>
|
||||||
|
<ram:SpecifiedTaxRegistration>
|
||||||
|
<ram:ID schemeID="VA">DE 123456789</ram:ID>
|
||||||
|
</ram:SpecifiedTaxRegistration>
|
||||||
|
</ram:SellerTradeParty>
|
||||||
|
<ram:BuyerTradeParty>
|
||||||
|
<ram:ID>[Buyer identifier]</ram:ID>
|
||||||
|
<ram:Name>[Buyer name]</ram:Name>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>12345</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>[Buyer address line 1]</ram:LineOne>
|
||||||
|
<ram:CityName>[Buyer city]</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
<ram:URIUniversalCommunication>
|
||||||
|
<ram:URIID schemeID="EM">buyer@info.de</ram:URIID>
|
||||||
|
</ram:URIUniversalCommunication>
|
||||||
|
</ram:BuyerTradeParty>
|
||||||
|
</ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:ApplicableHeaderTradeDelivery/>
|
||||||
|
<ram:ApplicableHeaderTradeSettlement>
|
||||||
|
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
|
||||||
|
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:TypeCode>58</ram:TypeCode>
|
||||||
|
<ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<!-- dies ist eine nicht existerende aber valide IBAN als test dummy -->
|
||||||
|
<ram:IBANID>DE79000000001234567890</ram:IBANID>
|
||||||
|
</ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:CalculatedAmount>22.04</ram:CalculatedAmount>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:BasisAmount>314.86</ram:BasisAmount>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:Description>Zahlbar sofort ohne Abzug.</ram:Description>
|
||||||
|
</ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>314.86</ram:LineTotalAmount>
|
||||||
|
<ram:TaxBasisTotalAmount>314.86</ram:TaxBasisTotalAmount>
|
||||||
|
<ram:TaxTotalAmount currencyID="EUR">22.04</ram:TaxTotalAmount>
|
||||||
|
<ram:GrandTotalAmount>336.9</ram:GrandTotalAmount>
|
||||||
|
<ram:DuePayableAmount>336.9</ram:DuePayableAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
</ram:ApplicableHeaderTradeSettlement>
|
||||||
|
</rsm:SupplyChainTradeTransaction>
|
||||||
|
</rsm:CrossIndustryInvoice>
|
||||||
+145
@@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ubl:Invoice xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
|
||||||
|
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||||
|
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
||||||
|
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</cbc:CustomizationID>
|
||||||
|
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
|
||||||
|
<cbc:ID>123456XX</cbc:ID>
|
||||||
|
<cbc:IssueDate>2016-04-04</cbc:IssueDate>
|
||||||
|
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
|
||||||
|
<cbc:Note>#ADU#Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden.</cbc:Note>
|
||||||
|
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
||||||
|
<cbc:BuyerReference>04011000-12345-03</cbc:BuyerReference>
|
||||||
|
<cac:AccountingSupplierParty>
|
||||||
|
<cac:Party>
|
||||||
|
<cbc:EndpointID schemeID="EM">seller@email.de</cbc:EndpointID>
|
||||||
|
<cac:PartyName>
|
||||||
|
<cbc:Name>[Seller trading name]</cbc:Name>
|
||||||
|
</cac:PartyName>
|
||||||
|
<cac:PostalAddress>
|
||||||
|
<cbc:StreetName>[Seller address line 1]</cbc:StreetName>
|
||||||
|
<cbc:CityName>[Seller city]</cbc:CityName>
|
||||||
|
<cbc:PostalZone>12345</cbc:PostalZone>
|
||||||
|
<cac:Country>
|
||||||
|
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
||||||
|
</cac:Country>
|
||||||
|
</cac:PostalAddress>
|
||||||
|
<cac:PartyTaxScheme>
|
||||||
|
<cbc:CompanyID>DE 123456789</cbc:CompanyID>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:PartyTaxScheme>
|
||||||
|
<cac:PartyLegalEntity>
|
||||||
|
<cbc:RegistrationName>[Seller name]</cbc:RegistrationName>
|
||||||
|
<cbc:CompanyID>[HRA-Eintrag]</cbc:CompanyID>
|
||||||
|
<cbc:CompanyLegalForm>123/456/7890, HRA-Eintrag in […]</cbc:CompanyLegalForm>
|
||||||
|
</cac:PartyLegalEntity>
|
||||||
|
<cac:Contact>
|
||||||
|
<cbc:Name>nicht vorhanden</cbc:Name>
|
||||||
|
<cbc:Telephone>+49 1234-5678</cbc:Telephone>
|
||||||
|
<cbc:ElectronicMail>seller@email.de</cbc:ElectronicMail>
|
||||||
|
</cac:Contact>
|
||||||
|
</cac:Party>
|
||||||
|
</cac:AccountingSupplierParty>
|
||||||
|
<cac:AccountingCustomerParty>
|
||||||
|
<cac:Party>
|
||||||
|
<cbc:EndpointID schemeID="EM">buyer@info.de</cbc:EndpointID>
|
||||||
|
<cac:PartyIdentification>
|
||||||
|
<cbc:ID>[Buyer identifier]</cbc:ID>
|
||||||
|
</cac:PartyIdentification>
|
||||||
|
<cac:PostalAddress>
|
||||||
|
<cbc:StreetName>[Buyer address line 1]</cbc:StreetName>
|
||||||
|
<cbc:CityName>[Buyer city]</cbc:CityName>
|
||||||
|
<cbc:PostalZone>12345</cbc:PostalZone>
|
||||||
|
<cac:Country>
|
||||||
|
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
||||||
|
</cac:Country>
|
||||||
|
</cac:PostalAddress>
|
||||||
|
<cac:PartyLegalEntity>
|
||||||
|
<cbc:RegistrationName>[Buyer name]</cbc:RegistrationName>
|
||||||
|
</cac:PartyLegalEntity>
|
||||||
|
</cac:Party>
|
||||||
|
</cac:AccountingCustomerParty>
|
||||||
|
<cac:PaymentMeans>
|
||||||
|
<cbc:PaymentMeansCode>58</cbc:PaymentMeansCode>
|
||||||
|
<cac:PayeeFinancialAccount>
|
||||||
|
<!-- dies ist eine nicht existerende aber valide IBAN als test dummy -->
|
||||||
|
<cbc:ID>DE79000000001234567890</cbc:ID>
|
||||||
|
</cac:PayeeFinancialAccount>
|
||||||
|
</cac:PaymentMeans>
|
||||||
|
<cac:PaymentTerms>
|
||||||
|
<cbc:Note>Zahlbar sofort ohne Abzug.</cbc:Note>
|
||||||
|
</cac:PaymentTerms>
|
||||||
|
<cac:TaxTotal>
|
||||||
|
<cbc:TaxAmount currencyID="EUR">22.04</cbc:TaxAmount>
|
||||||
|
<cac:TaxSubtotal>
|
||||||
|
<cbc:TaxableAmount currencyID="EUR">314.86</cbc:TaxableAmount>
|
||||||
|
<cbc:TaxAmount currencyID="EUR">22.04</cbc:TaxAmount>
|
||||||
|
<cac:TaxCategory>
|
||||||
|
<cbc:ID>S</cbc:ID>
|
||||||
|
<cbc:Percent>7</cbc:Percent>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:TaxCategory>
|
||||||
|
</cac:TaxSubtotal>
|
||||||
|
</cac:TaxTotal>
|
||||||
|
<cac:LegalMonetaryTotal>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">314.86</cbc:LineExtensionAmount>
|
||||||
|
<cbc:TaxExclusiveAmount currencyID="EUR">314.86</cbc:TaxExclusiveAmount>
|
||||||
|
<cbc:TaxInclusiveAmount currencyID="EUR">336.9</cbc:TaxInclusiveAmount>
|
||||||
|
<cbc:PayableAmount currencyID="EUR">336.9</cbc:PayableAmount>
|
||||||
|
</cac:LegalMonetaryTotal>
|
||||||
|
<cac:InvoiceLine>
|
||||||
|
<cbc:ID>Zeitschrift [...]</cbc:ID>
|
||||||
|
<cbc:Note>Die letzte Lieferung im Rahmen des abgerechneten Abonnements erfolgt in 12/2016 Lieferung erfolgt / erfolgte direkt vom Verlag</cbc:Note>
|
||||||
|
<cbc:InvoicedQuantity unitCode="XPP">1</cbc:InvoicedQuantity>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">288.79</cbc:LineExtensionAmount>
|
||||||
|
<cac:InvoicePeriod>
|
||||||
|
<cbc:StartDate>2016-01-01</cbc:StartDate>
|
||||||
|
<cbc:EndDate>2016-12-31</cbc:EndDate>
|
||||||
|
</cac:InvoicePeriod>
|
||||||
|
<cac:OrderLineReference>
|
||||||
|
<cbc:LineID>6171175.1</cbc:LineID>
|
||||||
|
</cac:OrderLineReference>
|
||||||
|
<cac:Item>
|
||||||
|
<cbc:Description>Zeitschrift Inland</cbc:Description>
|
||||||
|
<cbc:Name>Zeitschrift [...]</cbc:Name>
|
||||||
|
<cac:SellersItemIdentification>
|
||||||
|
<cbc:ID>246</cbc:ID>
|
||||||
|
</cac:SellersItemIdentification>
|
||||||
|
<cac:CommodityClassification>
|
||||||
|
<cbc:ItemClassificationCode listID="IB">0721-880X</cbc:ItemClassificationCode>
|
||||||
|
</cac:CommodityClassification>
|
||||||
|
<cac:ClassifiedTaxCategory>
|
||||||
|
<cbc:ID>S</cbc:ID>
|
||||||
|
<cbc:Percent>7</cbc:Percent>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:ClassifiedTaxCategory>
|
||||||
|
</cac:Item>
|
||||||
|
<cac:Price>
|
||||||
|
<cbc:PriceAmount currencyID="EUR">288.79</cbc:PriceAmount>
|
||||||
|
</cac:Price>
|
||||||
|
</cac:InvoiceLine>
|
||||||
|
<cac:InvoiceLine>
|
||||||
|
<cbc:ID>Porto + Versandkosten</cbc:ID>
|
||||||
|
<cbc:InvoicedQuantity unitCode="XPP">1</cbc:InvoicedQuantity>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">26.07</cbc:LineExtensionAmount>
|
||||||
|
<cac:Item>
|
||||||
|
<cbc:Name>Porto + Versandkosten</cbc:Name>
|
||||||
|
<cac:ClassifiedTaxCategory>
|
||||||
|
<cbc:ID>S</cbc:ID>
|
||||||
|
<cbc:Percent>7</cbc:Percent>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:ClassifiedTaxCategory>
|
||||||
|
</cac:Item>
|
||||||
|
<cac:Price>
|
||||||
|
<cbc:PriceAmount currencyID="EUR">26.07</cbc:PriceAmount>
|
||||||
|
</cac:Price>
|
||||||
|
</cac:InvoiceLine>
|
||||||
|
</ubl:Invoice>
|
||||||
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,124 @@
|
|||||||
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
from src.main import app, configure_logging
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
return TestClient(app)
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_valid_zugferd(client):
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_base64 = base64.b64encode(f.read()).decode()
|
||||||
|
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["is_zugferd"] is True
|
||||||
|
assert data["zugferd_profil"] == "EN16931"
|
||||||
|
assert "xml_raw" in data
|
||||||
|
assert "xml_data" in data
|
||||||
|
assert "pdf_text" in data
|
||||||
|
assert "extraction_meta" in data
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_non_zugferd(client):
|
||||||
|
with open("tests/fixtures/EmptyPDFA1.pdf", "rb") as f:
|
||||||
|
pdf_base64 = base64.b64encode(f.read()).decode()
|
||||||
|
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["is_zugferd"] is False
|
||||||
|
assert data["zugferd_profil"] is None
|
||||||
|
assert "pdf_text" in data
|
||||||
|
assert "extraction_meta" in data
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_invalid_base64(client):
|
||||||
|
response = client.post("/extract", json={"pdf_base64": "invalid!!!"})
|
||||||
|
assert response.status_code == 400
|
||||||
|
data = response.json()
|
||||||
|
assert data["error"] == "invalid_base64"
|
||||||
|
assert "message" in data
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_non_pdf(client):
|
||||||
|
pdf_base64 = base64.b64encode(b"Hello World").decode()
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 400
|
||||||
|
data = response.json()
|
||||||
|
assert "error" in data
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_pflichtfelder(client):
|
||||||
|
response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": {
|
||||||
|
"invoice_number": "RE-001",
|
||||||
|
"invoice_date": "2025-02-04",
|
||||||
|
"supplier": {"name": "Test GmbH", "vat_id": "DE123456789"},
|
||||||
|
"buyer": {"name": "Kunde AG"},
|
||||||
|
"totals": {
|
||||||
|
"net": 100.0,
|
||||||
|
"gross": 119.0,
|
||||||
|
"vat_total": 19.0,
|
||||||
|
"line_total_sum": 100.0,
|
||||||
|
},
|
||||||
|
"line_items": [
|
||||||
|
{
|
||||||
|
"position": 1,
|
||||||
|
"description": "Test",
|
||||||
|
"quantity": 1.0,
|
||||||
|
"unit": "Stück",
|
||||||
|
"unit_price": 100.0,
|
||||||
|
"line_total": 100.0,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"checks": ["pflichtfelder"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert "result" in data
|
||||||
|
assert "is_valid" in data["result"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_empty_checks(client):
|
||||||
|
response = client.post("/validate", json={"xml_data": {}, "checks": []})
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
class TestLogLevel:
|
||||||
|
"""LOG_LEVEL environment variable controls the service log level."""
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def _restore_level(self):
|
||||||
|
yield
|
||||||
|
logging.getLogger("src").setLevel(logging.INFO)
|
||||||
|
|
||||||
|
def test_log_level_from_env(self, monkeypatch):
|
||||||
|
monkeypatch.setenv("LOG_LEVEL", "debug")
|
||||||
|
configure_logging()
|
||||||
|
|
||||||
|
assert logging.getLogger("src").level == logging.DEBUG
|
||||||
|
assert logging.getLogger("src.extractor").getEffectiveLevel() == logging.DEBUG
|
||||||
|
|
||||||
|
def test_default_is_info(self, monkeypatch):
|
||||||
|
monkeypatch.delenv("LOG_LEVEL", raising=False)
|
||||||
|
configure_logging()
|
||||||
|
|
||||||
|
assert logging.getLogger("src").level == logging.INFO
|
||||||
|
|
||||||
|
def test_invalid_value_falls_back_to_info(self, monkeypatch):
|
||||||
|
monkeypatch.setenv("LOG_LEVEL", "chatty")
|
||||||
|
configure_logging()
|
||||||
|
|
||||||
|
assert logging.getLogger("src").level == logging.INFO
|
||||||
@@ -0,0 +1,520 @@
|
|||||||
|
"""Tests for ZUGFeRD extractor.
|
||||||
|
|
||||||
|
Tests are written following TDD: FAILING TESTS FIRST (RED phase),
|
||||||
|
then implementation makes them pass (GREEN phase).
|
||||||
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import binascii
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pypdf import PdfReader, PdfWriter
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractionError:
|
||||||
|
"""Test ExtractionError exception class."""
|
||||||
|
|
||||||
|
def test_extraction_error_initialization(self):
|
||||||
|
"""Test ExtractionError can be created with all fields."""
|
||||||
|
from src.extractor import ExtractionError
|
||||||
|
|
||||||
|
error = ExtractionError(
|
||||||
|
error_code="corrupt_pdf",
|
||||||
|
message="PDF is corrupted",
|
||||||
|
details="Trailer not found",
|
||||||
|
)
|
||||||
|
assert error.error_code == "corrupt_pdf"
|
||||||
|
assert error.message == "PDF is corrupted"
|
||||||
|
assert error.details == "Trailer not found"
|
||||||
|
|
||||||
|
def test_extraction_error_without_details(self):
|
||||||
|
"""Test ExtractionError can be created without details."""
|
||||||
|
from src.extractor import ExtractionError
|
||||||
|
|
||||||
|
error = ExtractionError(error_code="invalid_pdf", message="Not a PDF file")
|
||||||
|
assert error.error_code == "invalid_pdf"
|
||||||
|
assert error.message == "Not a PDF file"
|
||||||
|
assert error.details == ""
|
||||||
|
|
||||||
|
def test_extraction_error_is_exception(self):
|
||||||
|
"""Test ExtractionError is a proper exception."""
|
||||||
|
from src.extractor import ExtractionError
|
||||||
|
|
||||||
|
error = ExtractionError(error_code="file_too_large", message="File too large")
|
||||||
|
assert isinstance(error, Exception)
|
||||||
|
assert str(error) == "File too large"
|
||||||
|
|
||||||
|
|
||||||
|
class TestFileSizeValidation:
|
||||||
|
"""Test file size validation in extract_zugferd()."""
|
||||||
|
|
||||||
|
def test_file_size_limit_exactly_10mb(self):
|
||||||
|
"""Test PDF exactly at 10MB limit passes size check but fails PDF parsing."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
# 10MB = 10 * 1024 * 1024 bytes
|
||||||
|
large_pdf = b"X" * (10 * 1024 * 1024)
|
||||||
|
|
||||||
|
# 10MB exactly is allowed (not > 10MB), but invalid PDF data causes parse error
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_zugferd(large_pdf)
|
||||||
|
|
||||||
|
# Should fail PDF parsing, not file size check
|
||||||
|
assert exc_info.value.error_code in ["corrupt_pdf", "invalid_pdf"]
|
||||||
|
|
||||||
|
def test_file_size_limit_10mb_plus_one_byte(self):
|
||||||
|
"""Test PDF one byte over 10MB limit is rejected."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
# 10MB + 1 byte
|
||||||
|
too_large = b"X" * (10 * 1024 * 1024 + 1)
|
||||||
|
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_zugferd(too_large)
|
||||||
|
|
||||||
|
assert exc_info.value.error_code == "file_too_large"
|
||||||
|
|
||||||
|
def test_file_size_under_10mb_accepted(self):
|
||||||
|
"""Test PDF under 10MB is accepted for processing."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
# Small PDF (9MB)
|
||||||
|
small_pdf = b"X" * (9 * 1024 * 1024)
|
||||||
|
|
||||||
|
# Should process (even if invalid PDF, different error)
|
||||||
|
try:
|
||||||
|
extract_zugferd(small_pdf)
|
||||||
|
except ExtractionError as e:
|
||||||
|
# Different error is expected (not file_too_large)
|
||||||
|
assert e.error_code != "file_too_large"
|
||||||
|
|
||||||
|
|
||||||
|
class TestNonZUGFeRDPDF:
|
||||||
|
"""Test extraction from PDF without ZUGFeRD XML."""
|
||||||
|
|
||||||
|
def test_non_zugferd_pdf(self):
|
||||||
|
"""Test PDF without ZUGFeRD XML returns is_zugferd=False."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
# Load non-ZUGFeRD sample PDF
|
||||||
|
with open("tests/fixtures/EmptyPDFA1.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is False
|
||||||
|
assert result.zugferd_profil is None
|
||||||
|
assert result.xml_raw is None
|
||||||
|
assert result.xml_data is None
|
||||||
|
assert result.pdf_text is not None
|
||||||
|
assert len(result.pdf_text) > 0
|
||||||
|
assert result.extraction_meta.pages >= 1
|
||||||
|
assert result.extraction_meta.extraction_time_ms >= 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestEN16931Extraction:
|
||||||
|
"""Test extraction from EN16931 profile PDF."""
|
||||||
|
|
||||||
|
def test_extract_en16931_profile(self):
|
||||||
|
"""Test EN16931 PDF extraction detects correct profile."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.zugferd_profil == "EN16931"
|
||||||
|
assert result.xml_raw is not None
|
||||||
|
assert len(result.xml_raw) > 0
|
||||||
|
assert result.xml_data is not None
|
||||||
|
assert result.pdf_text is not None
|
||||||
|
assert result.extraction_meta.xml_attachment_name is not None
|
||||||
|
assert result.extraction_meta.pages >= 1
|
||||||
|
assert result.extraction_meta.extraction_time_ms >= 0
|
||||||
|
|
||||||
|
def test_extract_all_required_fields(self):
|
||||||
|
"""Test all XmlData fields are populated from EN16931."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.xml_data is not None
|
||||||
|
xml_data = result.xml_data
|
||||||
|
|
||||||
|
# Required fields
|
||||||
|
assert xml_data.invoice_number is not None and len(xml_data.invoice_number) > 0
|
||||||
|
assert xml_data.invoice_date is not None and len(xml_data.invoice_date) > 0
|
||||||
|
assert xml_data.supplier is not None
|
||||||
|
assert xml_data.buyer is not None
|
||||||
|
assert xml_data.line_items is not None
|
||||||
|
assert xml_data.totals is not None
|
||||||
|
|
||||||
|
# Supplier fields
|
||||||
|
assert xml_data.supplier.name is not None and len(xml_data.supplier.name) > 0
|
||||||
|
|
||||||
|
# Buyer fields
|
||||||
|
assert xml_data.buyer.name is not None and len(xml_data.buyer.name) > 0
|
||||||
|
|
||||||
|
# Line items
|
||||||
|
assert len(xml_data.line_items) > 0
|
||||||
|
first_item = xml_data.line_items[0]
|
||||||
|
assert first_item.position >= 1
|
||||||
|
assert first_item.description is not None and len(first_item.description) > 0
|
||||||
|
assert first_item.quantity > 0
|
||||||
|
assert first_item.unit is not None and len(first_item.unit) > 0
|
||||||
|
assert first_item.unit_price is not None and first_item.unit_price > 0
|
||||||
|
assert first_item.line_total is not None and first_item.line_total > 0
|
||||||
|
|
||||||
|
# Totals
|
||||||
|
assert xml_data.totals.line_total_sum > 0
|
||||||
|
assert xml_data.totals.net > 0
|
||||||
|
assert xml_data.totals.vat_total >= 0
|
||||||
|
assert xml_data.totals.gross > 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestErrorHandling:
|
||||||
|
"""Test error handling for various PDF issues."""
|
||||||
|
|
||||||
|
def test_corrupt_pdf_raises_error(self):
|
||||||
|
"""Test corrupt PDF raises ExtractionError with correct code."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
# Invalid PDF data
|
||||||
|
corrupt_pdf = b"NOT A PDF FILE AT ALL"
|
||||||
|
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_zugferd(corrupt_pdf)
|
||||||
|
|
||||||
|
# Should raise either corrupt_pdf or invalid_pdf
|
||||||
|
assert exc_info.value.error_code in ["corrupt_pdf", "invalid_pdf"]
|
||||||
|
|
||||||
|
def test_empty_pdf_raises_error(self):
|
||||||
|
"""Test empty PDF raises ExtractionError."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
with pytest.raises(ExtractionError):
|
||||||
|
extract_zugferd(b"")
|
||||||
|
|
||||||
|
def test_invalid_base64(self):
|
||||||
|
"""Test invalid base64 raises ExtractionError."""
|
||||||
|
from src.extractor import ExtractionError, extract_zugferd
|
||||||
|
|
||||||
|
# This would be called by API layer, but we can test the concept
|
||||||
|
# Invalid PDF that's not valid base64-encoded
|
||||||
|
try:
|
||||||
|
invalid_base64 = b"$$$INVALID$$$"
|
||||||
|
# If API layer decodes invalid base64, it gets error
|
||||||
|
decoded = base64.b64decode(invalid_base64, validate=True)
|
||||||
|
extract_zugferd(decoded)
|
||||||
|
except (binascii.Error, ValueError):
|
||||||
|
# base64 error is expected
|
||||||
|
pass
|
||||||
|
except ExtractionError as e:
|
||||||
|
# Or extraction error from invalid PDF
|
||||||
|
assert e.error_code in ["invalid_pdf", "corrupt_pdf"]
|
||||||
|
|
||||||
|
|
||||||
|
class TestPDFTextExtraction:
|
||||||
|
"""Test PDF text extraction."""
|
||||||
|
|
||||||
|
def test_pdf_text_extraction(self):
|
||||||
|
"""Test PDF text is extracted correctly."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.pdf_text is not None
|
||||||
|
assert len(result.pdf_text) > 0
|
||||||
|
# PDF text may contain invoice-related terms in German or English
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractionMeta:
|
||||||
|
"""Test extraction metadata."""
|
||||||
|
|
||||||
|
def test_extraction_meta_populated(self):
|
||||||
|
"""Test extraction metadata is populated correctly."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.extraction_meta is not None
|
||||||
|
assert result.extraction_meta.pages >= 1
|
||||||
|
assert result.extraction_meta.extraction_time_ms >= 0
|
||||||
|
|
||||||
|
def test_extraction_meta_non_zugferd(self):
|
||||||
|
"""Test extraction metadata for non-ZUGFeRD PDF."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/EmptyPDFA1.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.extraction_meta is not None
|
||||||
|
assert result.extraction_meta.pages >= 1
|
||||||
|
assert result.extraction_meta.extraction_time_ms >= 0
|
||||||
|
assert result.extraction_meta.xml_attachment_name is None
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtendedProfile:
|
||||||
|
"""Test extraction from EXTENDED profile PDF (if available)."""
|
||||||
|
|
||||||
|
def test_extract_extended_profile(self):
|
||||||
|
"""Test EXTENDED PDF extraction detects correct profile."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/zugferd_2p1_EXTENDED_PDFA-3A.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.zugferd_profil == "EXTENDED"
|
||||||
|
assert result.xml_data is not None
|
||||||
|
|
||||||
|
|
||||||
|
class TestZUGFeRDProfileVariations:
|
||||||
|
"""Test various ZUGFeRD profile detection."""
|
||||||
|
|
||||||
|
def test_detect_basicwl_profile(self):
|
||||||
|
"""Test BASIC WL profile detection."""
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
|
||||||
|
with open("tests/fixtures/validAvoir_FR_type380_BASICWL.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
# Profile should be detected (BASIC, BASICWL, etc.)
|
||||||
|
assert result.zugferd_profil is not None
|
||||||
|
assert result.xml_data is not None
|
||||||
|
|
||||||
|
|
||||||
|
class TestXRechnungExtraction:
|
||||||
|
"""Test extraction from XRechnung PDFs with non-standard filenames."""
|
||||||
|
|
||||||
|
def test_xrechnung_by_xml_extension_fallback(self):
|
||||||
|
"""Test XRechnung with 'xrechnung.xml' filename is extracted correctly.
|
||||||
|
|
||||||
|
Depending on the factur-x version, the library recognizes non-standard
|
||||||
|
attachment names itself or our fallback kicks in — both paths must
|
||||||
|
yield the same result, so we only assert our own behavior here.
|
||||||
|
"""
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from src.extractor import extract_zugferd, _find_xml_attachment_fallback
|
||||||
|
|
||||||
|
# Load valid XML from existing test fixture
|
||||||
|
with open("tests/fixtures/validXRechnung.pdf", "rb") as f:
|
||||||
|
orig_reader = PdfReader(f)
|
||||||
|
xml_content = None
|
||||||
|
for att in orig_reader.attachment_list:
|
||||||
|
xml_content = att.content
|
||||||
|
break
|
||||||
|
if xml_content is None:
|
||||||
|
pytest.fail("Test fixture has no XML attachment")
|
||||||
|
|
||||||
|
# Create a new PDF with a non-standard attachment name
|
||||||
|
pdf_writer = PdfWriter()
|
||||||
|
pdf_writer.add_blank_page(width=72, height=72)
|
||||||
|
pdf_writer.add_attachment("xrechnung.xml", xml_content)
|
||||||
|
|
||||||
|
output = BytesIO()
|
||||||
|
pdf_writer.write(output)
|
||||||
|
pdf_bytes = output.getvalue()
|
||||||
|
|
||||||
|
# Verify our fallback function finds it on its own
|
||||||
|
fallback_result = _find_xml_attachment_fallback(pdf_bytes)
|
||||||
|
assert fallback_result[0] == "xrechnung.xml", (
|
||||||
|
"Fallback should find xrechnung.xml"
|
||||||
|
)
|
||||||
|
assert fallback_result[1] is not None, "Fallback should return XML content"
|
||||||
|
|
||||||
|
# Verify full extraction works, whichever path finds the XML
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.xml_raw is not None
|
||||||
|
assert result.xml_data is not None
|
||||||
|
assert result.xml_data.invoice_number is not None
|
||||||
|
assert result.extraction_meta.xml_attachment_name == "xrechnung.xml"
|
||||||
|
|
||||||
|
|
||||||
|
TAX_REGISTRATION_XML_TEMPLATE = """<rsm:CrossIndustryInvoice
|
||||||
|
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
||||||
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100">
|
||||||
|
<rsm:SupplyChainTradeTransaction>
|
||||||
|
<ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:SellerTradeParty>
|
||||||
|
<ram:Name>Test Seller GmbH</ram:Name>
|
||||||
|
{seller_tax_registrations}
|
||||||
|
{seller_contact}
|
||||||
|
</ram:SellerTradeParty>
|
||||||
|
<ram:BuyerTradeParty>
|
||||||
|
<ram:Name>Test Buyer AG</ram:Name>
|
||||||
|
{buyer_tax_registrations}
|
||||||
|
</ram:BuyerTradeParty>
|
||||||
|
</ram:ApplicableHeaderTradeAgreement>
|
||||||
|
</rsm:SupplyChainTradeTransaction>
|
||||||
|
</rsm:CrossIndustryInvoice>"""
|
||||||
|
|
||||||
|
VA_REGISTRATION = (
|
||||||
|
"<ram:SpecifiedTaxRegistration>"
|
||||||
|
'<ram:ID schemeID="VA">DE123456789</ram:ID>'
|
||||||
|
"</ram:SpecifiedTaxRegistration>"
|
||||||
|
)
|
||||||
|
FC_REGISTRATION = (
|
||||||
|
"<ram:SpecifiedTaxRegistration>"
|
||||||
|
'<ram:ID schemeID="FC">2281410000697</ram:ID>'
|
||||||
|
"</ram:SpecifiedTaxRegistration>"
|
||||||
|
)
|
||||||
|
BUYER_FC_REGISTRATION = (
|
||||||
|
"<ram:SpecifiedTaxRegistration>"
|
||||||
|
'<ram:ID schemeID="FC">9876543210</ram:ID>'
|
||||||
|
"</ram:SpecifiedTaxRegistration>"
|
||||||
|
)
|
||||||
|
CONTACT_WITH_EMAIL = (
|
||||||
|
"<ram:DefinedTradeContact>"
|
||||||
|
"<ram:EmailURIUniversalCommunication>"
|
||||||
|
"<ram:URIID>seller@example.de</ram:URIID>"
|
||||||
|
"</ram:EmailURIUniversalCommunication>"
|
||||||
|
"</ram:DefinedTradeContact>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestTaxRegistrationExtraction:
|
||||||
|
"""Test extraction of tax registrations (VAT ID vs. tax number)."""
|
||||||
|
|
||||||
|
def _parse(self, seller_regs: str, buyer_regs: str, seller_contact: str = ""):
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from src.extractor import parse_buyer, parse_supplier
|
||||||
|
|
||||||
|
xml = TAX_REGISTRATION_XML_TEMPLATE.format(
|
||||||
|
seller_tax_registrations=seller_regs,
|
||||||
|
buyer_tax_registrations=buyer_regs,
|
||||||
|
seller_contact=seller_contact,
|
||||||
|
)
|
||||||
|
root = etree.fromstring(xml.encode("utf-8"))
|
||||||
|
return parse_supplier(root), parse_buyer(root)
|
||||||
|
|
||||||
|
def test_seller_vat_id_and_tax_number(self):
|
||||||
|
"""Seller with VA and FC registrations extracts both fields."""
|
||||||
|
supplier, _ = self._parse(VA_REGISTRATION + FC_REGISTRATION, "")
|
||||||
|
|
||||||
|
assert supplier.vat_id == "DE123456789"
|
||||||
|
assert supplier.tax_number == "2281410000697"
|
||||||
|
|
||||||
|
def test_seller_tax_number_only(self):
|
||||||
|
"""Seller with only FC registration (e.g. Kleinunternehmer/Werkstatt)."""
|
||||||
|
supplier, _ = self._parse(FC_REGISTRATION, "")
|
||||||
|
|
||||||
|
assert supplier.vat_id is None
|
||||||
|
assert supplier.tax_number == "2281410000697"
|
||||||
|
|
||||||
|
def test_seller_vat_id_only(self):
|
||||||
|
"""Seller with only VA registration leaves tax_number empty."""
|
||||||
|
supplier, _ = self._parse(VA_REGISTRATION, "")
|
||||||
|
|
||||||
|
assert supplier.vat_id == "DE123456789"
|
||||||
|
assert supplier.tax_number is None
|
||||||
|
|
||||||
|
def test_buyer_tax_number(self):
|
||||||
|
"""Buyer with FC registration extracts tax_number."""
|
||||||
|
_, buyer = self._parse(VA_REGISTRATION, BUYER_FC_REGISTRATION)
|
||||||
|
|
||||||
|
assert buyer.vat_id is None
|
||||||
|
assert buyer.tax_number == "9876543210"
|
||||||
|
|
||||||
|
def test_seller_email_from_trade_contact(self):
|
||||||
|
"""Seller email is found in DefinedTradeContact (BT-42)."""
|
||||||
|
supplier, _ = self._parse(
|
||||||
|
VA_REGISTRATION, "", seller_contact=CONTACT_WITH_EMAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
assert supplier.email == "seller@example.de"
|
||||||
|
|
||||||
|
def test_seller_email_absent(self):
|
||||||
|
"""No email elements leaves email as None."""
|
||||||
|
supplier, _ = self._parse(VA_REGISTRATION, "")
|
||||||
|
|
||||||
|
assert supplier.email is None
|
||||||
|
|
||||||
|
|
||||||
|
LINE_ITEM_XML_TEMPLATE = """<rsm:CrossIndustryInvoice
|
||||||
|
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
||||||
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100">
|
||||||
|
<rsm:SupplyChainTradeTransaction>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:SpecifiedTradeProduct>
|
||||||
|
<ram:Name>Flanschsicherungsset</ram:Name>
|
||||||
|
</ram:SpecifiedTradeProduct>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount>{charge_amount}</ram:ChargeAmount>
|
||||||
|
{basis_quantity}
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="H87">{billed_quantity}</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount>{line_total}</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
</rsm:SupplyChainTradeTransaction>
|
||||||
|
</rsm:CrossIndustryInvoice>"""
|
||||||
|
|
||||||
|
|
||||||
|
class TestBasisQuantityExtraction:
|
||||||
|
"""Test unit price normalization via BasisQuantity (BT-149)."""
|
||||||
|
|
||||||
|
def _parse_items(self, basis_quantity: str):
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from src.extractor import parse_line_items
|
||||||
|
|
||||||
|
xml = LINE_ITEM_XML_TEMPLATE.format(
|
||||||
|
charge_amount="75.85",
|
||||||
|
basis_quantity=basis_quantity,
|
||||||
|
billed_quantity="140",
|
||||||
|
line_total="106.19",
|
||||||
|
)
|
||||||
|
root = etree.fromstring(xml.encode("utf-8"))
|
||||||
|
return parse_line_items(root)
|
||||||
|
|
||||||
|
def test_unit_price_divided_by_basis_quantity(self):
|
||||||
|
"""Charge amount per 100 units is normalized to per-unit price."""
|
||||||
|
items = self._parse_items("<ram:BasisQuantity>100</ram:BasisQuantity>")
|
||||||
|
|
||||||
|
assert len(items) == 1
|
||||||
|
assert items[0].unit_price == pytest.approx(0.7585)
|
||||||
|
|
||||||
|
def test_unit_price_without_basis_quantity(self):
|
||||||
|
"""Without BasisQuantity the charge amount stays as-is."""
|
||||||
|
items = self._parse_items("")
|
||||||
|
|
||||||
|
assert len(items) == 1
|
||||||
|
assert items[0].unit_price == pytest.approx(75.85)
|
||||||
|
|
||||||
|
def test_unit_price_with_zero_basis_quantity(self):
|
||||||
|
"""Zero BasisQuantity is ignored (division guard)."""
|
||||||
|
items = self._parse_items("<ram:BasisQuantity>0</ram:BasisQuantity>")
|
||||||
|
|
||||||
|
assert len(items) == 1
|
||||||
|
assert items[0].unit_price == pytest.approx(75.85)
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
"""Regression sweep over all invoice fixtures.
|
||||||
|
|
||||||
|
Every fixture PDF is extracted and validated end-to-end on every test run.
|
||||||
|
Known limitations of extractor and validator are catalogued explicitly in
|
||||||
|
KNOWN_GAPS and VALIDATION_EXCLUDED below. The sweep fails when:
|
||||||
|
|
||||||
|
- any fixture stops extracting (exception),
|
||||||
|
- a fixture that used to be clean produces new critical errors,
|
||||||
|
- a fixture with known gaps produces more/different errors than catalogued,
|
||||||
|
- a gap was fixed but its catalogue entry was not removed.
|
||||||
|
|
||||||
|
So: fix a gap, then remove its entry — the sweep enforces honest bookkeeping.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
from src.models import ValidateRequest
|
||||||
|
from src.validator import validate_invoice
|
||||||
|
|
||||||
|
FIXTURES = Path(__file__).parent / "fixtures"
|
||||||
|
ALL_CHECKS = ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"]
|
||||||
|
|
||||||
|
EXPECTED_NON_ZUGFERD = {"EmptyPDFA1.pdf"}
|
||||||
|
|
||||||
|
VALIDATION_EXCLUDED = {
|
||||||
|
"ORDER-X_EX01_ORDER_FULL_DATA-COMFORT.pdf": (
|
||||||
|
"ORDER-X order document, not an invoice"
|
||||||
|
),
|
||||||
|
"zugferd_invoice.pdf": (
|
||||||
|
"ZUGFeRD 1.0 uses a different XML namespace (not supported)"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
KNOWN_GAPS: dict[str, set[str]] = {
|
||||||
|
"EN16931_1_Teilrechnung.pdf": {
|
||||||
|
"line_items[3].line_total",
|
||||||
|
"totals.net",
|
||||||
|
},
|
||||||
|
"MustangBeispiel20221026.pdf": {
|
||||||
|
"totals.net",
|
||||||
|
},
|
||||||
|
"validAvoir_FR_type380_BASICWL.pdf": {
|
||||||
|
"line_items",
|
||||||
|
"totals.net",
|
||||||
|
"vat_id",
|
||||||
|
},
|
||||||
|
"zugferd_2p1_EXTENDED_PDFA-3A.pdf": {
|
||||||
|
"totals.net",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _pdf_files() -> list[str]:
|
||||||
|
return sorted(path.name for path in FIXTURES.glob("*.pdf"))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("filename", _pdf_files())
|
||||||
|
def test_fixture_sweep(filename: str) -> None:
|
||||||
|
"""Extract and validate one fixture; deviations from the catalogue fail."""
|
||||||
|
pdf_bytes = (FIXTURES / filename).read_bytes()
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
if filename in EXPECTED_NON_ZUGFERD:
|
||||||
|
assert result.is_zugferd is False
|
||||||
|
return
|
||||||
|
|
||||||
|
assert result.is_zugferd is True, f"{filename}: expected ZUGFeRD XML"
|
||||||
|
assert result.xml_data is not None
|
||||||
|
|
||||||
|
if filename in VALIDATION_EXCLUDED:
|
||||||
|
return
|
||||||
|
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=result.xml_data.model_dump(),
|
||||||
|
pdf_text=result.pdf_text,
|
||||||
|
checks=ALL_CHECKS,
|
||||||
|
profile=result.zugferd_profil,
|
||||||
|
)
|
||||||
|
validation = validate_invoice(request)
|
||||||
|
critical_fields = {error.field for error in validation.errors}
|
||||||
|
expected_fields = KNOWN_GAPS.get(filename, set())
|
||||||
|
|
||||||
|
assert critical_fields == expected_fields, (
|
||||||
|
f"{filename}: critical fields changed — update KNOWN_GAPS "
|
||||||
|
f"(new state: {sorted(critical_fields)})"
|
||||||
|
)
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
"""Integration tests for full ZUGFeRD workflow: extract → validate."""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
from src.main import app
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
"""Create TestClient fixture for FastAPI app."""
|
||||||
|
return TestClient(app)
|
||||||
|
|
||||||
|
|
||||||
|
def read_pdf_as_base64(filepath: str) -> str:
|
||||||
|
"""Helper function to read a PDF file and encode as base64.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filepath: Path to the PDF file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Base64-encoded PDF content as string.
|
||||||
|
"""
|
||||||
|
with open(filepath, "rb") as f:
|
||||||
|
return base64.b64encode(f.read()).decode()
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_en16931_full_workflow(client):
|
||||||
|
"""Test full workflow: extract → validate with EN16931 invoice."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/EN16931_Einfach.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["is_zugferd"] is True
|
||||||
|
assert extract_data["zugferd_profil"] == "EN16931"
|
||||||
|
assert "xml_data" in extract_data
|
||||||
|
assert "pdf_text" in extract_data
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
assert "is_valid" in validate_data["result"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_basic_wl_full_workflow(client):
|
||||||
|
"""Test full workflow: extract → validate with BASIC WL invoice."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/validAvoir_FR_type380_BASICWL.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["is_zugferd"] is True
|
||||||
|
assert "xml_data" in extract_data
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["pflichtfelder"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_extended_profile_full_workflow(client):
|
||||||
|
"""Test full workflow: extract → validate with EXTENDED profile."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/zugferd_2p1_EXTENDED_PDFA-3A.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["is_zugferd"] is True
|
||||||
|
assert "xml_data" in extract_data
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["pflichtfelder", "betraege"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_invalid_base64_error(client):
|
||||||
|
"""Test error scenario: invalid base64 in extract request."""
|
||||||
|
extract_response = client.post(
|
||||||
|
"/extract", json={"pdf_base64": "not_valid_base64!!!"}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert extract_response.status_code == 400
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["error"] == "invalid_base64"
|
||||||
|
assert "message" in extract_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_non_zugferd_pdf_workflow(client):
|
||||||
|
"""Test workflow with non-ZUGFeRD PDF."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/EmptyPDFA1.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["is_zugferd"] is False
|
||||||
|
assert extract_data["zugferd_profil"] is None
|
||||||
|
assert extract_data["xml_data"] is None
|
||||||
|
assert "pdf_text" in extract_data
|
||||||
|
|
||||||
|
# Only validate if xml_data is present
|
||||||
|
if extract_data.get("xml_data"):
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["pflichtfelder"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_various_validation_checks(client):
|
||||||
|
"""Test full workflow with different validation check combinations."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/EN16931_Einfach.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
assert extract_data["is_zugferd"] is True
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["pflichtfelder"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": ["betraege"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_multiple_profiles_sequentially(client):
|
||||||
|
"""Test extraction from multiple ZUGFeRD profiles in sequence."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/EN16931_Einfach.pdf")
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json()["zugferd_profil"] == "EN16931"
|
||||||
|
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/validAvoir_FR_type380_BASICWL.pdf")
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/zugferd_2p1_EXTENDED_PDFA-3A.pdf")
|
||||||
|
response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_empty_checks_list(client):
|
||||||
|
"""Test workflow with empty checks list in validation."""
|
||||||
|
pdf_base64 = read_pdf_as_base64("tests/fixtures/EN16931_Einfach.pdf")
|
||||||
|
extract_response = client.post("/extract", json={"pdf_base64": pdf_base64})
|
||||||
|
|
||||||
|
assert extract_response.status_code == 200
|
||||||
|
extract_data = extract_response.json()
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": extract_data["xml_data"],
|
||||||
|
"pdf_text": extract_data["pdf_text"],
|
||||||
|
"checks": [],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_integration_corrupt_xml_data_validation(client):
|
||||||
|
"""Test validation with corrupt or malformed XML data returns validation errors."""
|
||||||
|
corrupt_data = {
|
||||||
|
"invoice_number": "TEST-001",
|
||||||
|
"totals": {"net": "invalid_number"},
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_response = client.post(
|
||||||
|
"/validate",
|
||||||
|
json={
|
||||||
|
"xml_data": corrupt_data,
|
||||||
|
"pdf_text": "",
|
||||||
|
"checks": ["pflichtfelder"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Validator catches Pydantic errors and returns 200 with validation result
|
||||||
|
assert validate_response.status_code == 200
|
||||||
|
validate_data = validate_response.json()
|
||||||
|
assert "result" in validate_data
|
||||||
|
assert validate_data["result"]["is_valid"] is False
|
||||||
|
assert len(validate_data["result"]["errors"]) > 0
|
||||||
@@ -0,0 +1,517 @@
|
|||||||
|
"""Tests for Pydantic models."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
# These tests will fail initially, then pass after models are implemented
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractionMeta:
|
||||||
|
"""Test ExtractionMeta model."""
|
||||||
|
|
||||||
|
def test_minimal_extraction_meta(self):
|
||||||
|
"""Test ExtractionMeta with minimal required fields."""
|
||||||
|
from src.models import ExtractionMeta
|
||||||
|
|
||||||
|
meta = ExtractionMeta(pages=1, extraction_time_ms=234)
|
||||||
|
assert meta.pages == 1
|
||||||
|
assert meta.extraction_time_ms == 234
|
||||||
|
assert meta.xml_attachment_name is None
|
||||||
|
|
||||||
|
def test_full_extraction_meta(self):
|
||||||
|
"""Test ExtractionMeta with all fields."""
|
||||||
|
from src.models import ExtractionMeta
|
||||||
|
|
||||||
|
meta = ExtractionMeta(
|
||||||
|
pages=2, xml_attachment_name="factur-x.xml", extraction_time_ms=456
|
||||||
|
)
|
||||||
|
assert meta.pages == 2
|
||||||
|
assert meta.xml_attachment_name == "factur-x.xml"
|
||||||
|
assert meta.extraction_time_ms == 456
|
||||||
|
|
||||||
|
|
||||||
|
class TestSupplier:
|
||||||
|
"""Test Supplier model."""
|
||||||
|
|
||||||
|
def test_minimal_supplier(self):
|
||||||
|
"""Test Supplier with minimal required fields."""
|
||||||
|
from src.models import Supplier
|
||||||
|
|
||||||
|
supplier = Supplier(name="ACME GmbH")
|
||||||
|
assert supplier.name == "ACME GmbH"
|
||||||
|
assert supplier.street is None
|
||||||
|
assert supplier.vat_id is None
|
||||||
|
assert supplier.tax_number is None
|
||||||
|
|
||||||
|
def test_full_supplier(self):
|
||||||
|
"""Test Supplier with all fields."""
|
||||||
|
from src.models import Supplier
|
||||||
|
|
||||||
|
supplier = Supplier(
|
||||||
|
name="ACME GmbH",
|
||||||
|
street="Musterstraße 42",
|
||||||
|
postal_code="12345",
|
||||||
|
city="Musterstadt",
|
||||||
|
country="DE",
|
||||||
|
vat_id="DE123456789",
|
||||||
|
tax_number="2281410000697",
|
||||||
|
email="info@acme.de",
|
||||||
|
)
|
||||||
|
assert supplier.name == "ACME GmbH"
|
||||||
|
assert supplier.street == "Musterstraße 42"
|
||||||
|
assert supplier.postal_code == "12345"
|
||||||
|
assert supplier.city == "Musterstadt"
|
||||||
|
assert supplier.country == "DE"
|
||||||
|
assert supplier.vat_id == "DE123456789"
|
||||||
|
assert supplier.tax_number == "2281410000697"
|
||||||
|
assert supplier.email == "info@acme.de"
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuyer:
|
||||||
|
"""Test Buyer model."""
|
||||||
|
|
||||||
|
def test_minimal_buyer(self):
|
||||||
|
"""Test Buyer with minimal required fields."""
|
||||||
|
from src.models import Buyer
|
||||||
|
|
||||||
|
buyer = Buyer(name="Customer AG")
|
||||||
|
assert buyer.name == "Customer AG"
|
||||||
|
assert buyer.street is None
|
||||||
|
|
||||||
|
def test_full_buyer(self):
|
||||||
|
"""Test Buyer with all fields."""
|
||||||
|
from src.models import Buyer
|
||||||
|
|
||||||
|
buyer = Buyer(
|
||||||
|
name="Customer AG",
|
||||||
|
street="Kundenweg 7",
|
||||||
|
postal_code="54321",
|
||||||
|
city="Kundenstadt",
|
||||||
|
country="DE",
|
||||||
|
vat_id="DE987654321",
|
||||||
|
tax_number="1234567890",
|
||||||
|
)
|
||||||
|
assert buyer.name == "Customer AG"
|
||||||
|
assert buyer.street == "Kundenweg 7"
|
||||||
|
assert buyer.vat_id == "DE987654321"
|
||||||
|
assert buyer.tax_number == "1234567890"
|
||||||
|
|
||||||
|
|
||||||
|
class TestVatBreakdown:
|
||||||
|
"""Test VatBreakdown model."""
|
||||||
|
|
||||||
|
def test_vat_breakdown(self):
|
||||||
|
"""Test VatBreakdown model."""
|
||||||
|
from src.models import VatBreakdown
|
||||||
|
|
||||||
|
vat = VatBreakdown(rate=19.0, base=99.90, amount=18.98)
|
||||||
|
assert vat.rate == 19.0
|
||||||
|
assert vat.base == 99.90
|
||||||
|
assert vat.amount == 18.98
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentTerms:
|
||||||
|
"""Test PaymentTerms model."""
|
||||||
|
|
||||||
|
def test_minimal_payment_terms(self):
|
||||||
|
"""Test PaymentTerms with minimal fields."""
|
||||||
|
from src.models import PaymentTerms
|
||||||
|
|
||||||
|
terms = PaymentTerms()
|
||||||
|
assert terms.iban is None
|
||||||
|
assert terms.bic is None
|
||||||
|
assert terms.account_holder is None
|
||||||
|
|
||||||
|
def test_full_payment_terms(self):
|
||||||
|
"""Test PaymentTerms with all fields."""
|
||||||
|
from src.models import PaymentTerms
|
||||||
|
|
||||||
|
terms = PaymentTerms(
|
||||||
|
iban="DE89370400440532013000", bic="DEUTDEFF", account_holder="ACME GmbH"
|
||||||
|
)
|
||||||
|
assert terms.iban == "DE89370400440532013000"
|
||||||
|
assert terms.bic == "DEUTDEFF"
|
||||||
|
assert terms.account_holder == "ACME GmbH"
|
||||||
|
|
||||||
|
|
||||||
|
class TestTotals:
|
||||||
|
"""Test Totals model."""
|
||||||
|
|
||||||
|
def test_totals_minimal(self):
|
||||||
|
"""Test Totals with required fields only."""
|
||||||
|
from src.models import Totals
|
||||||
|
|
||||||
|
totals = Totals(line_total_sum=99.90, net=99.90, vat_total=18.98, gross=118.88)
|
||||||
|
assert totals.line_total_sum == 99.90
|
||||||
|
assert totals.net == 99.90
|
||||||
|
assert totals.vat_total == 18.98
|
||||||
|
assert totals.gross == 118.88
|
||||||
|
assert totals.vat_breakdown == []
|
||||||
|
|
||||||
|
def test_totals_with_vat_breakdown(self):
|
||||||
|
"""Test Totals with VAT breakdown."""
|
||||||
|
from src.models import Totals, VatBreakdown
|
||||||
|
|
||||||
|
totals = Totals(
|
||||||
|
line_total_sum=99.90,
|
||||||
|
net=99.90,
|
||||||
|
vat_total=18.98,
|
||||||
|
gross=118.88,
|
||||||
|
vat_breakdown=[VatBreakdown(rate=19.0, base=99.90, amount=18.98)],
|
||||||
|
)
|
||||||
|
assert len(totals.vat_breakdown) == 1
|
||||||
|
assert totals.vat_breakdown[0].rate == 19.0
|
||||||
|
|
||||||
|
|
||||||
|
class TestLineItem:
|
||||||
|
"""Test LineItem model."""
|
||||||
|
|
||||||
|
def test_minimal_line_item(self):
|
||||||
|
"""Test LineItem with minimal required fields."""
|
||||||
|
from src.models import LineItem
|
||||||
|
|
||||||
|
item = LineItem(
|
||||||
|
position=1,
|
||||||
|
description="Widget",
|
||||||
|
quantity=10.0,
|
||||||
|
unit="Stück",
|
||||||
|
unit_price=9.99,
|
||||||
|
line_total=99.90,
|
||||||
|
)
|
||||||
|
assert item.position == 1
|
||||||
|
assert item.description == "Widget"
|
||||||
|
assert item.quantity == 10.0
|
||||||
|
assert item.unit == "Stück"
|
||||||
|
assert item.unit_price == 9.99
|
||||||
|
assert item.line_total == 99.90
|
||||||
|
assert item.article_number is None
|
||||||
|
assert item.vat_rate is None
|
||||||
|
|
||||||
|
def test_full_line_item(self):
|
||||||
|
"""Test LineItem with all fields."""
|
||||||
|
from src.models import LineItem
|
||||||
|
|
||||||
|
item = LineItem(
|
||||||
|
position=1,
|
||||||
|
article_number="ART-001",
|
||||||
|
article_number_buyer="KUN-001",
|
||||||
|
description="Premium Widget",
|
||||||
|
quantity=5.0,
|
||||||
|
unit="Stück",
|
||||||
|
unit_price=19.99,
|
||||||
|
line_total=99.95,
|
||||||
|
vat_rate=19.0,
|
||||||
|
vat_amount=18.99,
|
||||||
|
)
|
||||||
|
assert item.article_number == "ART-001"
|
||||||
|
assert item.article_number_buyer == "KUN-001"
|
||||||
|
assert item.vat_rate == 19.0
|
||||||
|
assert item.vat_amount == 18.99
|
||||||
|
|
||||||
|
|
||||||
|
class TestXmlData:
|
||||||
|
"""Test XmlData model."""
|
||||||
|
|
||||||
|
def test_minimal_xml_data(self):
|
||||||
|
"""Test XmlData with minimal required fields."""
|
||||||
|
from src.models import XmlData, Supplier, Buyer, Totals
|
||||||
|
|
||||||
|
data = XmlData(
|
||||||
|
invoice_number="RE-2025-001234",
|
||||||
|
invoice_date="2025-02-04",
|
||||||
|
supplier={"name": "ACME GmbH"},
|
||||||
|
buyer={"name": "Customer AG"},
|
||||||
|
line_items=[],
|
||||||
|
totals={"line_total_sum": 0.0, "net": 0.0, "vat_total": 0.0, "gross": 0.0},
|
||||||
|
)
|
||||||
|
assert data.invoice_number == "RE-2025-001234"
|
||||||
|
assert data.invoice_date == "2025-02-04"
|
||||||
|
assert data.due_date is None
|
||||||
|
assert data.notes is None
|
||||||
|
|
||||||
|
def test_full_xml_data(self):
|
||||||
|
"""Test XmlData with all fields."""
|
||||||
|
from src.models import XmlData, Supplier, Buyer, LineItem, Totals, VatBreakdown
|
||||||
|
|
||||||
|
data = XmlData(
|
||||||
|
invoice_number="RE-2025-001234",
|
||||||
|
invoice_date="2025-02-04",
|
||||||
|
due_date="2025-03-04",
|
||||||
|
supplier=Supplier(name="ACME GmbH", vat_id="DE123456789"),
|
||||||
|
buyer=Buyer(name="Customer AG", vat_id="DE987654321"),
|
||||||
|
line_items=[
|
||||||
|
LineItem(
|
||||||
|
position=1,
|
||||||
|
description="Widget",
|
||||||
|
quantity=10.0,
|
||||||
|
unit="Stück",
|
||||||
|
unit_price=9.99,
|
||||||
|
line_total=99.90,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
totals=Totals(
|
||||||
|
line_total_sum=99.90,
|
||||||
|
net=99.90,
|
||||||
|
vat_breakdown=[VatBreakdown(rate=19.0, base=99.90, amount=18.98)],
|
||||||
|
vat_total=18.98,
|
||||||
|
gross=118.88,
|
||||||
|
),
|
||||||
|
currency="EUR",
|
||||||
|
notes="Payment due within 30 days",
|
||||||
|
)
|
||||||
|
assert data.invoice_number == "RE-2025-001234"
|
||||||
|
assert data.due_date == "2025-03-04"
|
||||||
|
assert data.currency == "EUR"
|
||||||
|
assert data.notes == "Payment due within 30 days"
|
||||||
|
assert len(data.line_items) == 1
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractResponse:
|
||||||
|
"""Test ExtractResponse model."""
|
||||||
|
|
||||||
|
def test_extract_response_zugferd(self):
|
||||||
|
"""Test ExtractResponse with ZUGFeRD data."""
|
||||||
|
from src.models import (
|
||||||
|
ExtractResponse,
|
||||||
|
XmlData,
|
||||||
|
ExtractionMeta,
|
||||||
|
Supplier,
|
||||||
|
Buyer,
|
||||||
|
LineItem,
|
||||||
|
Totals,
|
||||||
|
VatBreakdown,
|
||||||
|
)
|
||||||
|
|
||||||
|
response = ExtractResponse(
|
||||||
|
is_zugferd=True,
|
||||||
|
zugferd_profil="EN16931",
|
||||||
|
xml_raw="<?xml version='1.0'?>...",
|
||||||
|
xml_data=XmlData(
|
||||||
|
invoice_number="RE-2025-001234",
|
||||||
|
invoice_date="2025-02-04",
|
||||||
|
supplier=Supplier(name="ACME GmbH"),
|
||||||
|
buyer=Buyer(name="Customer AG"),
|
||||||
|
line_items=[
|
||||||
|
LineItem(
|
||||||
|
position=1,
|
||||||
|
description="Widget",
|
||||||
|
quantity=10.0,
|
||||||
|
unit="Stück",
|
||||||
|
unit_price=9.99,
|
||||||
|
line_total=99.90,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
totals=Totals(
|
||||||
|
line_total_sum=99.90,
|
||||||
|
net=99.90,
|
||||||
|
vat_breakdown=[VatBreakdown(rate=19.0, base=99.90, amount=18.98)],
|
||||||
|
vat_total=18.98,
|
||||||
|
gross=118.88,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
pdf_text="Rechnung\n...",
|
||||||
|
extraction_meta=ExtractionMeta(
|
||||||
|
pages=1, xml_attachment_name="factur-x.xml", extraction_time_ms=234
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assert response.is_zugferd is True
|
||||||
|
assert response.zugferd_profil == "EN16931"
|
||||||
|
assert response.xml_raw is not None
|
||||||
|
assert response.xml_data is not None
|
||||||
|
assert response.pdf_text is not None
|
||||||
|
assert response.extraction_meta.pages == 1
|
||||||
|
|
||||||
|
def test_extract_response_non_zugferd(self):
|
||||||
|
"""Test ExtractResponse for non-ZUGFeRD PDF."""
|
||||||
|
from src.models import ExtractResponse, ExtractionMeta
|
||||||
|
|
||||||
|
response = ExtractResponse(
|
||||||
|
is_zugferd=False,
|
||||||
|
pdf_text="Invoice text from PDF...",
|
||||||
|
extraction_meta=ExtractionMeta(pages=1, extraction_time_ms=50),
|
||||||
|
)
|
||||||
|
assert response.is_zugferd is False
|
||||||
|
assert response.zugferd_profil is None
|
||||||
|
assert response.xml_raw is None
|
||||||
|
assert response.xml_data is None
|
||||||
|
assert response.pdf_text is not None
|
||||||
|
|
||||||
|
|
||||||
|
class TestErrorDetail:
|
||||||
|
"""Test ErrorDetail model."""
|
||||||
|
|
||||||
|
def test_error_detail_critical(self):
|
||||||
|
"""Test ErrorDetail with critical severity."""
|
||||||
|
from src.models import ErrorDetail
|
||||||
|
|
||||||
|
error = ErrorDetail(
|
||||||
|
check="pflichtfelder",
|
||||||
|
field="invoice_number",
|
||||||
|
error_code="missing_required_field",
|
||||||
|
message="Invoice number is required",
|
||||||
|
severity="critical",
|
||||||
|
)
|
||||||
|
assert error.check == "pflichtfelder"
|
||||||
|
assert error.field == "invoice_number"
|
||||||
|
assert error.error_code == "missing_required_field"
|
||||||
|
assert error.message == "Invoice number is required"
|
||||||
|
assert error.severity == "critical"
|
||||||
|
|
||||||
|
def test_error_detail_warning(self):
|
||||||
|
"""Test ErrorDetail with warning severity."""
|
||||||
|
from src.models import ErrorDetail
|
||||||
|
|
||||||
|
error = ErrorDetail(
|
||||||
|
check="pdf_abgleich",
|
||||||
|
field=None,
|
||||||
|
error_code="value_mismatch",
|
||||||
|
message="Amounts differ slightly",
|
||||||
|
severity="warning",
|
||||||
|
)
|
||||||
|
assert error.check == "pdf_abgleich"
|
||||||
|
assert error.field is None
|
||||||
|
assert error.severity == "warning"
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidationResult:
|
||||||
|
"""Test ValidationResult model."""
|
||||||
|
|
||||||
|
def test_valid_result(self):
|
||||||
|
"""Test ValidationResult with no errors."""
|
||||||
|
from src.models import ValidationResult
|
||||||
|
|
||||||
|
result = ValidationResult(
|
||||||
|
is_valid=True, errors=[], warnings=[], summary=None, validation_time_ms=100
|
||||||
|
)
|
||||||
|
assert result.is_valid is True
|
||||||
|
assert result.errors == []
|
||||||
|
assert result.warnings == []
|
||||||
|
assert result.summary is None
|
||||||
|
assert result.validation_time_ms == 100
|
||||||
|
|
||||||
|
def test_invalid_result_with_errors(self):
|
||||||
|
"""Test ValidationResult with errors."""
|
||||||
|
from src.models import ValidationResult, ErrorDetail
|
||||||
|
|
||||||
|
result = ValidationResult(
|
||||||
|
is_valid=False,
|
||||||
|
errors=[
|
||||||
|
ErrorDetail(
|
||||||
|
check="pflichtfelder",
|
||||||
|
field="invoice_number",
|
||||||
|
error_code="missing_required_field",
|
||||||
|
message="Invoice number is required",
|
||||||
|
severity="critical",
|
||||||
|
),
|
||||||
|
ErrorDetail(
|
||||||
|
check="betraege",
|
||||||
|
field="totals.gross",
|
||||||
|
error_code="calculation_mismatch",
|
||||||
|
message="Gross total mismatch: expected 118.88, got 118.90",
|
||||||
|
severity="critical",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
warnings=[
|
||||||
|
ErrorDetail(
|
||||||
|
check="pflichtfelder",
|
||||||
|
field="due_date",
|
||||||
|
error_code="missing_optional_field",
|
||||||
|
message="Due date not provided",
|
||||||
|
severity="warning",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
summary={"total_errors": 2, "total_warnings": 1, "critical_errors": 2},
|
||||||
|
validation_time_ms=150,
|
||||||
|
)
|
||||||
|
assert result.is_valid is False
|
||||||
|
assert len(result.errors) == 2
|
||||||
|
assert len(result.warnings) == 1
|
||||||
|
assert result.summary["total_errors"] == 2
|
||||||
|
assert result.validation_time_ms == 150
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractRequest:
|
||||||
|
"""Test ExtractRequest model."""
|
||||||
|
|
||||||
|
def test_extract_request(self):
|
||||||
|
"""Test ExtractRequest model."""
|
||||||
|
from src.models import ExtractRequest
|
||||||
|
|
||||||
|
request = ExtractRequest(pdf_base64="JVBERi0xLjQK...")
|
||||||
|
assert request.pdf_base64 == "JVBERi0xLjQK..."
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateRequest:
|
||||||
|
"""Test ValidateRequest model."""
|
||||||
|
|
||||||
|
def test_validate_request_minimal(self):
|
||||||
|
"""Test ValidateRequest with minimal fields."""
|
||||||
|
from src.models import ValidateRequest
|
||||||
|
|
||||||
|
request = ValidateRequest(xml_data={}, checks=["pflichtfelder"])
|
||||||
|
assert request.xml_data == {}
|
||||||
|
assert request.checks == ["pflichtfelder"]
|
||||||
|
assert request.pdf_text is None
|
||||||
|
|
||||||
|
def test_validate_request_full(self):
|
||||||
|
"""Test ValidateRequest with all fields."""
|
||||||
|
from src.models import ValidateRequest
|
||||||
|
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data={"invoice_number": "RE-001", "totals": {"gross": 118.88}},
|
||||||
|
pdf_text="Invoice text...",
|
||||||
|
checks=["pflichtfelder", "betraege", "ustid", "pdf_abgleich"],
|
||||||
|
)
|
||||||
|
assert request.xml_data["invoice_number"] == "RE-001"
|
||||||
|
assert request.pdf_text is not None
|
||||||
|
assert len(request.checks) == 4
|
||||||
|
|
||||||
|
|
||||||
|
class TestErrorResponse:
|
||||||
|
"""Test ErrorResponse model."""
|
||||||
|
|
||||||
|
def test_error_response(self):
|
||||||
|
"""Test ErrorResponse model."""
|
||||||
|
from src.models import ErrorResponse
|
||||||
|
|
||||||
|
response = ErrorResponse(
|
||||||
|
error="invalid_pdf", message="The provided file is not a valid PDF"
|
||||||
|
)
|
||||||
|
assert response.error == "invalid_pdf"
|
||||||
|
assert response.message == "The provided file is not a valid PDF"
|
||||||
|
|
||||||
|
|
||||||
|
class TestModelsSerializeToJSON:
|
||||||
|
"""Test JSON serialization of all models."""
|
||||||
|
|
||||||
|
def test_extract_response_serializes(self):
|
||||||
|
"""Test ExtractResponse serializes to valid JSON."""
|
||||||
|
from src.models import ExtractResponse, ExtractionMeta
|
||||||
|
|
||||||
|
response = ExtractResponse(
|
||||||
|
is_zugferd=False,
|
||||||
|
pdf_text="Invoice text...",
|
||||||
|
extraction_meta=ExtractionMeta(pages=1, extraction_time_ms=50),
|
||||||
|
)
|
||||||
|
json_str = response.model_dump_json()
|
||||||
|
assert '"is_zugferd":false' in json_str
|
||||||
|
assert '"pdf_text"' in json_str
|
||||||
|
|
||||||
|
def test_validation_result_serializes(self):
|
||||||
|
"""Test ValidationResult serializes to valid JSON."""
|
||||||
|
from src.models import ValidationResult
|
||||||
|
|
||||||
|
result = ValidationResult(
|
||||||
|
is_valid=True, errors=[], warnings=[], summary=None, validation_time_ms=100
|
||||||
|
)
|
||||||
|
json_str = result.model_dump_json()
|
||||||
|
assert '"is_valid":true' in json_str
|
||||||
|
|
||||||
|
def test_models_roundtrip(self):
|
||||||
|
"""Test models survive JSON roundtrip."""
|
||||||
|
from src.models import Supplier
|
||||||
|
|
||||||
|
supplier = Supplier(name="ACME GmbH", vat_id="DE123456789")
|
||||||
|
json_str = supplier.model_dump_json()
|
||||||
|
supplier2 = Supplier.model_validate_json(json_str)
|
||||||
|
assert supplier2.name == supplier.name
|
||||||
|
assert supplier2.vat_id == supplier.vat_id
|
||||||
@@ -0,0 +1,308 @@
|
|||||||
|
"""
|
||||||
|
Unit tests for PDF text extraction and parsing.
|
||||||
|
|
||||||
|
TDD approach: Tests written first, implementation follows.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from src.pdf_parser import extract_text_from_pdf, extract_from_text
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractTextFromPDF:
|
||||||
|
"""Test PDF text extraction using pypdf."""
|
||||||
|
|
||||||
|
def test_extract_text_from_sample_pdf(self):
|
||||||
|
"""Extract text from EN16931_Einfach.pdf sample."""
|
||||||
|
# Load the test PDF
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
# Extract text
|
||||||
|
text = extract_text_from_pdf(pdf_bytes)
|
||||||
|
|
||||||
|
# Verify text was extracted
|
||||||
|
assert text is not None
|
||||||
|
assert len(text) > 0
|
||||||
|
|
||||||
|
# Verify key content is present
|
||||||
|
assert "Lieferant GmbH" in text
|
||||||
|
assert "Rechnung" in text
|
||||||
|
|
||||||
|
def test_extract_text_from_empty_pdf(self):
|
||||||
|
"""Handle empty PDF gracefully."""
|
||||||
|
with open("tests/fixtures/EmptyPDFA1.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
text = extract_text_from_pdf(pdf_bytes)
|
||||||
|
|
||||||
|
# Should return empty string or minimal content
|
||||||
|
assert isinstance(text, str)
|
||||||
|
|
||||||
|
def test_extract_text_from_invalid_pdf(self):
|
||||||
|
"""Handle invalid PDF bytes gracefully."""
|
||||||
|
invalid_pdf = b"Not a valid PDF"
|
||||||
|
|
||||||
|
# Should raise an appropriate error
|
||||||
|
with pytest.raises(Exception):
|
||||||
|
extract_text_from_pdf(invalid_pdf)
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractFromText:
|
||||||
|
"""Test invoice field extraction from text using regex patterns."""
|
||||||
|
|
||||||
|
def test_extract_invoice_number_german(self):
|
||||||
|
"""Extract German invoice number format."""
|
||||||
|
text = "Rechnungs-Nr: RE-2025-001234"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "invoice_number" in result
|
||||||
|
assert result["invoice_number"] == "RE-2025-001234"
|
||||||
|
assert "invoice_number_confidence" in result
|
||||||
|
assert result["invoice_number_confidence"] > 0.8
|
||||||
|
|
||||||
|
def test_extract_invoice_number_english(self):
|
||||||
|
"""Extract English invoice number format."""
|
||||||
|
text = "Invoice No: INV-2025-001234"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "invoice_number" in result
|
||||||
|
assert result["invoice_number"] == "INV-2025-001234"
|
||||||
|
|
||||||
|
def test_extract_invoice_number_beleg(self):
|
||||||
|
"""Extract Beleg-Nr format."""
|
||||||
|
text = "Beleg-Nr: 471102"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "invoice_number" in result
|
||||||
|
assert result["invoice_number"] == "471102"
|
||||||
|
|
||||||
|
def test_extract_invoice_date_german(self):
|
||||||
|
"""Extract German date format and convert to ISO."""
|
||||||
|
text = "Rechnungsdatum: 04.02.2025"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "invoice_date" in result
|
||||||
|
assert result["invoice_date"] == "2025-02-04"
|
||||||
|
|
||||||
|
def test_extract_invoice_date_iso(self):
|
||||||
|
"""Extract ISO date format."""
|
||||||
|
text = "Invoice Date: 2025-02-04"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "invoice_date" in result
|
||||||
|
assert result["invoice_date"] == "2025-02-04"
|
||||||
|
|
||||||
|
def test_extract_gross_amount_german(self):
|
||||||
|
"""Extract gross amount with German format."""
|
||||||
|
text = "Brutto: 1.234,56 EUR"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "gross_amount" in result
|
||||||
|
assert result["gross_amount"] == 1234.56
|
||||||
|
assert "gross_amount_confidence" in result
|
||||||
|
|
||||||
|
def test_extract_gross_amount_variations(self):
|
||||||
|
"""Test various gross amount labels."""
|
||||||
|
variations = [
|
||||||
|
("Brutto: 118,88", 118.88),
|
||||||
|
("Gesamtbetrag: 118,88 EUR", 118.88),
|
||||||
|
("Total: 118.88", 118.88),
|
||||||
|
("Endbetrag: 529,87", 529.87),
|
||||||
|
("Summe: 100,00", 100.00),
|
||||||
|
]
|
||||||
|
|
||||||
|
for text, expected in variations:
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert "gross_amount" in result
|
||||||
|
assert result["gross_amount"] == expected
|
||||||
|
|
||||||
|
def test_extract_net_amount(self):
|
||||||
|
"""Extract net amount."""
|
||||||
|
text = "Netto: 100,00 EUR"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "net_amount" in result
|
||||||
|
assert result["net_amount"] == 100.00
|
||||||
|
assert "net_amount_confidence" in result
|
||||||
|
|
||||||
|
def test_extract_net_amount_rechnungsbetrag(self):
|
||||||
|
"""Extract net amount with alternative label."""
|
||||||
|
text = "Rechnungsbetrag: 473,00"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "net_amount" in result
|
||||||
|
assert result["net_amount"] == 473.00
|
||||||
|
|
||||||
|
def test_extract_vat_amount(self):
|
||||||
|
"""Extract VAT amount."""
|
||||||
|
text = "MwSt: 18,88 EUR"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "vat_amount" in result
|
||||||
|
assert result["vat_amount"] == 18.88
|
||||||
|
assert "vat_amount_confidence" in result
|
||||||
|
|
||||||
|
def test_extract_vat_amount_variations(self):
|
||||||
|
"""Test various VAT amount labels."""
|
||||||
|
variations = [
|
||||||
|
("MwSt: 56,87", 56.87),
|
||||||
|
("USt: 18,88 EUR", 18.88),
|
||||||
|
("Steuer: 19,00", 19.00),
|
||||||
|
]
|
||||||
|
|
||||||
|
for text, expected in variations:
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert "vat_amount" in result
|
||||||
|
assert result["vat_amount"] == expected
|
||||||
|
|
||||||
|
def test_extract_supplier_name(self):
|
||||||
|
"""Extract supplier name."""
|
||||||
|
text = "Lieferant: Lieferant GmbH"
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "supplier_name" in result
|
||||||
|
assert result["supplier_name"] == "Lieferant GmbH"
|
||||||
|
|
||||||
|
def test_extract_supplier_name_verkaeufer(self):
|
||||||
|
"""Extract supplier with Verkäufer label."""
|
||||||
|
text = "Verkäufer: ACME Corporation Inc."
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert "supplier_name" in result
|
||||||
|
assert result["supplier_name"] == "ACME Corporation Inc."
|
||||||
|
|
||||||
|
def test_extract_all_fields_comprehensive(self):
|
||||||
|
"""Extract all fields from realistic invoice text."""
|
||||||
|
text = """
|
||||||
|
Rechnungs-Nr: RE-2025-001234
|
||||||
|
Rechnungsdatum: 04.02.2025
|
||||||
|
Lieferant: Lieferant GmbH
|
||||||
|
Netto: 100,00 EUR
|
||||||
|
MwSt: 18,88 EUR
|
||||||
|
Brutto: 118,88 EUR
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert result["invoice_number"] == "RE-2025-001234"
|
||||||
|
assert result["invoice_date"] == "2025-02-04"
|
||||||
|
assert result["supplier_name"] == "Lieferant GmbH"
|
||||||
|
assert result["net_amount"] == 100.00
|
||||||
|
assert result["vat_amount"] == 18.88
|
||||||
|
assert result["gross_amount"] == 118.88
|
||||||
|
|
||||||
|
def test_confidence_scores_in_range(self):
|
||||||
|
"""Verify all confidence scores are in 0.0-1.0 range."""
|
||||||
|
text = """
|
||||||
|
Rechnungs-Nr: RE-2025-001234
|
||||||
|
Rechnungsdatum: 04.02.2025
|
||||||
|
Lieferant: Lieferant GmbH
|
||||||
|
Netto: 100,00 EUR
|
||||||
|
MwSt: 18,88 EUR
|
||||||
|
Brutto: 118,88 EUR
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
confidence_fields = [k for k in result.keys() if k.endswith("_confidence")]
|
||||||
|
|
||||||
|
for field in confidence_fields:
|
||||||
|
assert isinstance(result[field], (int, float))
|
||||||
|
assert 0.0 <= result[field] <= 1.0
|
||||||
|
|
||||||
|
def test_empty_text(self):
|
||||||
|
"""Handle empty input text gracefully."""
|
||||||
|
result = extract_from_text("")
|
||||||
|
|
||||||
|
# Should return empty dict or dict with None values
|
||||||
|
assert isinstance(result, dict)
|
||||||
|
|
||||||
|
def test_no_matches(self):
|
||||||
|
"""Handle text with no matches."""
|
||||||
|
text = "This is just random text with no invoice data."
|
||||||
|
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
assert isinstance(result, dict)
|
||||||
|
# Values should be None or missing
|
||||||
|
|
||||||
|
|
||||||
|
class TestGermanNumberFormat:
|
||||||
|
"""Test German number format conversion."""
|
||||||
|
|
||||||
|
def test_simple_decimal(self):
|
||||||
|
"""Convert simple German decimal: 123,45"""
|
||||||
|
text = "Brutto: 123,45"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["gross_amount"] == 123.45
|
||||||
|
|
||||||
|
def test_thousands_separator(self):
|
||||||
|
"""Convert with thousands: 1.234,56"""
|
||||||
|
text = "Brutto: 1.234,56"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["gross_amount"] == 1234.56
|
||||||
|
|
||||||
|
def test_large_amount(self):
|
||||||
|
"""Convert large amount: 10.000,00"""
|
||||||
|
text = "Brutto: 10.000,00"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["gross_amount"] == 10000.00
|
||||||
|
|
||||||
|
def test_integer_amount(self):
|
||||||
|
"""Convert integer: 100,00"""
|
||||||
|
text = "Netto: 100,00"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["net_amount"] == 100.00
|
||||||
|
|
||||||
|
|
||||||
|
class TestGermanDateFormat:
|
||||||
|
"""Test German date format conversion."""
|
||||||
|
|
||||||
|
def test_dd_mm_yyyy(self):
|
||||||
|
"""Convert DD.MM.YYYY to ISO format."""
|
||||||
|
text = "Rechnungsdatum: 15.11.2024"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["invoice_date"] == "2024-11-15"
|
||||||
|
|
||||||
|
def test_d_m_yyyy(self):
|
||||||
|
"""Convert D.M.YYYY (single digits) to ISO format."""
|
||||||
|
text = "Rechnungsdatum: 4.2.2025"
|
||||||
|
result = extract_from_text(text)
|
||||||
|
assert result["invoice_date"] == "2025-02-04"
|
||||||
|
|
||||||
|
|
||||||
|
class TestRealPDFExtraction:
|
||||||
|
"""Test extraction from actual PDF fixtures."""
|
||||||
|
|
||||||
|
def test_extract_from_en16931_sample(self):
|
||||||
|
"""Extract fields from EN16931_Einfach.pdf."""
|
||||||
|
with open("tests/fixtures/EN16931_Einfach.pdf", "rb") as f:
|
||||||
|
pdf_bytes = f.read()
|
||||||
|
|
||||||
|
# Extract text
|
||||||
|
text = extract_text_from_pdf(pdf_bytes)
|
||||||
|
|
||||||
|
# Extract fields
|
||||||
|
result = extract_from_text(text)
|
||||||
|
|
||||||
|
# Verify key fields were found
|
||||||
|
assert result is not None
|
||||||
|
# Check if at least some fields were extracted
|
||||||
|
# (exact values may vary based on PDF layout)
|
||||||
|
extracted_fields = [
|
||||||
|
k
|
||||||
|
for k, v in result.items()
|
||||||
|
if v is not None and not k.endswith("_confidence")
|
||||||
|
]
|
||||||
|
assert len(extracted_fields) > 0
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
"""Regression tests from real-world invoices (anonymized).
|
||||||
|
|
||||||
|
Every test in this module originated from a production bug. When a new real
|
||||||
|
invoice reveals a service bug: anonymize the invoice XML into
|
||||||
|
tests/fixtures/real/, verify it contains no real-world data, and add a test
|
||||||
|
here that locks in the correct behavior.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
from io import BytesIO
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pypdf import PdfWriter
|
||||||
|
|
||||||
|
from src.extractor import extract_zugferd
|
||||||
|
from src.models import ValidateRequest
|
||||||
|
from src.validator import validate_invoice
|
||||||
|
|
||||||
|
REAL_FIXTURES = Path(__file__).parent / "fixtures" / "real"
|
||||||
|
ALL_CHECKS = ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"]
|
||||||
|
|
||||||
|
|
||||||
|
def _pdf_with_attachment(xml_bytes: bytes) -> bytes:
|
||||||
|
"""Wrap invoice XML in a minimal PDF (no visual content)."""
|
||||||
|
writer = PdfWriter()
|
||||||
|
writer.add_blank_page(width=72, height=72)
|
||||||
|
writer.add_attachment("factur-x.xml", xml_bytes)
|
||||||
|
output = BytesIO()
|
||||||
|
writer.write(output)
|
||||||
|
return output.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
class TestFcTaxNumberBasisQuantityInvoice:
|
||||||
|
"""Anonymized EXTENDED invoice: FC-only tax registration (no VAT ID),
|
||||||
|
unit price with basis quantity 100, spaced buyer VAT ID, seller email
|
||||||
|
in DefinedTradeContact.
|
||||||
|
|
||||||
|
Regressions locked in (found 2026-09 on a real workshop invoice):
|
||||||
|
supplier tax_number never extracted, unit price off by factor 100,
|
||||||
|
spaced VAT ID rejected as invalid format, contact email dropped.
|
||||||
|
"""
|
||||||
|
|
||||||
|
XML_PATH = REAL_FIXTURES / "extended_fc_steuernummer_basisqty.xml"
|
||||||
|
|
||||||
|
def test_extraction(self) -> None:
|
||||||
|
pdf_bytes = _pdf_with_attachment(self.XML_PATH.read_bytes())
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
data = result.xml_data
|
||||||
|
|
||||||
|
assert data.invoice_number == "4711"
|
||||||
|
assert re.fullmatch(r"\d{4}-\d{2}-\d{2}", data.due_date)
|
||||||
|
assert data.supplier.tax_number == "1112223334444"
|
||||||
|
assert data.supplier.vat_id is None
|
||||||
|
assert data.supplier.email == "rechnung@beispielwerkstatt.example"
|
||||||
|
assert data.buyer.vat_id == "DE 123 456 789"
|
||||||
|
|
||||||
|
assert len(data.line_items) == 2
|
||||||
|
first, second = data.line_items
|
||||||
|
assert first.quantity == 140
|
||||||
|
assert first.unit_price == pytest.approx(0.7585)
|
||||||
|
assert first.line_total == pytest.approx(106.19)
|
||||||
|
assert second.quantity == 50
|
||||||
|
assert second.unit_price == pytest.approx(0.7585)
|
||||||
|
assert second.line_total == pytest.approx(37.93)
|
||||||
|
|
||||||
|
assert data.totals.net == pytest.approx(144.12)
|
||||||
|
assert data.totals.vat_total == pytest.approx(10.09)
|
||||||
|
assert data.totals.gross == pytest.approx(154.21)
|
||||||
|
|
||||||
|
def test_validation_all_checks_pass(self) -> None:
|
||||||
|
pdf_bytes = _pdf_with_attachment(self.XML_PATH.read_bytes())
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=result.xml_data.model_dump(),
|
||||||
|
pdf_text=result.pdf_text,
|
||||||
|
checks=ALL_CHECKS,
|
||||||
|
)
|
||||||
|
validation = validate_invoice(request)
|
||||||
|
|
||||||
|
assert validation.is_valid is True
|
||||||
|
assert validation.errors == []
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
"""Tests for utility functions."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from src.utils import (
|
||||||
|
UNECE_UNIT_CODES,
|
||||||
|
amounts_match,
|
||||||
|
parse_german_date,
|
||||||
|
parse_german_number,
|
||||||
|
round_decimal,
|
||||||
|
translate_unit_code,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestTranslateUnitCode:
|
||||||
|
"""Tests for translate_unit_code function."""
|
||||||
|
|
||||||
|
def test_translates_known_codes(self):
|
||||||
|
"""Test translation of known UN/ECE unit codes."""
|
||||||
|
assert translate_unit_code("C62") == "Stück"
|
||||||
|
assert translate_unit_code("H87") == "Stück"
|
||||||
|
assert translate_unit_code("KGM") == "Kilogramm"
|
||||||
|
assert translate_unit_code("GRM") == "Gramm"
|
||||||
|
assert translate_unit_code("TNE") == "Tonne"
|
||||||
|
assert translate_unit_code("MTR") == "Meter"
|
||||||
|
assert translate_unit_code("KMT") == "Kilometer"
|
||||||
|
assert translate_unit_code("MTK") == "Quadratmeter"
|
||||||
|
assert translate_unit_code("LTR") == "Liter"
|
||||||
|
assert translate_unit_code("MLT") == "Milliliter"
|
||||||
|
assert translate_unit_code("DAY") == "Tag"
|
||||||
|
assert translate_unit_code("HUR") == "Stunde"
|
||||||
|
assert translate_unit_code("MON") == "Monat"
|
||||||
|
assert translate_unit_code("ANN") == "Jahr"
|
||||||
|
assert translate_unit_code("SET") == "Set"
|
||||||
|
assert translate_unit_code("PCE") == "Stück"
|
||||||
|
assert translate_unit_code("EA") == "Stück"
|
||||||
|
|
||||||
|
def test_returns_original_code_for_unknown(self):
|
||||||
|
"""Test that unknown codes are returned unchanged."""
|
||||||
|
assert translate_unit_code("UNKNOWN") == "UNKNOWN"
|
||||||
|
assert translate_unit_code("XYZ") == "XYZ"
|
||||||
|
|
||||||
|
def test_all_unit_codes_defined(self):
|
||||||
|
"""Verify all 17 unit codes from spec are defined."""
|
||||||
|
expected_codes = {
|
||||||
|
"C62",
|
||||||
|
"H87",
|
||||||
|
"KGM",
|
||||||
|
"GRM",
|
||||||
|
"TNE",
|
||||||
|
"MTR",
|
||||||
|
"KMT",
|
||||||
|
"MTK",
|
||||||
|
"LTR",
|
||||||
|
"MLT",
|
||||||
|
"DAY",
|
||||||
|
"HUR",
|
||||||
|
"MON",
|
||||||
|
"ANN",
|
||||||
|
"SET",
|
||||||
|
"PCE",
|
||||||
|
"EA",
|
||||||
|
}
|
||||||
|
assert set(UNECE_UNIT_CODES.keys()) == expected_codes
|
||||||
|
|
||||||
|
|
||||||
|
class TestAmountsMatch:
|
||||||
|
"""Tests for amounts_match function."""
|
||||||
|
|
||||||
|
def test_exact_match(self):
|
||||||
|
"""Test that exact amounts match."""
|
||||||
|
assert amounts_match(100.0, 100.0) is True
|
||||||
|
assert amounts_match(123.45, 123.45) is True
|
||||||
|
|
||||||
|
def test_within_tolerance(self):
|
||||||
|
"""Test amounts within default tolerance match."""
|
||||||
|
assert amounts_match(100.00, 100.01) is True
|
||||||
|
assert amounts_match(100.00, 99.99) is True
|
||||||
|
assert amounts_match(123.45, 123.44) is True
|
||||||
|
assert amounts_match(123.45, 123.46) is True
|
||||||
|
|
||||||
|
def test_at_tolerance_boundary(self):
|
||||||
|
"""Test amounts exactly at tolerance boundary."""
|
||||||
|
assert amounts_match(100.00, 100.01) is True # difference = 0.01
|
||||||
|
assert amounts_match(100.01, 100.00) is True # difference = 0.01
|
||||||
|
|
||||||
|
def test_beyond_tolerance(self):
|
||||||
|
"""Test amounts beyond tolerance do not match."""
|
||||||
|
assert amounts_match(100.00, 100.02) is False
|
||||||
|
assert amounts_match(100.00, 99.98) is False
|
||||||
|
assert amounts_match(0.00, 0.02) is False
|
||||||
|
|
||||||
|
def test_with_custom_tolerance(self):
|
||||||
|
"""Test with custom tolerance values."""
|
||||||
|
assert amounts_match(100.0, 100.05, tolerance=0.05) is True
|
||||||
|
assert amounts_match(100.0, 100.06, tolerance=0.05) is False
|
||||||
|
|
||||||
|
def test_negative_amounts(self):
|
||||||
|
"""Test with negative amounts."""
|
||||||
|
assert amounts_match(-100.00, -100.01) is True
|
||||||
|
assert amounts_match(-100.00, -99.99) is True
|
||||||
|
assert amounts_match(-100.00, -100.02) is False
|
||||||
|
|
||||||
|
def test_zero_amounts(self):
|
||||||
|
"""Test with zero amounts."""
|
||||||
|
assert amounts_match(0.00, 0.01) is True
|
||||||
|
assert amounts_match(0.00, 0.00) is True
|
||||||
|
|
||||||
|
|
||||||
|
class TestParseGermanNumber:
|
||||||
|
"""Tests for parse_german_number function."""
|
||||||
|
|
||||||
|
def test_integer_without_separator(self):
|
||||||
|
"""Test parsing integer without separators."""
|
||||||
|
assert parse_german_number("123") == 123.0
|
||||||
|
assert parse_german_number("0") == 0.0
|
||||||
|
|
||||||
|
def test_decimal_without_thousands(self):
|
||||||
|
"""Test parsing decimal without thousands separator."""
|
||||||
|
assert parse_german_number("123,45") == 123.45
|
||||||
|
assert parse_german_number("0,99") == 0.99
|
||||||
|
|
||||||
|
def test_with_thousands_separator(self):
|
||||||
|
"""Test parsing with German thousands separator (dot)."""
|
||||||
|
assert parse_german_number("1.234,56") == 1234.56
|
||||||
|
assert parse_german_number("12.345,67") == 12345.67
|
||||||
|
assert parse_german_number("123.456,78") == 123456.78
|
||||||
|
|
||||||
|
def test_large_number(self):
|
||||||
|
"""Test parsing large numbers with multiple thousands separators."""
|
||||||
|
assert parse_german_number("1.234.567,89") == 1234567.89
|
||||||
|
|
||||||
|
def test_round_number(self):
|
||||||
|
"""Test parsing round numbers with decimal zero."""
|
||||||
|
assert parse_german_number("1.234,00") == 1234.0
|
||||||
|
|
||||||
|
def test_negative_number(self):
|
||||||
|
"""Test parsing negative numbers."""
|
||||||
|
assert parse_german_number("-1.234,56") == -1234.56
|
||||||
|
assert parse_german_number("-123,45") == -123.45
|
||||||
|
|
||||||
|
|
||||||
|
class TestParseGermanDate:
|
||||||
|
"""Tests for parse_german_date function."""
|
||||||
|
|
||||||
|
def test_standard_date(self):
|
||||||
|
"""Test parsing standard German date format."""
|
||||||
|
assert parse_german_date("04.02.2025") == "2025-02-04"
|
||||||
|
assert parse_german_date("01.01.2024") == "2024-01-01"
|
||||||
|
assert parse_german_date("31.12.2023") == "2023-12-31"
|
||||||
|
|
||||||
|
def test_single_digit_day_or_month(self):
|
||||||
|
"""Test with single digit day or month."""
|
||||||
|
assert parse_german_date("4.2.2025") == "2025-02-04"
|
||||||
|
assert parse_german_date("1.1.2024") == "2024-01-01"
|
||||||
|
assert parse_german_date("4.12.2025") == "2025-12-04"
|
||||||
|
assert parse_german_date("04.2.2025") == "2025-02-04"
|
||||||
|
|
||||||
|
def test_already_iso_format(self):
|
||||||
|
"""Test that already ISO formatted dates are returned unchanged."""
|
||||||
|
assert parse_german_date("2025-02-04") == "2025-02-04"
|
||||||
|
assert parse_german_date("2024-12-31") == "2024-12-31"
|
||||||
|
|
||||||
|
def test_invalid_format(self):
|
||||||
|
"""Test invalid date formats."""
|
||||||
|
assert parse_german_date("invalid") == "invalid"
|
||||||
|
assert parse_german_date("01/02/2025") == "01/02/2025"
|
||||||
|
|
||||||
|
def test_only_dots_not_triple(self):
|
||||||
|
"""Test date with dots but not three parts."""
|
||||||
|
assert parse_german_date("01.02") == "01.02"
|
||||||
|
|
||||||
|
|
||||||
|
class TestRoundDecimal:
|
||||||
|
"""Tests for round_decimal function."""
|
||||||
|
|
||||||
|
def test_default_two_places(self):
|
||||||
|
"""Test rounding to default 2 decimal places."""
|
||||||
|
assert round_decimal(123.456) == 123.46
|
||||||
|
assert round_decimal(123.454) == 123.45
|
||||||
|
assert round_decimal(123.455) == 123.46 # Standard rounding
|
||||||
|
assert round_decimal(123.445) == 123.45 # Standard rounding
|
||||||
|
|
||||||
|
def test_custom_places(self):
|
||||||
|
"""Test rounding to custom decimal places."""
|
||||||
|
assert round_decimal(123.4567, 3) == 123.457
|
||||||
|
assert round_decimal(123.4567, 0) == 123.0
|
||||||
|
assert round_decimal(123.4567, 4) == 123.4567
|
||||||
|
|
||||||
|
def test_rounding_up(self):
|
||||||
|
"""Test rounding up cases."""
|
||||||
|
assert round_decimal(123.449, 2) == 123.45
|
||||||
|
assert round_decimal(123.994, 2) == 123.99
|
||||||
|
|
||||||
|
def test_rounding_down(self):
|
||||||
|
"""Test rounding down cases."""
|
||||||
|
assert round_decimal(123.444, 2) == 123.44
|
||||||
|
assert round_decimal(123.004, 2) == 123.0
|
||||||
|
|
||||||
|
def test_negative_numbers(self):
|
||||||
|
"""Test rounding negative numbers."""
|
||||||
|
assert round_decimal(-123.456) == -123.46
|
||||||
|
assert round_decimal(-123.454) == -123.45
|
||||||
|
|
||||||
|
def test_zero(self):
|
||||||
|
"""Test rounding zero."""
|
||||||
|
assert round_decimal(0.0) == 0.0
|
||||||
|
assert round_decimal(0.004) == 0.0
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,355 @@
|
|||||||
|
"""Tests for plain-XML e-invoices and UBL syntax.
|
||||||
|
|
||||||
|
Fixtures in tests/fixtures/xml/ are official KoSIT XRechnung test-suite
|
||||||
|
business cases: the same invoice once in CII and once in UBL syntax.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import re
|
||||||
|
from io import BytesIO
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
from pypdf import PdfWriter
|
||||||
|
|
||||||
|
from src.extractor import (
|
||||||
|
ExtractionError,
|
||||||
|
extract_from_xml,
|
||||||
|
extract_invoice,
|
||||||
|
extract_zugferd,
|
||||||
|
)
|
||||||
|
from src.main import app
|
||||||
|
from src.models import ValidateRequest
|
||||||
|
from src.validator import validate_invoice
|
||||||
|
|
||||||
|
XML_FIXTURES = Path(__file__).parent / "fixtures" / "xml"
|
||||||
|
CII_XML = XML_FIXTURES / "xrechnung_01.01a_cii.xml"
|
||||||
|
UBL_XML = XML_FIXTURES / "xrechnung_01.01a_ubl.xml"
|
||||||
|
ALL_CHECKS = ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"]
|
||||||
|
|
||||||
|
CREDIT_NOTE_XML = b"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CreditNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
|
||||||
|
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||||
|
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
||||||
|
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
|
||||||
|
<cbc:ID>GS-0815</cbc:ID>
|
||||||
|
<cbc:IssueDate>2026-03-01</cbc:IssueDate>
|
||||||
|
<cbc:CreditNoteTypeCode>381</cbc:CreditNoteTypeCode>
|
||||||
|
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
||||||
|
<cac:AccountingSupplierParty><cac:Party>
|
||||||
|
<cac:PartyName><cbc:Name>Beispiel Handel</cbc:Name></cac:PartyName>
|
||||||
|
<cac:PartyTaxScheme>
|
||||||
|
<cbc:CompanyID>123/456/78901</cbc:CompanyID>
|
||||||
|
<cac:TaxScheme><cbc:ID>FC</cbc:ID></cac:TaxScheme>
|
||||||
|
</cac:PartyTaxScheme>
|
||||||
|
</cac:Party></cac:AccountingSupplierParty>
|
||||||
|
<cac:AccountingCustomerParty><cac:Party>
|
||||||
|
<cac:PartyLegalEntity>
|
||||||
|
<cbc:RegistrationName>Muster Kunde GmbH</cbc:RegistrationName>
|
||||||
|
</cac:PartyLegalEntity>
|
||||||
|
</cac:Party></cac:AccountingCustomerParty>
|
||||||
|
<cac:PaymentMeans>
|
||||||
|
<cbc:PaymentMeansCode>58</cbc:PaymentMeansCode>
|
||||||
|
<cbc:PaymentDueDate>2026-03-15</cbc:PaymentDueDate>
|
||||||
|
</cac:PaymentMeans>
|
||||||
|
<cac:TaxTotal>
|
||||||
|
<cbc:TaxAmount currencyID="EUR">3.80</cbc:TaxAmount>
|
||||||
|
<cac:TaxSubtotal>
|
||||||
|
<cbc:TaxableAmount currencyID="EUR">20.00</cbc:TaxableAmount>
|
||||||
|
<cbc:TaxAmount currencyID="EUR">3.80</cbc:TaxAmount>
|
||||||
|
<cac:TaxCategory><cbc:ID>S</cbc:ID><cbc:Percent>19</cbc:Percent></cac:TaxCategory>
|
||||||
|
</cac:TaxSubtotal>
|
||||||
|
</cac:TaxTotal>
|
||||||
|
<cac:LegalMonetaryTotal>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">20.00</cbc:LineExtensionAmount>
|
||||||
|
<cbc:TaxExclusiveAmount currencyID="EUR">20.00</cbc:TaxExclusiveAmount>
|
||||||
|
<cbc:TaxInclusiveAmount currencyID="EUR">23.80</cbc:TaxInclusiveAmount>
|
||||||
|
<cbc:PayableAmount currencyID="EUR">23.80</cbc:PayableAmount>
|
||||||
|
</cac:LegalMonetaryTotal>
|
||||||
|
<cac:CreditNoteLine>
|
||||||
|
<cbc:ID>1</cbc:ID>
|
||||||
|
<cbc:CreditedQuantity unitCode="H87">200</cbc:CreditedQuantity>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">20.00</cbc:LineExtensionAmount>
|
||||||
|
<cac:Item>
|
||||||
|
<cbc:Name>Schrauben M6</cbc:Name>
|
||||||
|
<cac:BuyersItemIdentification><cbc:ID>K-77</cbc:ID></cac:BuyersItemIdentification>
|
||||||
|
<cac:ClassifiedTaxCategory><cbc:ID>S</cbc:ID><cbc:Percent>19</cbc:Percent></cac:ClassifiedTaxCategory>
|
||||||
|
</cac:Item>
|
||||||
|
<cac:Price>
|
||||||
|
<cbc:PriceAmount currencyID="EUR">10.00</cbc:PriceAmount>
|
||||||
|
<cbc:BaseQuantity unitCode="H87">100</cbc:BaseQuantity>
|
||||||
|
</cac:Price>
|
||||||
|
</cac:CreditNoteLine>
|
||||||
|
</CreditNote>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
return TestClient(app)
|
||||||
|
|
||||||
|
|
||||||
|
def _validate(xml_data):
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=xml_data.model_dump(), pdf_text=None, checks=ALL_CHECKS
|
||||||
|
)
|
||||||
|
return validate_invoice(request)
|
||||||
|
|
||||||
|
|
||||||
|
class TestPlainXml:
|
||||||
|
"""Plain XML files (no PDF container) in both syntaxes."""
|
||||||
|
|
||||||
|
def test_cii_xml(self):
|
||||||
|
result = extract_invoice(CII_XML.read_bytes())
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.xml_syntax == "CII"
|
||||||
|
assert result.zugferd_profil == "XRECHNUNG_3.0"
|
||||||
|
assert result.pdf_text is None
|
||||||
|
assert result.extraction_meta.pages == 0
|
||||||
|
assert result.extraction_meta.xml_attachment_name is None
|
||||||
|
assert result.xml_data.invoice_number == "123456XX"
|
||||||
|
assert result.xml_data.invoice_date == "2016-04-04"
|
||||||
|
assert result.xml_data.buyer_reference == "04011000-12345-03"
|
||||||
|
assert result.xml_data.totals.gross == pytest.approx(336.9)
|
||||||
|
|
||||||
|
def test_ubl_xml(self):
|
||||||
|
result = extract_invoice(UBL_XML.read_bytes())
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.xml_syntax == "UBL"
|
||||||
|
assert result.zugferd_profil == "XRECHNUNG_3.0"
|
||||||
|
assert result.xml_raw.lstrip().startswith("<")
|
||||||
|
|
||||||
|
data = result.xml_data
|
||||||
|
assert data.invoice_number == "123456XX"
|
||||||
|
assert data.invoice_date == "2016-04-04"
|
||||||
|
assert data.buyer_reference == "04011000-12345-03"
|
||||||
|
assert data.currency == "EUR"
|
||||||
|
assert data.supplier.name == "[Seller name]"
|
||||||
|
assert data.supplier.vat_id == "DE 123456789"
|
||||||
|
assert data.supplier.postal_code == "12345"
|
||||||
|
assert data.supplier.country == "DE"
|
||||||
|
assert data.supplier.email == "seller@email.de"
|
||||||
|
assert data.buyer.name == "[Buyer name]"
|
||||||
|
assert data.payment_terms.iban == "DE79000000001234567890"
|
||||||
|
|
||||||
|
assert len(data.line_items) == 2
|
||||||
|
first = data.line_items[0]
|
||||||
|
assert first.article_number == "246"
|
||||||
|
assert first.quantity == 1
|
||||||
|
assert first.unit == "XPP"
|
||||||
|
assert first.unit_price == pytest.approx(288.79)
|
||||||
|
assert first.line_total == pytest.approx(288.79)
|
||||||
|
assert first.vat_rate == 7
|
||||||
|
|
||||||
|
assert data.totals.line_total_sum == pytest.approx(314.86)
|
||||||
|
assert data.totals.net == pytest.approx(314.86)
|
||||||
|
assert data.totals.vat_total == pytest.approx(22.04)
|
||||||
|
assert data.totals.gross == pytest.approx(336.9)
|
||||||
|
assert len(data.totals.vat_breakdown) == 1
|
||||||
|
assert data.totals.vat_breakdown[0].rate == 7
|
||||||
|
|
||||||
|
def test_ubl_and_cii_yield_same_invoice(self):
|
||||||
|
"""The same business case must parse identically from both syntaxes."""
|
||||||
|
cii = extract_invoice(CII_XML.read_bytes()).xml_data.model_dump()
|
||||||
|
ubl = extract_invoice(UBL_XML.read_bytes()).xml_data.model_dump()
|
||||||
|
|
||||||
|
# The note's subject-code prefix is carried differently by syntax
|
||||||
|
cii.pop("notes")
|
||||||
|
ubl.pop("notes")
|
||||||
|
assert ubl == cii
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", [CII_XML, UBL_XML])
|
||||||
|
def test_validation_passes(self, path):
|
||||||
|
validation = _validate(extract_invoice(path.read_bytes()).xml_data)
|
||||||
|
|
||||||
|
assert validation.errors == []
|
||||||
|
assert validation.is_valid is True
|
||||||
|
|
||||||
|
def test_utf8_bom_is_accepted(self):
|
||||||
|
result = extract_invoice(b"\xef\xbb\xbf" + UBL_XML.read_bytes())
|
||||||
|
|
||||||
|
assert result.xml_syntax == "UBL"
|
||||||
|
assert not result.xml_raw.startswith("")
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuyerReference:
|
||||||
|
"""BT-10 (Leitweg-ID) is mandatory on XRechnung invoices only."""
|
||||||
|
|
||||||
|
def _data_without_reference(self):
|
||||||
|
xml_data = extract_invoice(UBL_XML.read_bytes()).xml_data
|
||||||
|
xml_data.buyer_reference = None
|
||||||
|
return xml_data.model_dump()
|
||||||
|
|
||||||
|
def test_missing_on_xrechnung_is_critical(self):
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=self._data_without_reference(),
|
||||||
|
checks=["pflichtfelder"],
|
||||||
|
profile="XRECHNUNG_3.0",
|
||||||
|
)
|
||||||
|
validation = validate_invoice(request)
|
||||||
|
|
||||||
|
assert validation.is_valid is False
|
||||||
|
assert [e.field for e in validation.errors] == ["buyer_reference"]
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("profile", [None, "EN16931", "PEPPOL_BIS_BILLING_3.0"])
|
||||||
|
def test_missing_on_other_profiles_is_fine(self, profile):
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=self._data_without_reference(),
|
||||||
|
checks=["pflichtfelder"],
|
||||||
|
profile=profile,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_invoice(request).errors == []
|
||||||
|
|
||||||
|
def test_present_on_xrechnung_passes(self):
|
||||||
|
result = extract_invoice(CII_XML.read_bytes())
|
||||||
|
request = ValidateRequest(
|
||||||
|
xml_data=result.xml_data.model_dump(),
|
||||||
|
checks=ALL_CHECKS,
|
||||||
|
profile=result.zugferd_profil,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert validate_invoice(request).errors == []
|
||||||
|
|
||||||
|
|
||||||
|
class TestUblCreditNote:
|
||||||
|
"""UBL CreditNote uses its own line and quantity element names."""
|
||||||
|
|
||||||
|
def test_credit_note(self):
|
||||||
|
result = extract_invoice(CREDIT_NOTE_XML)
|
||||||
|
|
||||||
|
assert result.xml_syntax == "UBL"
|
||||||
|
assert result.zugferd_profil == "PEPPOL_BIS_BILLING_3.0"
|
||||||
|
|
||||||
|
data = result.xml_data
|
||||||
|
assert data.invoice_number == "GS-0815"
|
||||||
|
assert data.due_date == "2026-03-15"
|
||||||
|
assert data.supplier.name == "Beispiel Handel"
|
||||||
|
assert data.supplier.vat_id is None
|
||||||
|
assert data.supplier.tax_number == "123/456/78901"
|
||||||
|
assert data.buyer.name == "Muster Kunde GmbH"
|
||||||
|
assert data.payment_terms is None
|
||||||
|
|
||||||
|
assert len(data.line_items) == 1
|
||||||
|
line = data.line_items[0]
|
||||||
|
assert line.article_number_buyer == "K-77"
|
||||||
|
assert line.quantity == 200
|
||||||
|
# Price 10.00 per base quantity 100
|
||||||
|
assert line.unit_price == pytest.approx(0.10)
|
||||||
|
assert line.line_total == pytest.approx(20.0)
|
||||||
|
|
||||||
|
def test_credit_note_validation_passes(self):
|
||||||
|
validation = _validate(extract_invoice(CREDIT_NOTE_XML).xml_data)
|
||||||
|
|
||||||
|
assert validation.errors == []
|
||||||
|
|
||||||
|
|
||||||
|
class TestUblInPdf:
|
||||||
|
"""A PDF may carry a UBL invoice as attachment."""
|
||||||
|
|
||||||
|
def test_ubl_attachment(self):
|
||||||
|
writer = PdfWriter()
|
||||||
|
writer.add_blank_page(width=72, height=72)
|
||||||
|
writer.add_attachment("xrechnung.xml", UBL_XML.read_bytes())
|
||||||
|
output = BytesIO()
|
||||||
|
writer.write(output)
|
||||||
|
|
||||||
|
result = extract_invoice(output.getvalue())
|
||||||
|
|
||||||
|
assert result.is_zugferd is True
|
||||||
|
assert result.xml_syntax == "UBL"
|
||||||
|
assert result.extraction_meta.xml_attachment_name == "xrechnung.xml"
|
||||||
|
assert result.extraction_meta.pages == 1
|
||||||
|
assert result.xml_data.invoice_number == "123456XX"
|
||||||
|
|
||||||
|
def test_xrechnung_pdf_reports_xrechnung_profile(self):
|
||||||
|
"""Must hold for every factur-x version (6.x maps it to EN16931)."""
|
||||||
|
pdf_bytes = Path("tests/fixtures/validXRechnung.pdf").read_bytes()
|
||||||
|
|
||||||
|
assert extract_invoice(pdf_bytes).zugferd_profil.startswith("XRECHNUNG_")
|
||||||
|
|
||||||
|
def test_zugferd_pdf_reports_cii(self):
|
||||||
|
pdf_bytes = Path("tests/fixtures/EN16931_Einfach.pdf").read_bytes()
|
||||||
|
|
||||||
|
result = extract_zugferd(pdf_bytes)
|
||||||
|
assert result.xml_syntax == "CII"
|
||||||
|
# CII dates (format 102, YYYYMMDD) are normalized to ISO notation
|
||||||
|
assert re.fullmatch(r"\d{4}-\d{2}-\d{2}", result.xml_data.invoice_date)
|
||||||
|
assert extract_invoice(pdf_bytes).zugferd_profil == "EN16931"
|
||||||
|
|
||||||
|
|
||||||
|
class TestXmlErrors:
|
||||||
|
"""Malformed, foreign and hostile XML."""
|
||||||
|
|
||||||
|
def test_malformed_xml(self):
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_invoice(b"<?xml version='1.0'?><Invoice><unclosed>")
|
||||||
|
|
||||||
|
assert exc_info.value.error_code == "invalid_xml"
|
||||||
|
|
||||||
|
def test_foreign_xml(self):
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_invoice(b"<html><body>no invoice</body></html>")
|
||||||
|
|
||||||
|
assert exc_info.value.error_code == "unsupported_xml_format"
|
||||||
|
|
||||||
|
def test_external_entities_are_not_resolved(self, tmp_path):
|
||||||
|
secret = tmp_path / "secret.txt"
|
||||||
|
secret.write_text("TOP-SECRET-CONTENT")
|
||||||
|
doctype = f'<!DOCTYPE x [<!ENTITY xxe SYSTEM "file://{secret}">]>'.encode()
|
||||||
|
xml = UBL_XML.read_bytes()
|
||||||
|
declaration_end = xml.index(b"?>") + 2
|
||||||
|
xml = xml[:declaration_end] + doctype + xml[declaration_end:]
|
||||||
|
xml = xml.replace(b"<cbc:ID>123456XX</cbc:ID>", b"<cbc:ID>&xxe;</cbc:ID>", 1)
|
||||||
|
|
||||||
|
result = extract_from_xml(xml)
|
||||||
|
|
||||||
|
assert "TOP-SECRET-CONTENT" not in result.model_dump_json()
|
||||||
|
|
||||||
|
def test_file_too_large(self):
|
||||||
|
with pytest.raises(ExtractionError) as exc_info:
|
||||||
|
extract_invoice(b"<a>" + b" " * (10 * 1024 * 1024) + b"</a>")
|
||||||
|
|
||||||
|
assert exc_info.value.error_code == "file_too_large"
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtractEndpointXml:
|
||||||
|
"""POST /extract with plain XML."""
|
||||||
|
|
||||||
|
def test_xml_base64(self, client):
|
||||||
|
payload = {"xml_base64": base64.b64encode(UBL_XML.read_bytes()).decode()}
|
||||||
|
response = client.post("/extract", json=payload)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["is_zugferd"] is True
|
||||||
|
assert data["xml_syntax"] == "UBL"
|
||||||
|
assert data["zugferd_profil"] == "XRECHNUNG_3.0"
|
||||||
|
assert data["xml_data"]["invoice_number"] == "123456XX"
|
||||||
|
|
||||||
|
def test_xml_in_pdf_field_is_detected(self, client):
|
||||||
|
"""Clients that only know pdf_base64 can send XML through it."""
|
||||||
|
payload = {"pdf_base64": base64.b64encode(CII_XML.read_bytes()).decode()}
|
||||||
|
response = client.post("/extract", json=payload)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json()["xml_syntax"] == "CII"
|
||||||
|
|
||||||
|
def test_pdf_in_xml_field_is_rejected(self, client):
|
||||||
|
pdf_bytes = Path("tests/fixtures/EN16931_Einfach.pdf").read_bytes()
|
||||||
|
payload = {"xml_base64": base64.b64encode(pdf_bytes).decode()}
|
||||||
|
response = client.post("/extract", json=payload)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json()["error"] == "invalid_xml"
|
||||||
|
|
||||||
|
def test_no_file(self, client):
|
||||||
|
assert client.post("/extract", json={}).status_code == 422
|
||||||
|
|
||||||
|
def test_both_files(self, client):
|
||||||
|
payload = {"pdf_base64": "QQ==", "xml_base64": "QQ=="}
|
||||||
|
|
||||||
|
assert client.post("/extract", json=payload).status_code == 422
|
||||||
@@ -0,0 +1,701 @@
|
|||||||
|
version = 1
|
||||||
|
revision = 3
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "annotated-doc"
|
||||||
|
version = "0.0.4"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz", hash = "sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size = 7288, upload-time = "2025-11-10T22:07:42.062Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl", hash = "sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size = 5303, upload-time = "2025-11-10T22:07:40.673Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "annotated-types"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anyio"
|
||||||
|
version = "4.12.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "idna" },
|
||||||
|
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/96/f0/5eb65b2bb0d09ac6776f2eb54adee6abe8228ea05b20a5ad0e4945de8aac/anyio-4.12.1.tar.gz", hash = "sha256:41cfcc3a4c85d3f05c932da7c26d0201ac36f72abd4435ba90d0464a3ffed703", size = 228685, upload-time = "2026-01-06T11:45:21.246Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/38/0e/27be9fdef66e72d64c0cdc3cc2823101b80585f8119b5c112c2e8f5f7dab/anyio-4.12.1-py3-none-any.whl", hash = "sha256:d405828884fc140aa80a3c667b8beed277f1dfedec42ba031bd6ac3db606ab6c", size = 113592, upload-time = "2026-01-06T11:45:19.497Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "certifi"
|
||||||
|
version = "2026.1.4"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz", hash = "sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120", size = 154268, upload-time = "2026-01-04T02:42:41.825Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "charset-normalizer"
|
||||||
|
version = "3.5.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/e5/3f/143b048436775b0f76ac3eec145c019e8173ccc2885c8f20319b996d5e83/charset_normalizer-3.5.1.tar.gz", hash = "sha256:6117b84ea48435e5356dc737f5121485c30920ba43375fa7b434fd753df0eac3", size = 171764, upload-time = "2026-08-15T08:20:44.807Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6a/b6/034f6802e9c3f6418966cfabb7db8c9252cc2429c5098f41cc43af804149/charset_normalizer-3.5.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:eda059b6bc8bc0812d626fd91a7ce01bf583df0a61296eff390fd94141a34e30", size = 363585, upload-time = "2026-08-15T08:16:46.646Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d5/fa/6a7e2a7c4b5451912b8c417732df79574354443592a88d616de03da66ae5/charset_normalizer-3.5.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:aa2bb0b37202dca27175591f761108b5d34096ade1191ffe4808bdf6b1571488", size = 251189, upload-time = "2026-08-15T08:16:48.287Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a4/c8/ab42b07cfd82e919f427fcfaa7c41abae8242833ad1aad66d42bae40b669/charset_normalizer-3.5.1-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0b2b1b3fa5670c127b246df1d0c059defd41f689a868a3b9d79df9b1cac42d22", size = 239724, upload-time = "2026-08-15T08:16:49.67Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e7/80/b9348b5d3041209f98b4cdad7655766369233f1d533f4f4f7558e9717bec/charset_normalizer-3.5.1-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:6e5e4d73d588ca5ed09df1b7dcd1b203d1df3c542e3f50d126c947d432b10731", size = 280078, upload-time = "2026-08-15T08:16:51.228Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/82/38/083a24028304bc85bb9e376fed801178423dcbb67495f73b6ea0624e1894/charset_normalizer-3.5.1-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b54e7e13267d49ffbfe68e25b3cbd774dab38fa37238f71265e91b36146eb21c", size = 276650, upload-time = "2026-08-15T08:16:52.625Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0d/35/731ac04aa0a097fc1c97f0994c375bdb230c6c96619db794208fe664e9ce/charset_normalizer-3.5.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c7b742bf31c88566b4bb6335a7f393bb322e580b6bb98df7bd0c25e6e3519ce8", size = 262325, upload-time = "2026-08-15T08:16:54.085Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f5/28/c2028e7021fb89c6e56868ed0e387b8e9aa811abdd2ab3208d6578d2c930/charset_normalizer-3.5.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6ba32c4d2abf1d2fe7cf27d280f4cca5664233b0f885549c7761719eb977f486", size = 261140, upload-time = "2026-08-15T08:16:55.604Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/28/f0/0c0ceec6d98b7daa62e361e418135d59685811d79ba11529aad5cdf15e84/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0722590aabf9dc6a6c0343d523c05458fa2b5047dbe6302fd526bb570600753f", size = 252791, upload-time = "2026-08-15T08:16:57.103Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f0/3e/48f4cd187b1c33189d86039e9cbe4f92c05454175504b44ff81806d4d1bf/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:aa1099b956fb795e686d073568f6dc002a0bb89765ea6d5b055dd7d9bf1b116c", size = 240730, upload-time = "2026-08-15T08:16:58.418Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/42/85/f9e22af69af67c54cce42be9455d9c81294f918b4ccc454db01f66efcac2/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:bd6c173f04743d483881bffa1478d5a4624475b8cd1d2194956a75548e191c18", size = 280791, upload-time = "2026-08-15T08:16:59.918Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fd/4c/9044135f42127630b6fa742feb51256353f6ab87a78f2fdd1de3de955a7f/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:f298e218441525d3794428b4c8b8fb8662c6d3ea79925d4807ee6b9a96a3bca5", size = 259598, upload-time = "2026-08-15T08:17:01.421Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ba/ed/1dd7cfebb4e75812934c49ca3b79757d11948053f7937ab7070c151f3c55/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:6e2912d4babbc65196ac13c2f53468dc57fb8b9c25ef913e8c59ddf7c6dc0e1b", size = 278217, upload-time = "2026-08-15T08:17:02.782Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/eb/239c84503cc9e3ba6eb34686a24bc66e84f3924efdd7e38e751a19f6bc10/charset_normalizer-3.5.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3d27167433c0d5f18dc850f07d0b3816221984fecdc405d6c157a6f0b8f8e9e6", size = 263417, upload-time = "2026-08-15T08:17:04.216Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/ab/4e4510e1e288478e2c8333131d1c1382382ba8cd2165053c79e39d1da961/charset_normalizer-3.5.1-cp311-cp311-win32.whl", hash = "sha256:ac00177c4831ffa650f8609e4bdddd5fe09c03b1c0c47acece7e6ea20421598b", size = 181774, upload-time = "2026-08-15T08:17:05.58Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e3/57/32f0ccea59e8612057c61d6fd22ef2cb63cca93c9fe594094919696ac170/charset_normalizer-3.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:f9b1e28d0e8dbfa858abdba91d6b547beaf2df1a59bec6da6faae7b96a4991a9", size = 206653, upload-time = "2026-08-15T08:17:07.075Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/17/d4/b65c433fc521e58b5f54293982a5e51c05cb5f2dd3f1c7a6acb65b75324e/charset_normalizer-3.5.1-cp311-cp311-win_arm64.whl", hash = "sha256:ae31a1a1db2ee6cc2942fccaf695c934bc7f3db9f2133a3fef1f367cf1a4ab10", size = 185630, upload-time = "2026-08-15T08:17:08.502Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/30/27/78873dc8b6a56357517b74b6bb9568b80450e7bb4f6ef7e3fa9d22aa0bd7/charset_normalizer-3.5.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:5b6d1386bf0096d26d3a863dc0a487a5b4eb9aa93cf5ba69683d29dde6b9d60f", size = 344456, upload-time = "2026-08-15T08:17:10.072Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9a/4c/be49ada26b1f0232d57aa89bbebf997a5cc2332a5616b6eca26ff680044d/charset_normalizer-3.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4582c27e8c889d64811987b5967fbd3ae0c823fe1fd933b543d55ac20bb475fa", size = 238530, upload-time = "2026-08-15T08:17:11.563Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/76/84/6f1290fa07ae6978d3960caa3eb1b8019bf9284ab7c2297b00c099ef4250/charset_normalizer-3.5.1-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1d1c7a53a6c2103925cdd6d7229f8c567379f211c869793df679f2e9f738c369", size = 230200, upload-time = "2026-08-15T08:17:12.919Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e7/a0/47b18adeed31c8f16ba9700f32c1b18594cfa09f47eb672a488c273c22bf/charset_normalizer-3.5.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e6621fb2a4988d6e53eedc455e5903e2679f3967b8acb3d639f1b63c14a2e893", size = 262222, upload-time = "2026-08-15T08:17:14.571Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/38/fe/341861ac118dae06f3ec0eb487488af52128f2ef2faf0b11003944d22259/charset_normalizer-3.5.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:7c0c10730342b0c9b35dd1d619beb8214e520bd96a1f870f452680b238aab3e0", size = 258951, upload-time = "2026-08-15T08:17:16.158Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6f/89/bb5108dc6c3651dca963f2b0a3ba19bbcb370c94e1b6d3e0e844a58e6dca/charset_normalizer-3.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b9af956078716df40d985fb0dfeb2c2120c5ca92ba4ff4b388acfd01cdc14d08", size = 248801, upload-time = "2026-08-15T08:17:17.683Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b1/ba/ef83ae3aca816393decfa3530976f38a79812d707b80b580ac33b83f9877/charset_normalizer-3.5.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f9f8405c2c758532c74fed975dbee57be1f31a6e865c031870c79a6ed3212ada", size = 244070, upload-time = "2026-08-15T08:17:19.191Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f6/0b/c5292a2462d69b7378ea89793bbb5b2b6fcf6f7dd6d1667f9619094ad553/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:96fef3e886d6a9874b14f27fc193fbdc69d5d8035783d86aa4e1cea594e695f9", size = 240110, upload-time = "2026-08-15T08:17:20.547Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/46/22/111e5be3b740d5c2a5bfcedb3d237b6591e5c2e82ae9d6ffcb121fe0909c/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5d8531a6569d025f68e2321e7638fb7978f23db58e5f69f56913837aae03816e", size = 232836, upload-time = "2026-08-15T08:17:21.895Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f9/d2/d2aad6fe0dbb44b194bf3becb60f5a0ac48446ade999a47fe7bb41eb09a7/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:aae2ee51122d3ae968a3837d97dc24a0aeebb0dea23694422cd172bd30017cd6", size = 262712, upload-time = "2026-08-15T08:17:23.727Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/35/5a/337e4663a5eae6de99db940ee8066d4145caafb61327db62deda15313cce/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:7235dc28fc6dd9d832ac7c7bce95367dedb85929f17368a0c2bee1e080b9acbf", size = 242977, upload-time = "2026-08-15T08:17:25.157Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ca/85/f82f8a92e31c7519410e2e1afdc630f28ec47490ce2c09a11c1a43cbb459/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:4abdc5f9ad448c1ecbfae2974b820535d6bc6e7eef63babbab3d81cf46968c71", size = 260207, upload-time = "2026-08-15T08:17:26.602Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b7/52/643d11ffd60e9ac2fd1fb87e167a19285b9eefeff4a40e63c87cbfbeab36/charset_normalizer-3.5.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ba501e667c17d8411f98e67a022d9604ef179aff0e459b7e292c796837c13573", size = 250562, upload-time = "2026-08-15T08:17:27.971Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/62/16/46556278c2168d12df9da7fede5dc6fc70e60301b26a82bbeec238c9cfe3/charset_normalizer-3.5.1-cp312-cp312-win32.whl", hash = "sha256:cfa1c0cc3a8f9f53f1243a5a99ac36fd003880199383b37672e86ddda9cb07e2", size = 178507, upload-time = "2026-08-15T08:17:29.277Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9d/7a/4c6c298171e6b3e745633180ff59350fc0ca0db1ffd28df1e369e0579f71/charset_normalizer-3.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:3617ac3cfd8b9888f145ad89dd6e692285834b0201c6074a5eeaad3fd4d668c2", size = 200551, upload-time = "2026-08-15T08:17:30.668Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cd/d7/eb95a042f0dd22e304b0b6472b154f3546a1a039a9ee89ccb2a7f61591fc/charset_normalizer-3.5.1-cp312-cp312-win_arm64.whl", hash = "sha256:88e85ab89cb822c1e635f51d6d32e488f94e002e70e2f492bdb8b945543f345a", size = 180700, upload-time = "2026-08-15T08:17:32.028Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bc/61/2cb6ad133dbbb449fa2d37ccae973232f4827e799af258d15e589a3d1e9e/charset_normalizer-3.5.1-cp313-cp313-android_24_arm64_v8a.whl", hash = "sha256:4f298bdadb8f0b9e5672877f647d1be9373ef5320c9e2f049795e26cad28b6a9", size = 211584, upload-time = "2026-08-15T08:17:33.597Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/18/57/a305c968be1ca13f3dd1b32f445877e97addf55d80b65c7cb35fac82b777/charset_normalizer-3.5.1-cp313-cp313-android_24_x86_64.whl", hash = "sha256:88ca277405c2d3b71c4e1c2ee0e7966e807bcba86a69d11e19ba199d18ae4491", size = 223359, upload-time = "2026-08-15T08:17:35.022Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/09/0a/d3646670292ce8d8f8cc11ac067d44885e697a5591f57a9221128da5e7b3/charset_normalizer-3.5.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:9362dd90aa7dab48c0054a21187791ccf05473f7dba5d92b8033ae62164675e7", size = 194464, upload-time = "2026-08-15T08:17:36.452Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/de/93/d51ec556e01042fed6f993ea859311bc7917b466684182fbbceb6ca24762/charset_normalizer-3.5.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:977cdbd483a9cff38179bea4fd754289a6f2195c7abd414aba85410b3e66cc5e", size = 197676, upload-time = "2026-08-15T08:17:37.819Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a4/a0/562247944386f7d4ef94467e84876600cc1e0f1b93239aaa9213d2bc3cbd/charset_normalizer-3.5.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:e90251c0c7bdd54a100a0dce3c07b7e637278c93af29dbf78ebb89a58c4bac7d", size = 340473, upload-time = "2026-08-15T08:17:39.303Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/31/e7/1d994be1b93d41e9502b8b0460eaa88a1dd8df335df415db87d6c3e91ab2/charset_normalizer-3.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:94d78ecec2605a8d0398b0f365d5f12a63248438516f5dac536a5eff7337df4a", size = 240156, upload-time = "2026-08-15T08:17:40.66Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/09/53/27923ce5cc6cbccb832037b27dca98882d9c53e9b69e866bbbef4aae7fc8/charset_normalizer-3.5.1-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:d59b75732e9b6f27388e10c14b0259cc5f2e48c78627d185e6a177b58ad3cffe", size = 228246, upload-time = "2026-08-15T08:17:42.003Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ce/48/5a97e84d63af1d55c07439cb80e56d99a8efb4295700eb4e18c0d1615d2c/charset_normalizer-3.5.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:0d929fc574b4d6fd9e7c0f5c2ede8716a41911923aa7fa5fce38e0818aa4a1ac", size = 263660, upload-time = "2026-08-15T08:17:43.627Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7a/c2/071575791dcc88316c0a9a65ce38897a82e4cfe4a325f0f7fe1b1ac47bcf/charset_normalizer-3.5.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:394fea06235c8543390050ed5f529187074b029fb027213f6c46ac11ab5d950e", size = 260354, upload-time = "2026-08-15T08:17:45.094Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fb/af/63240b0c0248c075c2535a1f1bd992821d8251b9f173abc13329661d09e4/charset_normalizer-3.5.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62b55f6722735a6c472f88361cde6640608773d9443cebdbb51abf436a1fcdd3", size = 250638, upload-time = "2026-08-15T08:17:46.496Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4d/66/70dfad64f15be09c15ccfee81330a7e515895dbe296dd23114e9a231268a/charset_normalizer-3.5.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fa48b1b63d639f9483e0633e092f5851e2348c352f1f9bb6c8182f87884ef876", size = 244583, upload-time = "2026-08-15T08:17:47.963Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c0/24/ef36367d38b9ddd4bccbf72888c342e8de1f5ae506fa0b2dcf970e2732a1/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:c71fb0d56c920c269cd3e2e3fe7c610e3f1fdb21a6ce60efa6430ff63676cea6", size = 242038, upload-time = "2026-08-15T08:17:49.481Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/db/ab/55e683ba0fff2e43adafc10daa3001eac90fdaa419a97227d5a7067eedde/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:485a0d363cafefcd2538a73c7c838daa2035f09b2c9f9b5e3133f80c6aeb84c2", size = 233677, upload-time = "2026-08-15T08:17:50.845Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bd/67/0f40eaf8d1b6e7cf15e82382a2965efaca787fc1c2794b7021d37aaf5036/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:5c0ea61a470e070686aa30892fed79e297d2c8d0ab46b8bcdf027d38c51da591", size = 264491, upload-time = "2026-08-15T08:17:52.61Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5c/64/12b4c2a11ee8df4fcc518c78b0d93e3a92bd3d5253d1617ce74ff0e8c7ef/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:90b7481fb62fbe172c558bc6fd1c4c98d82004a54a7551f20e11ac9bf0b8708c", size = 245196, upload-time = "2026-08-15T08:17:54.023Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/2e/651d910af6d0fba325eee1cda37ec5443462ed25360e666c144166eb6091/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:35fe081843b35aad20ffeccec3eeffbe637b15d14f3fb22cc1b59cd8ec17e93c", size = 261660, upload-time = "2026-08-15T08:17:55.491Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/90/c6/b09e05e6db7f64338e0dc067c79577b1138da86c1e38369096851d96be88/charset_normalizer-3.5.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fd0350afdc3aabd5576f60ea109228bd5538139713c7b094c5cd27c73a98bc6f", size = 252618, upload-time = "2026-08-15T08:17:57.025Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/76/4e/362d4f9fdcdf5556fb2aa3ce7d4a58ebce03ed1ff03aa1d9aca8d02f13f3/charset_normalizer-3.5.1-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:9d9a0dc7cbe9bec24c3f767c9122c41fe5a1bc43f47cd099d00d393e09769de4", size = 140362, upload-time = "2026-08-15T08:17:58.425Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b4/d4/703be739b26acce318bd29eb3b25b7209e1b1f527f9eae3d1f1f01fdde2b/charset_normalizer-3.5.1-cp313-cp313-win32.whl", hash = "sha256:d63600d620ad0064c3a748b950ac5ea38a80190e5498532efefa4b7b3f1da1f3", size = 177755, upload-time = "2026-08-15T08:18:00.037Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/33/56d97ade41c8db611e727168c52ae46c9224c362ec28d4b65d7e9869e8da/charset_normalizer-3.5.1-cp313-cp313-win_amd64.whl", hash = "sha256:aea996a6aba25260827c9ea511d1addfde2da9eb686ac961838509086188b7e6", size = 199295, upload-time = "2026-08-15T08:18:01.506Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5b/75/5b20dd1e6573a01a08158fe104104fa2c8abf941745596954185726cd46c/charset_normalizer-3.5.1-cp313-cp313-win_arm64.whl", hash = "sha256:fd0a274c0e5f9a21565cd9d3dd749b61f96b7aa1e20a93aa1ba4029518f2e5c0", size = 179856, upload-time = "2026-08-15T08:18:02.929Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/29/cd/2b812ce5e888f1ce69a5350281e58aab07ae64a958ecae8912f30865718e/charset_normalizer-3.5.1-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:774d157f112367ff4abd29019f38f023c24e00e56edc7829c20e358a5a913ad8", size = 212318, upload-time = "2026-08-15T08:18:04.403Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9e/4a/a6ee107430768a5334e6d63f31f148a04a1a491ef161a1ac9415a73f2fa8/charset_normalizer-3.5.1-cp314-cp314-android_24_x86_64.whl", hash = "sha256:26422d45fd13551cf564c58932f7d72b4f58b93b0fcf18c35ba6be12b46bb102", size = 224897, upload-time = "2026-08-15T08:18:05.997Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c3/d9/35ae3f64f29d0179c35c3baefe575904df2913dde519129c7f75995a2b1d/charset_normalizer-3.5.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:09a7bba9f739468c8e78c36a75c33768e53cb1959fc638f510454c14683f00d5", size = 194848, upload-time = "2026-08-15T08:18:07.397Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/74/76/f2fc7380f056cc273a53af37f50d08ad54b2c59f61078f31432edcf1c2bd/charset_normalizer-3.5.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:4c9548dc78002099910abaebc0a72ac58b7d30931869e0351c09b507dff4ece3", size = 198163, upload-time = "2026-08-15T08:18:08.989Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e9/40/095ce62fa078483cccc1fa2b36e6bc9580b85422a20ee9f925341c50e44f/charset_normalizer-3.5.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:c428c6c31eb5f4277d7f8eccaf767fbd548ddd5ce3c8b4f4cbbfab3d96b5904c", size = 341823, upload-time = "2026-08-15T08:18:10.458Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f1/5a/0e58b1c04a1596e0256f407274a92d5fb2ee21324409d1fab1da48a65b5b/charset_normalizer-3.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2f06b7eae9dbe77fe1d644ca244dad508de8d302870a43f3c559b521270938a0", size = 242458, upload-time = "2026-08-15T08:18:11.989Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/22/95/b4618ce912e6db0b1aae89ba788e38e8a7eba0f3025cc66e8c0699f977b2/charset_normalizer-3.5.1-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:6b7430cf5728e68f6c462254009a6ef4086e1bea43cf2f57aa9c55fb4f50ff96", size = 226717, upload-time = "2026-08-15T08:18:13.401Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/76/c681192bbda3d55356db5dadd64381d5202b37c6b598fcda5282e88b5d3d/charset_normalizer-3.5.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ab743e9bc90c1f73552ec33e10e3331315acd2c397b36065b591b0181de533cc", size = 266111, upload-time = "2026-08-15T08:18:14.961Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/88/be/55127bfca72c0cff6c022488d140d7c5b04c771e3b72e9bdb4836d54979d/charset_normalizer-3.5.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f6f7deae3feb4edfa2efaf7c574fe88cbf055038a6abdb40188e4fff66d5699f", size = 263128, upload-time = "2026-08-15T08:18:16.515Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e0/91/39c3af510b0aa32bbda03374259200f28430febfd1bf5e511fe765282ce5/charset_normalizer-3.5.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:15f024313246a4ed976c60f440bb8d257815513a681d212ff74fd46f7d715a90", size = 251240, upload-time = "2026-08-15T08:18:18.127Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1c/a5/cbe418bbc6ecdfc3e05a0116002897c4b403a5e838d697e64c78e9f0190d/charset_normalizer-3.5.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:823f82903d189af463d7df250ef1f7f696f3cee08cc8d91deb565e8d425f6506", size = 245282, upload-time = "2026-08-15T08:18:19.625Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cc/a4/689bb42e8e7cd492f3cb64907c6bc00ad247ec9a3628cd3f8eed126e8ae1/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:01e93745f7f219b703b60ba7afead36cfc4242782be5af484673fc500df12da5", size = 244597, upload-time = "2026-08-15T08:18:21.121Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c1/ce/9962938e179cf9f699d3f1e7b3114b5d7642dee6a893745229f9dd04f274/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:329fc3ccb63ad22d867d84c2adea759a64079a37ba4a343433b02c7a2816871e", size = 231376, upload-time = "2026-08-15T08:18:22.57Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/85/54/46000450ada53bd9eac5429a2c8c54cd2d9b39c0c255f229aea9af0948a5/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:bb57753e36e4855b8ca375069482250a6246372331a3e4f3407eaebb007443f5", size = 266715, upload-time = "2026-08-15T08:18:24.235Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3d/bb/618749d70f792b44252a777bf89bfb86823b9bbc1ea13fe8ce759b07f38a/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:fce8cbd4997efeb450bd298b54f755dcdff18d496f7a5ddbb4867c6d7c88fdc3", size = 245848, upload-time = "2026-08-15T08:18:25.726Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7e/3f/ffb64458527c7668031d5eb095d978de561958dc9f5b53f8e488a533e603/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:6c9cdde8becb25a7fde49924511aa2644d6f8081cc8df8e9452724303348d8e3", size = 264521, upload-time = "2026-08-15T08:18:27.193Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4f/ab/74a55fd803916a35ac461daf002708191aac19b546b80dc8cabfedc63d98/charset_normalizer-3.5.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:9ac4444d8d4fd4c4bd08bf451ed3167aa9e7ec6cdb41b648794f1d1103652e36", size = 253054, upload-time = "2026-08-15T08:18:28.568Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a0/2a/6a9034b7d3c60b17499afb482df5878bf9fa20b50cc3887d5ef017a833db/charset_normalizer-3.5.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:f03ac127268b43ef4fe9e6ab6794a6794b49485a0cc0c1db79876d2f33f75bc7", size = 140580, upload-time = "2026-08-15T08:18:30.214Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f3/46/1d362e1a00d035d66b9869e1281eee115907f7e390a16a07824ab5737360/charset_normalizer-3.5.1-cp314-cp314-win32.whl", hash = "sha256:1f5883d77fd409a261abb5dc8ccbe335720d798b1de4abb3b1d47ccbbc76b53b", size = 180325, upload-time = "2026-08-15T08:18:31.877Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7a/7c/4938c329b6a9d446f6a59aa2092ff7118f274209b5ed0e26893d1d30a63c/charset_normalizer-3.5.1-cp314-cp314-win_amd64.whl", hash = "sha256:c658c50ac0c98cd755a2dd50b7977d3bca7df401dcc47fbdfa87db53ef7d4e8b", size = 204175, upload-time = "2026-08-15T08:18:33.466Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ac/33/eeb384dbd8dec570661354592f4f2e1b2fcc92585624d146a000caf53841/charset_normalizer-3.5.1-cp314-cp314-win_arm64.whl", hash = "sha256:4bea7f8ebe90bbd7f0e4a2de42ca6924ba23e3e76418c408ff82f1d46fabd687", size = 184123, upload-time = "2026-08-15T08:18:34.913Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1c/6c/c73fa9d5a85f6ab05395de61c5f6984e0a9ff40bb5ff888d46dff02526c6/charset_normalizer-3.5.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:fbc597639158fd7c14d55e808718848319540f51b0e6746e3eefa59723a4a348", size = 381682, upload-time = "2026-08-15T08:18:36.349Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/30/c7/63565f860921457feba93bae6c86fb7746deb4cffeed2f375cb845318146/charset_normalizer-3.5.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e71c909f353863b2b89c83de2ebed71ea6d0df8a6ef65a128193c5e650766bef", size = 240826, upload-time = "2026-08-15T08:18:37.887Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/06/ae/7ae8807410dfa33f8e6f1715740adeaafa8a816cc4cb33508f54b1f7c896/charset_normalizer-3.5.1-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:7ac76cf9afd34929d76eb7fcb63be476a4853d8a96f0dcf2d0db68a0cbdf9885", size = 227861, upload-time = "2026-08-15T08:18:39.315Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e9/a3/887c1642f0da26000b0e0652d91071113c0e72cea33952e225cf589f49a9/charset_normalizer-3.5.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a3a370082ce34d0612f421e15fe011c53bb1feff21a26d06ad4fb244dab5a375", size = 260758, upload-time = "2026-08-15T08:18:40.88Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3e/11/e6f5b9a3d0e55b0ef7505cd3765cdd48f22db89994c947b316f52f801fd8/charset_normalizer-3.5.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:256dd4d85d9e4dc595e2bc983c980e73f62ddeb3165c58b4c3dfe78c5c8548c1", size = 259950, upload-time = "2026-08-15T08:18:42.351Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1b/ee/e4e10a94d51cd1ee638aa7e00b65399e6b2a4e8376ab6d2eac9f95586671/charset_normalizer-3.5.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:58d4aa13a59c969dbfdf9e6a9560e242cbfd9e8a8f50c2747714df1a423adf65", size = 249329, upload-time = "2026-08-15T08:18:43.914Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c4/25/d5f4198819e6059735a84e8d0bfb72dc33976da67b97adcd3fb5a5e07ec6/charset_normalizer-3.5.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0c6dfb5ca6723eeed15aa8e564a014d69fcb8812f94eef11fe3631e0508199f5", size = 243137, upload-time = "2026-08-15T08:18:45.368Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a5/e9/e925ca7569cf9fb9701fd82503fee73eea5268fdb856bdd64947092d3daa/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c010f5581d9c612804cc59fcf7b524b707fbcb72828551237ab545bb5c7034af", size = 242820, upload-time = "2026-08-15T08:18:46.842Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/34/17/672c251a888ed2aebcdd2fe830ad0104e25ff83c43f5c4f9c15e9fc6853c/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:52ec005752a56ae79547a05c0139ca2501a0c866390b6115008456b9f0e7cde1", size = 230504, upload-time = "2026-08-15T08:18:48.353Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3f/fc/f6a85abebd42ce4da2f1db0aa56cc6a0df1995e318b3875d14401b8381d1/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:2bced4061f000f7187254a02ad3433ae17eaf991747ceea2f478422590a5bba9", size = 263087, upload-time = "2026-08-15T08:18:49.859Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/98/66/7c42677e739ba66746b297e2046918d793078094dc239e1e72768cffccc6/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:9eea3ab2597a5e65fe65296e2d6a84570845a6b55532d90333d740d48bbc850a", size = 243269, upload-time = "2026-08-15T08:18:51.601Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/de/d8/a50b79237f417af10f8c2a501ce8d1ca87829a22e69117891ca4ba20a69e/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:496846868fea80e479324862fa877f02411f2fd0f83b79ccee2607aa68b2a032", size = 258766, upload-time = "2026-08-15T08:18:53.23Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2e/1d/0fc91aeaeb3c83b748f532399ce67cf84604b48297405d740000f7a9e786/charset_normalizer-3.5.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:85d5855daafc240cc045c026d7a15fd198a09b0fc8ff6f5ecbb5297b509cb11e", size = 250814, upload-time = "2026-08-15T08:18:54.768Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ae/10/3d8c777cf9024615295aa1b808324ad5b4a77855869c00824bad74ffaf8a/charset_normalizer-3.5.1-cp314-cp314t-win32.whl", hash = "sha256:58d3e12c88e0950bca850ae1f7c256055c097639c2edb9eb123af9807d8b15e4", size = 191074, upload-time = "2026-08-15T08:18:56.305Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4d/81/ae557d3c44d1a1d688696d60563413a0866a91b7ebc50f20df838be3d8c8/charset_normalizer-3.5.1-cp314-cp314t-win_amd64.whl", hash = "sha256:acaf604462bf330b0d07e7a07c1d6e4adac79e5fb13e9c5140590542cafacc00", size = 216476, upload-time = "2026-08-15T08:18:57.889Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/27/e9/61c01fb8b804692569c036b3fc50495814502dcf13a60649c6055390b02c/charset_normalizer-3.5.1-cp314-cp314t-win_arm64.whl", hash = "sha256:fdb8a068947befafba9952162645dc2fecaeb400e64584829ed5e9b2fbe21a7f", size = 194115, upload-time = "2026-08-15T08:18:59.418Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4a/4e/8544831ef59d8f27ce92c80871380fdacc8076a8a56ed62f82e54f991333/charset_normalizer-3.5.1-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:9085f87b0e38a2b92b8923059b4e8789fe40d9279712d15dcc670048d77079af", size = 342048, upload-time = "2026-08-15T08:19:01.054Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7f/a6/e3b46852424246065355644f4fb6dbccc0239a42a2eee27ecfc8957f0bcd/charset_normalizer-3.5.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2679de311c7946dde5d3b6f44941844133ff5c7cb86099c0061ab1e8901c20a8", size = 242997, upload-time = "2026-08-15T08:19:02.492Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/03/3b/0cc9a26777334ab2f2e3089b948bbf4e4fe72ea70b897715ef6415043ec8/charset_normalizer-3.5.1-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:baf3775a2635e5a11fbd5e4e64ee69c7e86875d224a5c72aca4c141064589a90", size = 237014, upload-time = "2026-08-15T08:19:03.943Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8c/c2/027335f0aa337a2a2e121bac1ad88c4f02ba6053ea0926802784f3db11af/charset_normalizer-3.5.1-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8ac8c94b6539074e0f40899301273ac8402b9b3e01c7b7ba269ff30340aaaf20", size = 266174, upload-time = "2026-08-15T08:19:05.598Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/86/d3/e367787febe4e74769dec0f406f2c3c8d1b955fce5aee1fd0f94e8367a45/charset_normalizer-3.5.1-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:8fe532b3c966d1fb794e0698e4589d0444017ae77fc0b31edea13c0e35bcc449", size = 263361, upload-time = "2026-08-15T08:19:07.251Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/af/3d/391b193eb9f3e84b02f9314088c386debdc0debee843535aaea2e2c6715d/charset_normalizer-3.5.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5c84bec0ab5ae0c64bfe73a7d2adcb5ce73b467523fc27fd6a28ab2aa6cbe35a", size = 252143, upload-time = "2026-08-15T08:19:08.816Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2e/57/de221f1745a90d418199761967e2776bfe2c275a1194220985e8c1d37833/charset_normalizer-3.5.1-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:854066be00447fa8de2ccbbe893e2ffc4b123ef16d897af794c1e18bd4a714b0", size = 252086, upload-time = "2026-08-15T08:19:10.255Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c8/e3/d119f86a01f9331e8186175f24873b1d74a7ee9e2e4b4d68f9947dae5afd/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:21b82d8082f6f5e7f456ef0bd16323d08de1266efbfeb476e64b2a91d1471a4e", size = 245231, upload-time = "2026-08-15T08:19:11.807Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/26/de/d8e48c135ae480879539cdb179c8d3b50c7879497d75dd899b5763b69cee/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_armv7l.whl", hash = "sha256:838648accb3a7fd9803fd45c87bce8509648eb0c11bc34e216141300977244f2", size = 241546, upload-time = "2026-08-15T08:19:13.416Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/67/c4/217755fd1abc50d326c252922cd642002758095a81ff45010337b8b3ef65/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:195ce897c6153c0700078142cf8efe3e6454ca4cf4357499e4078dfd83396626", size = 267033, upload-time = "2026-08-15T08:19:14.981Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b8/d7/34d8e404e358d2adcc5a228c2134643af00104c8fb0bf525f3688d756f05/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:978eab16f55b4ab2c2a745be9a0a840bf8f09a7f227d9c76eb30214d078865a5", size = 252045, upload-time = "2026-08-15T08:19:16.618Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5e/fa/40414471acf0aa0692ca77305aa00e434fcd8288f0941c93c30e9a5f8f2f/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_s390x.whl", hash = "sha256:cc0329df4caaceb950d2f580b5ac716a377f7059624a0bafaeaf8a218c6ed774", size = 264866, upload-time = "2026-08-15T08:19:18.101Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/32/90/fcc850bae791abd2e0c041847f13e270aa08692a79f3e00de6d2dce1cb50/charset_normalizer-3.5.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:687c9ca3035544b113bea2055e180af96fb63c0c476e22a9180f51925186e7b7", size = 253932, upload-time = "2026-08-15T08:19:19.734Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/af/af/53afe99068b3c10b4cbae592a52ef72a7c92c0188440e83ee3a078fd8f75/charset_normalizer-3.5.1-cp315-cp315-win32.whl", hash = "sha256:706bfd38730a5ac7a365793269a00f4e988178cec121391f4248d84ad8c972e9", size = 180320, upload-time = "2026-08-15T08:19:21.37Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c9/bc/f46a132041b29e4a8779ed712d3df1bf112e94ca8de58b66d7ec2c0cf8b9/charset_normalizer-3.5.1-cp315-cp315-win_amd64.whl", hash = "sha256:92caef967d287a407085d61176fce4012b1dd62daed4eb6d5ceb26d3d2538712", size = 204174, upload-time = "2026-08-15T08:19:23.088Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a1/5d/9ed554480eda8e447b673648628fdc29574d23dbad01fe11837adedd1cae/charset_normalizer-3.5.1-cp315-cp315-win_arm64.whl", hash = "sha256:5fc45d653ea8c9a20479167e11d4a0f8cb2fa3470737ab6f9c827532313187b7", size = 184126, upload-time = "2026-08-15T08:19:24.471Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3b/32/9b8929bf384061ee1fe5d9c27c6f9776d3d824039ad4e14c88ec00c7808e/charset_normalizer-3.5.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:59171c6e45bf07d0d5cab3b0bf81d945035530f6873398b3b531c31184d46663", size = 381441, upload-time = "2026-08-15T08:19:26.038Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/96/10/e9aa7923d3ddac652c99a1c5f7be494e737e151566a44abe018daf757f2c/charset_normalizer-3.5.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9dbdd9205662134957cf0c324f639bdc5031c0ca056e2369e238db75187c0f11", size = 241742, upload-time = "2026-08-15T08:19:27.532Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/28/53/a2d249ebddf47b889a100c0bdcb61a2f9dbb8bc24ef325cc062e4f476877/charset_normalizer-3.5.1-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e4b018dc5a0eee4676e38fe84a47a427816c590b93b55d9025274ec4d6ffc2dc", size = 235298, upload-time = "2026-08-15T08:19:29.274Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7d/07/469f78af590f7d5cd48e20d8dbfa3d66deeff9ba37768c04d886b5afd45c/charset_normalizer-3.5.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ced3fdd71aaa83ce593746c2edb42b7a59cb4c19c8b5c407781c72e493aae55a", size = 262500, upload-time = "2026-08-15T08:19:30.955Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/55/66/3bb56a47f7dcba014055b1a1d33c6f08bbe9c1e74dba154cfa25f90ae885/charset_normalizer-3.5.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:19a3dd5aa73cef1c99687c4fc57db016a9c17104ae1185da88ba566a5d3bebe4", size = 258888, upload-time = "2026-08-15T08:19:32.458Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ff/c1/2adc2800903fb013210349313b710a5376856578d9e33e6b9a1d8b36714a/charset_normalizer-3.5.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cc5d36d96478aa9c60654bd932525bf32964c62a7281eafdf16d85003a8d6004", size = 250243, upload-time = "2026-08-15T08:19:33.94Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/95/b5/a18d0dd1157ab655cc2cb14a545f4a4784bbad70ab3502412e36097502d9/charset_normalizer-3.5.1-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:04368edf83514385ffc3e1cfd4546e595f4f1272dd23ba437a93a9cc3741d47b", size = 249871, upload-time = "2026-08-15T08:19:35.413Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ad/c3/525f508cd1e58d0450ac55ed40ac75bc3a97482c59def5278456a5fbf03c/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:9b5db6052055d34d41230fb78d7c439c23dc536a9896f6cb039e8dd92cfc1263", size = 243580, upload-time = "2026-08-15T08:19:36.886Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7c/c1/49a91fe7e97c8140094ca5c64161ab623a70d9f636bf834eace14048acb5/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_armv7l.whl", hash = "sha256:252d099029bcbea642f2a06c4ed5046bdf8b5a8150b64afa5e027e88b106e5ee", size = 239807, upload-time = "2026-08-15T08:19:38.392Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/58/56a48c296601274c4689b864a8e2dfb209b81dfcb39472753ce95eea662b/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:6199d5606e2bbf2b096cf64d03f8b6790c91081d5ac866b8e7bb6422738cc60c", size = 264083, upload-time = "2026-08-15T08:19:39.856Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/10/4c/dc48409274a1817ff349711d26c62aa0c597df865d4d69ef79160c859193/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:77efcff2b23071c349402ac1066667a3d011f62398d81408c9b88ad991747c9e", size = 250317, upload-time = "2026-08-15T08:19:41.53Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/81/58/d325912115caec62d6bdd77bbab5e0b7da5d234a9f20affdffcbcb530d0b/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_s390x.whl", hash = "sha256:a5cbd90ecf0fc62e64726917ad083b73001f0563657a87ec3c0b504e277dc90d", size = 258173, upload-time = "2026-08-15T08:19:43.07Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/34/f7/b13b1ccae2c8ec63980d13be1890eb73f8aeabbfce02a24aabc0908788f5/charset_normalizer-3.5.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:4d26f14f041e83dd8edfd61f4cd4fa7285d31798b5bf1f28e70c367ba6c41d61", size = 251960, upload-time = "2026-08-15T08:19:44.587Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1e/25/ed3f9919c5aef8cc818be1f972f565f7610d7b2076b8ebb98839516ffc3c/charset_normalizer-3.5.1-cp315-cp315t-win32.whl", hash = "sha256:ac13b004224fb341e1e25a1ed5e19d32f57cdb2a403e01f003b46f051a550f6f", size = 191186, upload-time = "2026-08-15T08:19:46.293Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/69/d5/43c2b3e9d8267092b913eb8b0603f0f71993c395632886bd37a7223f96cf/charset_normalizer-3.5.1-cp315-cp315t-win_amd64.whl", hash = "sha256:35aea775dc2bd5f54cd84a1cd2696cc3207c479cb9cf0bd346f0d343e4300ddb", size = 215947, upload-time = "2026-08-15T08:19:47.853Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a8/76/9aad3e9c8865e5e0efa9a7f6f81c37a67635a985145ecd44528a81e088ee/charset_normalizer-3.5.1-cp315-cp315t-win_arm64.whl", hash = "sha256:fb78f6e7fcd8ad785d28cd577168bc1aaee827b25bb8755638f694794ea98f0a", size = 193909, upload-time = "2026-08-15T08:19:49.383Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5b/97/fb4e82231aba271ffd775a1b4993b0defc4e3059f286ae41d9433409fe85/charset_normalizer-3.5.1-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:41876ee62a3dddf48ff1121ad8f0798032aa03f2fd35f21f34a4cab14f18d8d2", size = 331467, upload-time = "2026-08-15T08:19:50.959Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9f/2f/fe3f187327aac18e2d54e9d2b08e15d27bf9b642d9e51c219f130fc34d1a/charset_normalizer-3.5.1-cp37-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:a6dac12ff6b846103483683f60c5f8fee205121adc58ffd87e90a90a3af69e99", size = 253057, upload-time = "2026-08-15T08:19:52.654Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d7/c7/9e48cee5c161fe24da823b61bf381921d77cb994a0a4de148e95018c1984/charset_normalizer-3.5.1-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cee5dd7c6fb5dd52a0fe2a740f9bc6e3593f5f8b1788bde49de02086f30182b2", size = 240930, upload-time = "2026-08-15T08:19:54.163Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/49/e0/716601f3cc69be7b198951150c75ead1ece33c3c8036ff6ffa46029659a0/charset_normalizer-3.5.1-cp37-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:343fb4f2821043bd87095f7b08a1a181febc8e36ac64212143bbfd0a0e1bc235", size = 230822, upload-time = "2026-08-15T08:19:55.807Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/05/71bfc5caa0abcc45aea1f6a4d50ac68e59605ddc7666fe8494f4cd229665/charset_normalizer-3.5.1-cp37-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ae4a097991662cd4fff0ddc74e0fe7874f82e00042fa0ea00855645ed0c79598", size = 260037, upload-time = "2026-08-15T08:19:57.312Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c3/92/de7e32ed05341e7a9c4c877c318418197b7f2d66a3b68d561bf2ac57ca3e/charset_normalizer-3.5.1-cp37-abi3-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4b599739b93b2cbeded49645ae3c8d1405c29ddfbceac1545c87a3f9580a9e96", size = 255097, upload-time = "2026-08-15T08:19:59.056Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f5/7b/ade0a122600319dfa0b1000ab0f9731c94a817904cf3c5de408c73a4ede7/charset_normalizer-3.5.1-cp37-abi3-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b39b69b347e5e47a3b5b8cfc005c68c1ba347474e3960236c4944a8ecd174962", size = 250166, upload-time = "2026-08-15T08:20:00.612Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/75/9c/019fbb9f4834491a160951349b1a3714439376f66e5f7cf18b4f18f0c7aa/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:a2028475ba855475b8b4d3cfeb4994269c967aea8b9892dfba907f4263a863a3", size = 241821, upload-time = "2026-08-15T08:20:02.321Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2b/b8/11d4840bfc99330cc7fbcc2681ee5a044553a6e77655508d8f9b2bff7b34/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:36047af20e17097c3bb9476c2b7655f2f7aa51322c0ba58c07695bedf755a950", size = 232529, upload-time = "2026-08-15T08:20:04.008Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/18/96/2b3a21492d9f65171ac75d872f5018260013d00bfa0ff70ec9f179148cbd/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:4c4fb141a727957c93edfe5c32a26ceb6b5f6461d67146e2d39f51e16170bea8", size = 260348, upload-time = "2026-08-15T08:20:05.877Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d6/aa/a69a2028e8bd052476c245460ab19d7de595de084dd968f2d75cd50c3e25/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:2f293479cce755c75f1697e87c409b7ae4c555c7dfecb6e988ad13abba943031", size = 247234, upload-time = "2026-08-15T08:20:07.487Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/35/8a/3d130aeabcaf3d2466af76b7b141c08d9e89c9016ab4b7cdd0f7dc2d1c62/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_s390x.whl", hash = "sha256:3588e376b3ea2eea84976f67273d679f229e24c66dce7b82ae45aef04ff6e072", size = 256917, upload-time = "2026-08-15T08:20:09.142Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/80/c2/a7379b840292d0c1ab9fbd17d1f3967aa81794dc95bc74be8999d7fedcf7/charset_normalizer-3.5.1-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:e199fb99720074809a7720f1c0b4d919eea8b87e88713e0f8f602f7bef543d9d", size = 254846, upload-time = "2026-08-15T08:20:10.727Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/01/65/d43b714731bb2f40d4053dfa00ecfc1c5a301f8e3316c5db3a09af59fe94/charset_normalizer-3.5.1-cp37-abi3-win32.whl", hash = "sha256:dd732602a7009217f658d5863d12d79d373a4de0eebc111094bcdd3bb8e0a6cc", size = 174216, upload-time = "2026-08-15T08:20:12.334Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/35/4f/b911ed898b26a09789eba9c9200c999aff6c61b4bafaf4838e56d1a1e1a3/charset_normalizer-3.5.1-cp37-abi3-win_amd64.whl", hash = "sha256:70055ff39b97c99e7ae40ea3e393fb62aa2e44dbd9b29f8d14f42fb0025c3959", size = 199764, upload-time = "2026-08-15T08:20:13.908Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f0/a7/920baf467bfd9bf689f3b318340f37aee4572a71f162bd8db51da55ba4fa/charset_normalizer-3.5.1-cp37-abi3-win_arm64.whl", hash = "sha256:87e4f41d375c0b9be2fb5251aee4b8a689169e134535aed81bf085c3b647451e", size = 287318, upload-time = "2026-08-15T08:20:15.551Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cc/61/d01fc49b8dea277640b55a9e15960dbca9fdc8c9fde18e572d39c59f4019/charset_normalizer-3.5.1-py3-none-any.whl", hash = "sha256:6df0ec430f9a831772c23ca5a224cba36517a58a84bb32c32bb59a9fa67c47f6", size = 68658, upload-time = "2026-08-15T08:20:43.306Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "click"
|
||||||
|
version = "8.3.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorama"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "factur-x"
|
||||||
|
version = "6.8"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "lxml" },
|
||||||
|
{ name = "pypdf" },
|
||||||
|
{ name = "python-stdnum" },
|
||||||
|
{ name = "requests" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/44/81/f00fb3ec786a23c47d96ab68f2b4d11856de17ca3c9818f57b4dbb7308b3/factur_x-6.8.tar.gz", hash = "sha256:d0071e9c7217666ead025f442765e1e2ef4a0ba8e2677bab640427eb08bbb349", size = 1112989, upload-time = "2026-08-18T09:24:57.393Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/be/9a9020187e4805d61668b5d8c4c263731b3697f9eba2aa6a689d3e7eea4b/factur_x-6.8-py3-none-any.whl", hash = "sha256:02b57dd57f59d0cdd87f034a538bf30a4b9241a72a19cd75fe1538233163ee15", size = 906687, upload-time = "2026-08-18T09:24:55.47Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastapi"
|
||||||
|
version = "0.129.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "annotated-doc" },
|
||||||
|
{ name = "pydantic" },
|
||||||
|
{ name = "starlette" },
|
||||||
|
{ name = "typing-extensions" },
|
||||||
|
{ name = "typing-inspection" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/48/47/75f6bea02e797abff1bca968d5997793898032d9923c1935ae2efdece642/fastapi-0.129.0.tar.gz", hash = "sha256:61315cebd2e65df5f97ec298c888f9de30430dd0612d59d6480beafbc10655af", size = 375450, upload-time = "2026-02-12T13:54:52.541Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9e/dd/d0ee25348ac58245ee9f90b6f3cbb666bf01f69be7e0911f9851bddbda16/fastapi-0.129.0-py3-none-any.whl", hash = "sha256:b4946880e48f462692b31c083be0432275cbfb6e2274566b1be91479cc1a84ec", size = 102950, upload-time = "2026-02-12T13:54:54.528Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "h11"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httpcore"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "certifi" },
|
||||||
|
{ name = "h11" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httpx"
|
||||||
|
version = "0.28.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "anyio" },
|
||||||
|
{ name = "certifi" },
|
||||||
|
{ name = "httpcore" },
|
||||||
|
{ name = "idna" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "idna"
|
||||||
|
version = "3.11"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iniconfig"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lxml"
|
||||||
|
version = "6.0.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/aa/88/262177de60548e5a2bfc46ad28232c9e9cbde697bd94132aeb80364675cb/lxml-6.0.2.tar.gz", hash = "sha256:cd79f3367bd74b317dda655dc8fcfa304d9eb6e4fb06b7168c5cf27f96e0cd62", size = 4073426, upload-time = "2025-09-22T04:04:59.287Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/77/d5/becbe1e2569b474a23f0c672ead8a29ac50b2dc1d5b9de184831bda8d14c/lxml-6.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:13e35cbc684aadf05d8711a5d1b5857c92e5e580efa9a0d2be197199c8def607", size = 8634365, upload-time = "2025-09-22T04:00:45.672Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/28/66/1ced58f12e804644426b85d0bb8a4478ca77bc1761455da310505f1a3526/lxml-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3b1675e096e17c6fe9c0e8c81434f5736c0739ff9ac6123c87c2d452f48fc938", size = 4650793, upload-time = "2025-09-22T04:00:47.783Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/11/84/549098ffea39dfd167e3f174b4ce983d0eed61f9d8d25b7bf2a57c3247fc/lxml-6.0.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8ac6e5811ae2870953390452e3476694196f98d447573234592d30488147404d", size = 4944362, upload-time = "2025-09-22T04:00:49.845Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ac/bd/f207f16abf9749d2037453d56b643a7471d8fde855a231a12d1e095c4f01/lxml-6.0.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5aa0fc67ae19d7a64c3fe725dc9a1bb11f80e01f78289d05c6f62545affec438", size = 5083152, upload-time = "2025-09-22T04:00:51.709Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/15/ae/bd813e87d8941d52ad5b65071b1affb48da01c4ed3c9c99e40abb266fbff/lxml-6.0.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:de496365750cc472b4e7902a485d3f152ecf57bd3ba03ddd5578ed8ceb4c5964", size = 5023539, upload-time = "2025-09-22T04:00:53.593Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/02/cd/9bfef16bd1d874fbe0cb51afb00329540f30a3283beb9f0780adbb7eec03/lxml-6.0.2-cp311-cp311-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:200069a593c5e40b8f6fc0d84d86d970ba43138c3e68619ffa234bc9bb806a4d", size = 5344853, upload-time = "2025-09-22T04:00:55.524Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b8/89/ea8f91594bc5dbb879734d35a6f2b0ad50605d7fb419de2b63d4211765cc/lxml-6.0.2-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7d2de809c2ee3b888b59f995625385f74629707c9355e0ff856445cdcae682b7", size = 5225133, upload-time = "2025-09-22T04:00:57.269Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b9/37/9c735274f5dbec726b2db99b98a43950395ba3d4a1043083dba2ad814170/lxml-6.0.2-cp311-cp311-manylinux_2_31_armv7l.whl", hash = "sha256:b2c3da8d93cf5db60e8858c17684c47d01fee6405e554fb55018dd85fc23b178", size = 4677944, upload-time = "2025-09-22T04:00:59.052Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/20/28/7dfe1ba3475d8bfca3878365075abe002e05d40dfaaeb7ec01b4c587d533/lxml-6.0.2-cp311-cp311-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:442de7530296ef5e188373a1ea5789a46ce90c4847e597856570439621d9c553", size = 5284535, upload-time = "2025-09-22T04:01:01.335Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e7/cf/5f14bc0de763498fc29510e3532bf2b4b3a1c1d5d0dff2e900c16ba021ef/lxml-6.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2593c77efde7bfea7f6389f1ab249b15ed4aa5bc5cb5131faa3b843c429fbedb", size = 5067343, upload-time = "2025-09-22T04:01:03.13Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1c/b0/bb8275ab5472f32b28cfbbcc6db7c9d092482d3439ca279d8d6fa02f7025/lxml-6.0.2-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:3e3cb08855967a20f553ff32d147e14329b3ae70ced6edc2f282b94afbc74b2a", size = 4725419, upload-time = "2025-09-22T04:01:05.013Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/25/4c/7c222753bc72edca3b99dbadba1b064209bc8ed4ad448af990e60dcce462/lxml-6.0.2-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:2ed6c667fcbb8c19c6791bbf40b7268ef8ddf5a96940ba9404b9f9a304832f6c", size = 5275008, upload-time = "2025-09-22T04:01:07.327Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6c/8c/478a0dc6b6ed661451379447cdbec77c05741a75736d97e5b2b729687828/lxml-6.0.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b8f18914faec94132e5b91e69d76a5c1d7b0c73e2489ea8929c4aaa10b76bbf7", size = 5248906, upload-time = "2025-09-22T04:01:09.452Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2d/d9/5be3a6ab2784cdf9accb0703b65e1b64fcdd9311c9f007630c7db0cfcce1/lxml-6.0.2-cp311-cp311-win32.whl", hash = "sha256:6605c604e6daa9e0d7f0a2137bdc47a2e93b59c60a65466353e37f8272f47c46", size = 3610357, upload-time = "2025-09-22T04:01:11.102Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e2/7d/ca6fb13349b473d5732fb0ee3eec8f6c80fc0688e76b7d79c1008481bf1f/lxml-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e5867f2651016a3afd8dd2c8238baa66f1e2802f44bc17e236f547ace6647078", size = 4036583, upload-time = "2025-09-22T04:01:12.766Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ab/a2/51363b5ecd3eab46563645f3a2c3836a2fc67d01a1b87c5017040f39f567/lxml-6.0.2-cp311-cp311-win_arm64.whl", hash = "sha256:4197fb2534ee05fd3e7afaab5d8bfd6c2e186f65ea7f9cd6a82809c887bd1285", size = 3680591, upload-time = "2025-09-22T04:01:14.874Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f3/c8/8ff2bc6b920c84355146cd1ab7d181bc543b89241cfb1ebee824a7c81457/lxml-6.0.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a59f5448ba2ceccd06995c95ea59a7674a10de0810f2ce90c9006f3cbc044456", size = 8661887, upload-time = "2025-09-22T04:01:17.265Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/6f/9aae1008083bb501ef63284220ce81638332f9ccbfa53765b2b7502203cf/lxml-6.0.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e8113639f3296706fbac34a30813929e29247718e88173ad849f57ca59754924", size = 4667818, upload-time = "2025-09-22T04:01:19.688Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f1/ca/31fb37f99f37f1536c133476674c10b577e409c0a624384147653e38baf2/lxml-6.0.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a8bef9b9825fa8bc816a6e641bb67219489229ebc648be422af695f6e7a4fa7f", size = 4950807, upload-time = "2025-09-22T04:01:21.487Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/da/87/f6cb9442e4bada8aab5ae7e1046264f62fdbeaa6e3f6211b93f4c0dd97f1/lxml-6.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:65ea18d710fd14e0186c2f973dc60bb52039a275f82d3c44a0e42b43440ea534", size = 5109179, upload-time = "2025-09-22T04:01:23.32Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c8/20/a7760713e65888db79bbae4f6146a6ae5c04e4a204a3c48896c408cd6ed2/lxml-6.0.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c371aa98126a0d4c739ca93ceffa0fd7a5d732e3ac66a46e74339acd4d334564", size = 5023044, upload-time = "2025-09-22T04:01:25.118Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a2/b0/7e64e0460fcb36471899f75831509098f3fd7cd02a3833ac517433cb4f8f/lxml-6.0.2-cp312-cp312-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:700efd30c0fa1a3581d80a748157397559396090a51d306ea59a70020223d16f", size = 5359685, upload-time = "2025-09-22T04:01:27.398Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b9/e1/e5df362e9ca4e2f48ed6411bd4b3a0ae737cc842e96877f5bf9428055ab4/lxml-6.0.2-cp312-cp312-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c33e66d44fe60e72397b487ee92e01da0d09ba2d66df8eae42d77b6d06e5eba0", size = 5654127, upload-time = "2025-09-22T04:01:29.629Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c6/d1/232b3309a02d60f11e71857778bfcd4acbdb86c07db8260caf7d008b08f8/lxml-6.0.2-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:90a345bbeaf9d0587a3aaffb7006aa39ccb6ff0e96a57286c0cb2fd1520ea192", size = 5253958, upload-time = "2025-09-22T04:01:31.535Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/35/35/d955a070994725c4f7d80583a96cab9c107c57a125b20bb5f708fe941011/lxml-6.0.2-cp312-cp312-manylinux_2_31_armv7l.whl", hash = "sha256:064fdadaf7a21af3ed1dcaa106b854077fbeada827c18f72aec9346847cd65d0", size = 4711541, upload-time = "2025-09-22T04:01:33.801Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1e/be/667d17363b38a78c4bd63cfd4b4632029fd68d2c2dc81f25ce9eb5224dd5/lxml-6.0.2-cp312-cp312-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fbc74f42c3525ac4ffa4b89cbdd00057b6196bcefe8bce794abd42d33a018092", size = 5267426, upload-time = "2025-09-22T04:01:35.639Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ea/47/62c70aa4a1c26569bc958c9ca86af2bb4e1f614e8c04fb2989833874f7ae/lxml-6.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6ddff43f702905a4e32bc24f3f2e2edfe0f8fde3277d481bffb709a4cced7a1f", size = 5064917, upload-time = "2025-09-22T04:01:37.448Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bd/55/6ceddaca353ebd0f1908ef712c597f8570cc9c58130dbb89903198e441fd/lxml-6.0.2-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:6da5185951d72e6f5352166e3da7b0dc27aa70bd1090b0eb3f7f7212b53f1bb8", size = 4788795, upload-time = "2025-09-22T04:01:39.165Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cf/e8/fd63e15da5e3fd4c2146f8bbb3c14e94ab850589beab88e547b2dbce22e1/lxml-6.0.2-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:57a86e1ebb4020a38d295c04fc79603c7899e0df71588043eb218722dabc087f", size = 5676759, upload-time = "2025-09-22T04:01:41.506Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/76/47/b3ec58dc5c374697f5ba37412cd2728f427d056315d124dd4b61da381877/lxml-6.0.2-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:2047d8234fe735ab77802ce5f2297e410ff40f5238aec569ad7c8e163d7b19a6", size = 5255666, upload-time = "2025-09-22T04:01:43.363Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/19/93/03ba725df4c3d72afd9596eef4a37a837ce8e4806010569bedfcd2cb68fd/lxml-6.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6f91fd2b2ea15a6800c8e24418c0775a1694eefc011392da73bc6cef2623b322", size = 5277989, upload-time = "2025-09-22T04:01:45.215Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c6/80/c06de80bfce881d0ad738576f243911fccf992687ae09fd80b734712b39c/lxml-6.0.2-cp312-cp312-win32.whl", hash = "sha256:3ae2ce7d6fedfb3414a2b6c5e20b249c4c607f72cb8d2bb7cc9c6ec7c6f4e849", size = 3611456, upload-time = "2025-09-22T04:01:48.243Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f7/d7/0cdfb6c3e30893463fb3d1e52bc5f5f99684a03c29a0b6b605cfae879cd5/lxml-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:72c87e5ee4e58a8354fb9c7c84cbf95a1c8236c127a5d1b7683f04bed8361e1f", size = 4011793, upload-time = "2025-09-22T04:01:50.042Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ea/7b/93c73c67db235931527301ed3785f849c78991e2e34f3fd9a6663ffda4c5/lxml-6.0.2-cp312-cp312-win_arm64.whl", hash = "sha256:61cb10eeb95570153e0c0e554f58df92ecf5109f75eacad4a95baa709e26c3d6", size = 3672836, upload-time = "2025-09-22T04:01:52.145Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/53/fd/4e8f0540608977aea078bf6d79f128e0e2c2bba8af1acf775c30baa70460/lxml-6.0.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:9b33d21594afab46f37ae58dfadd06636f154923c4e8a4d754b0127554eb2e77", size = 8648494, upload-time = "2025-09-22T04:01:54.242Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5d/f4/2a94a3d3dfd6c6b433501b8d470a1960a20ecce93245cf2db1706adf6c19/lxml-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6c8963287d7a4c5c9a432ff487c52e9c5618667179c18a204bdedb27310f022f", size = 4661146, upload-time = "2025-09-22T04:01:56.282Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/25/2e/4efa677fa6b322013035d38016f6ae859d06cac67437ca7dc708a6af7028/lxml-6.0.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1941354d92699fb5ffe6ed7b32f9649e43c2feb4b97205f75866f7d21aa91452", size = 4946932, upload-time = "2025-09-22T04:01:58.989Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ce/0f/526e78a6d38d109fdbaa5049c62e1d32fdd70c75fb61c4eadf3045d3d124/lxml-6.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bb2f6ca0ae2d983ded09357b84af659c954722bbf04dea98030064996d156048", size = 5100060, upload-time = "2025-09-22T04:02:00.812Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/81/76/99de58d81fa702cc0ea7edae4f4640416c2062813a00ff24bd70ac1d9c9b/lxml-6.0.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb2a12d704f180a902d7fa778c6d71f36ceb7b0d317f34cdc76a5d05aa1dd1df", size = 5019000, upload-time = "2025-09-22T04:02:02.671Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b5/35/9e57d25482bc9a9882cb0037fdb9cc18f4b79d85df94fa9d2a89562f1d25/lxml-6.0.2-cp313-cp313-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:6ec0e3f745021bfed19c456647f0298d60a24c9ff86d9d051f52b509663feeb1", size = 5348496, upload-time = "2025-09-22T04:02:04.904Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a6/8e/cb99bd0b83ccc3e8f0f528e9aa1f7a9965dfec08c617070c5db8d63a87ce/lxml-6.0.2-cp313-cp313-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:846ae9a12d54e368933b9759052d6206a9e8b250291109c48e350c1f1f49d916", size = 5643779, upload-time = "2025-09-22T04:02:06.689Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d0/34/9e591954939276bb679b73773836c6684c22e56d05980e31d52a9a8deb18/lxml-6.0.2-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ef9266d2aa545d7374938fb5c484531ef5a2ec7f2d573e62f8ce722c735685fd", size = 5244072, upload-time = "2025-09-22T04:02:08.587Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8d/27/b29ff065f9aaca443ee377aff699714fcbffb371b4fce5ac4ca759e436d5/lxml-6.0.2-cp313-cp313-manylinux_2_31_armv7l.whl", hash = "sha256:4077b7c79f31755df33b795dc12119cb557a0106bfdab0d2c2d97bd3cf3dffa6", size = 4718675, upload-time = "2025-09-22T04:02:10.783Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2b/9f/f756f9c2cd27caa1a6ef8c32ae47aadea697f5c2c6d07b0dae133c244fbe/lxml-6.0.2-cp313-cp313-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:a7c5d5e5f1081955358533be077166ee97ed2571d6a66bdba6ec2f609a715d1a", size = 5255171, upload-time = "2025-09-22T04:02:12.631Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/61/46/bb85ea42d2cb1bd8395484fd72f38e3389611aa496ac7772da9205bbda0e/lxml-6.0.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:8f8d0cbd0674ee89863a523e6994ac25fd5be9c8486acfc3e5ccea679bad2679", size = 5057175, upload-time = "2025-09-22T04:02:14.718Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/95/0c/443fc476dcc8e41577f0af70458c50fe299a97bb6b7505bb1ae09aa7f9ac/lxml-6.0.2-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:2cbcbf6d6e924c28f04a43f3b6f6e272312a090f269eff68a2982e13e5d57659", size = 4785688, upload-time = "2025-09-22T04:02:16.957Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/48/78/6ef0b359d45bb9697bc5a626e1992fa5d27aa3f8004b137b2314793b50a0/lxml-6.0.2-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:dfb874cfa53340009af6bdd7e54ebc0d21012a60a4e65d927c2e477112e63484", size = 5660655, upload-time = "2025-09-22T04:02:18.815Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ff/ea/e1d33808f386bc1339d08c0dcada6e4712d4ed8e93fcad5f057070b7988a/lxml-6.0.2-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:fb8dae0b6b8b7f9e96c26fdd8121522ce5de9bb5538010870bd538683d30e9a2", size = 5247695, upload-time = "2025-09-22T04:02:20.593Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4f/47/eba75dfd8183673725255247a603b4ad606f4ae657b60c6c145b381697da/lxml-6.0.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:358d9adae670b63e95bc59747c72f4dc97c9ec58881d4627fe0120da0f90d314", size = 5269841, upload-time = "2025-09-22T04:02:22.489Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/76/04/5c5e2b8577bc936e219becb2e98cdb1aca14a4921a12995b9d0c523502ae/lxml-6.0.2-cp313-cp313-win32.whl", hash = "sha256:e8cd2415f372e7e5a789d743d133ae474290a90b9023197fd78f32e2dc6873e2", size = 3610700, upload-time = "2025-09-22T04:02:24.465Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fe/0a/4643ccc6bb8b143e9f9640aa54e38255f9d3b45feb2cbe7ae2ca47e8782e/lxml-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:b30d46379644fbfc3ab81f8f82ae4de55179414651f110a1514f0b1f8f6cb2d7", size = 4010347, upload-time = "2025-09-22T04:02:26.286Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/31/ef/dcf1d29c3f530577f61e5fe2f1bd72929acf779953668a8a47a479ae6f26/lxml-6.0.2-cp313-cp313-win_arm64.whl", hash = "sha256:13dcecc9946dca97b11b7c40d29fba63b55ab4170d3c0cf8c0c164343b9bfdcf", size = 3671248, upload-time = "2025-09-22T04:02:27.918Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/03/15/d4a377b385ab693ce97b472fe0c77c2b16ec79590e688b3ccc71fba19884/lxml-6.0.2-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:b0c732aa23de8f8aec23f4b580d1e52905ef468afb4abeafd3fec77042abb6fe", size = 8659801, upload-time = "2025-09-22T04:02:30.113Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c8/e8/c128e37589463668794d503afaeb003987373c5f94d667124ffd8078bbd9/lxml-6.0.2-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:4468e3b83e10e0317a89a33d28f7aeba1caa4d1a6fd457d115dd4ffe90c5931d", size = 4659403, upload-time = "2025-09-22T04:02:32.119Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/00/ce/74903904339decdf7da7847bb5741fc98a5451b42fc419a86c0c13d26fe2/lxml-6.0.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:abd44571493973bad4598a3be7e1d807ed45aa2adaf7ab92ab7c62609569b17d", size = 4966974, upload-time = "2025-09-22T04:02:34.155Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1f/d3/131dec79ce61c5567fecf82515bd9bc36395df42501b50f7f7f3bd065df0/lxml-6.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:370cd78d5855cfbffd57c422851f7d3864e6ae72d0da615fca4dad8c45d375a5", size = 5102953, upload-time = "2025-09-22T04:02:36.054Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3a/ea/a43ba9bb750d4ffdd885f2cd333572f5bb900cd2408b67fdda07e85978a0/lxml-6.0.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:901e3b4219fa04ef766885fb40fa516a71662a4c61b80c94d25336b4934b71c0", size = 5055054, upload-time = "2025-09-22T04:02:38.154Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/60/23/6885b451636ae286c34628f70a7ed1fcc759f8d9ad382d132e1c8d3d9bfd/lxml-6.0.2-cp314-cp314-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:a4bf42d2e4cf52c28cc1812d62426b9503cdb0c87a6de81442626aa7d69707ba", size = 5352421, upload-time = "2025-09-22T04:02:40.413Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/48/5b/fc2ddfc94ddbe3eebb8e9af6e3fd65e2feba4967f6a4e9683875c394c2d8/lxml-6.0.2-cp314-cp314-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b2c7fdaa4d7c3d886a42534adec7cfac73860b89b4e5298752f60aa5984641a0", size = 5673684, upload-time = "2025-09-22T04:02:42.288Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/29/9c/47293c58cc91769130fbf85531280e8cc7868f7fbb6d92f4670071b9cb3e/lxml-6.0.2-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:98a5e1660dc7de2200b00d53fa00bcd3c35a3608c305d45a7bbcaf29fa16e83d", size = 5252463, upload-time = "2025-09-22T04:02:44.165Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9b/da/ba6eceb830c762b48e711ded880d7e3e89fc6c7323e587c36540b6b23c6b/lxml-6.0.2-cp314-cp314-manylinux_2_31_armv7l.whl", hash = "sha256:dc051506c30b609238d79eda75ee9cab3e520570ec8219844a72a46020901e37", size = 4698437, upload-time = "2025-09-22T04:02:46.524Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a5/24/7be3f82cb7990b89118d944b619e53c656c97dc89c28cfb143fdb7cd6f4d/lxml-6.0.2-cp314-cp314-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8799481bbdd212470d17513a54d568f44416db01250f49449647b5ab5b5dccb9", size = 5269890, upload-time = "2025-09-22T04:02:48.812Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1b/bd/dcfb9ea1e16c665efd7538fc5d5c34071276ce9220e234217682e7d2c4a5/lxml-6.0.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:9261bb77c2dab42f3ecd9103951aeca2c40277701eb7e912c545c1b16e0e4917", size = 5097185, upload-time = "2025-09-22T04:02:50.746Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/21/04/a60b0ff9314736316f28316b694bccbbabe100f8483ad83852d77fc7468e/lxml-6.0.2-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:65ac4a01aba353cfa6d5725b95d7aed6356ddc0a3cd734de00124d285b04b64f", size = 4745895, upload-time = "2025-09-22T04:02:52.968Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d6/bd/7d54bd1846e5a310d9c715921c5faa71cf5c0853372adf78aee70c8d7aa2/lxml-6.0.2-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:b22a07cbb82fea98f8a2fd814f3d1811ff9ed76d0fc6abc84eb21527596e7cc8", size = 5695246, upload-time = "2025-09-22T04:02:54.798Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fd/32/5643d6ab947bc371da21323acb2a6e603cedbe71cb4c99c8254289ab6f4e/lxml-6.0.2-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:d759cdd7f3e055d6bc8d9bec3ad905227b2e4c785dc16c372eb5b5e83123f48a", size = 5260797, upload-time = "2025-09-22T04:02:57.058Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/33/da/34c1ec4cff1eea7d0b4cd44af8411806ed943141804ac9c5d565302afb78/lxml-6.0.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:945da35a48d193d27c188037a05fec5492937f66fb1958c24fc761fb9d40d43c", size = 5277404, upload-time = "2025-09-22T04:02:58.966Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/82/57/4eca3e31e54dc89e2c3507e1cd411074a17565fa5ffc437c4ae0a00d439e/lxml-6.0.2-cp314-cp314-win32.whl", hash = "sha256:be3aaa60da67e6153eb15715cc2e19091af5dc75faef8b8a585aea372507384b", size = 3670072, upload-time = "2025-09-22T04:03:38.05Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e3/e0/c96cf13eccd20c9421ba910304dae0f619724dcf1702864fd59dd386404d/lxml-6.0.2-cp314-cp314-win_amd64.whl", hash = "sha256:fa25afbadead523f7001caf0c2382afd272c315a033a7b06336da2637d92d6ed", size = 4080617, upload-time = "2025-09-22T04:03:39.835Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d5/5d/b3f03e22b3d38d6f188ef044900a9b29b2fe0aebb94625ce9fe244011d34/lxml-6.0.2-cp314-cp314-win_arm64.whl", hash = "sha256:063eccf89df5b24e361b123e257e437f9e9878f425ee9aae3144c77faf6da6d8", size = 3754930, upload-time = "2025-09-22T04:03:41.565Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5e/5c/42c2c4c03554580708fc738d13414801f340c04c3eff90d8d2d227145275/lxml-6.0.2-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:6162a86d86893d63084faaf4ff937b3daea233e3682fb4474db07395794fa80d", size = 8910380, upload-time = "2025-09-22T04:03:01.645Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/4f/12df843e3e10d18d468a7557058f8d3733e8b6e12401f30b1ef29360740f/lxml-6.0.2-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:414aaa94e974e23a3e92e7ca5b97d10c0cf37b6481f50911032c69eeb3991bba", size = 4775632, upload-time = "2025-09-22T04:03:03.814Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e4/0c/9dc31e6c2d0d418483cbcb469d1f5a582a1cd00a1f4081953d44051f3c50/lxml-6.0.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:48461bd21625458dd01e14e2c38dd0aea69addc3c4f960c30d9f59d7f93be601", size = 4975171, upload-time = "2025-09-22T04:03:05.651Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e7/2b/9b870c6ca24c841bdd887504808f0417aa9d8d564114689266f19ddf29c8/lxml-6.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:25fcc59afc57d527cfc78a58f40ab4c9b8fd096a9a3f964d2781ffb6eb33f4ed", size = 5110109, upload-time = "2025-09-22T04:03:07.452Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/0c/4f5f2a4dd319a178912751564471355d9019e220c20d7db3fb8307ed8582/lxml-6.0.2-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5179c60288204e6ddde3f774a93350177e08876eaf3ab78aa3a3649d43eb7d37", size = 5041061, upload-time = "2025-09-22T04:03:09.297Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/12/64/554eed290365267671fe001a20d72d14f468ae4e6acef1e179b039436967/lxml-6.0.2-cp314-cp314t-manylinux_2_26_i686.manylinux_2_28_i686.whl", hash = "sha256:967aab75434de148ec80597b75062d8123cadf2943fb4281f385141e18b21338", size = 5306233, upload-time = "2025-09-22T04:03:11.651Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7a/31/1d748aa275e71802ad9722df32a7a35034246b42c0ecdd8235412c3396ef/lxml-6.0.2-cp314-cp314t-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d100fcc8930d697c6561156c6810ab4a508fb264c8b6779e6e61e2ed5e7558f9", size = 5604739, upload-time = "2025-09-22T04:03:13.592Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8f/41/2c11916bcac09ed561adccacceaedd2bf0e0b25b297ea92aab99fd03d0fa/lxml-6.0.2-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ca59e7e13e5981175b8b3e4ab84d7da57993eeff53c07764dcebda0d0e64ecd", size = 5225119, upload-time = "2025-09-22T04:03:15.408Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/99/05/4e5c2873d8f17aa018e6afde417c80cc5d0c33be4854cce3ef5670c49367/lxml-6.0.2-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:957448ac63a42e2e49531b9d6c0fa449a1970dbc32467aaad46f11545be9af1d", size = 4633665, upload-time = "2025-09-22T04:03:17.262Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0f/c9/dcc2da1bebd6275cdc723b515f93edf548b82f36a5458cca3578bc899332/lxml-6.0.2-cp314-cp314t-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b7fc49c37f1786284b12af63152fe1d0990722497e2d5817acfe7a877522f9a9", size = 5234997, upload-time = "2025-09-22T04:03:19.14Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9c/e2/5172e4e7468afca64a37b81dba152fc5d90e30f9c83c7c3213d6a02a5ce4/lxml-6.0.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e19e0643cc936a22e837f79d01a550678da8377d7d801a14487c10c34ee49c7e", size = 5090957, upload-time = "2025-09-22T04:03:21.436Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a5/b3/15461fd3e5cd4ddcb7938b87fc20b14ab113b92312fc97afe65cd7c85de1/lxml-6.0.2-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:1db01e5cf14345628e0cbe71067204db658e2fb8e51e7f33631f5f4735fefd8d", size = 4764372, upload-time = "2025-09-22T04:03:23.27Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/05/33/f310b987c8bf9e61c4dd8e8035c416bd3230098f5e3cfa69fc4232de7059/lxml-6.0.2-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:875c6b5ab39ad5291588aed6925fac99d0097af0dd62f33c7b43736043d4a2ec", size = 5634653, upload-time = "2025-09-22T04:03:25.767Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/70/ff/51c80e75e0bc9382158133bdcf4e339b5886c6ee2418b5199b3f1a61ed6d/lxml-6.0.2-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:cdcbed9ad19da81c480dfd6dd161886db6096083c9938ead313d94b30aadf272", size = 5233795, upload-time = "2025-09-22T04:03:27.62Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/56/4d/4856e897df0d588789dd844dbed9d91782c4ef0b327f96ce53c807e13128/lxml-6.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:80dadc234ebc532e09be1975ff538d154a7fa61ea5031c03d25178855544728f", size = 5257023, upload-time = "2025-09-22T04:03:30.056Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0f/85/86766dfebfa87bea0ab78e9ff7a4b4b45225df4b4d3b8cc3c03c5cd68464/lxml-6.0.2-cp314-cp314t-win32.whl", hash = "sha256:da08e7bb297b04e893d91087df19638dc7a6bb858a954b0cc2b9f5053c922312", size = 3911420, upload-time = "2025-09-22T04:03:32.198Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fe/1a/b248b355834c8e32614650b8008c69ffeb0ceb149c793961dd8c0b991bb3/lxml-6.0.2-cp314-cp314t-win_amd64.whl", hash = "sha256:252a22982dca42f6155125ac76d3432e548a7625d56f5a273ee78a5057216eca", size = 4406837, upload-time = "2025-09-22T04:03:34.027Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/92/aa/df863bcc39c5e0946263454aba394de8a9084dbaff8ad143846b0d844739/lxml-6.0.2-cp314-cp314t-win_arm64.whl", hash = "sha256:bb4c1847b303835d89d785a18801a883436cdfd5dc3d62947f9c49e24f0f5a2c", size = 3822205, upload-time = "2025-09-22T04:03:36.249Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0b/11/29d08bc103a62c0eba8016e7ed5aeebbf1e4312e83b0b1648dd203b0e87d/lxml-6.0.2-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:1c06035eafa8404b5cf475bb37a9f6088b0aca288d4ccc9d69389750d5543700", size = 3949829, upload-time = "2025-09-22T04:04:45.608Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/12/b3/52ab9a3b31e5ab8238da241baa19eec44d2ab426532441ee607165aebb52/lxml-6.0.2-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c7d13103045de1bdd6fe5d61802565f1a3537d70cd3abf596aa0af62761921ee", size = 4226277, upload-time = "2025-09-22T04:04:47.754Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a0/33/1eaf780c1baad88224611df13b1c2a9dfa460b526cacfe769103ff50d845/lxml-6.0.2-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0a3c150a95fbe5ac91de323aa756219ef9cf7fde5a3f00e2281e30f33fa5fa4f", size = 4330433, upload-time = "2025-09-22T04:04:49.907Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7a/c1/27428a2ff348e994ab4f8777d3a0ad510b6b92d37718e5887d2da99952a2/lxml-6.0.2-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:60fa43be34f78bebb27812ed90f1925ec99560b0fa1decdb7d12b84d857d31e9", size = 4272119, upload-time = "2025-09-22T04:04:51.801Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f0/d0/3020fa12bcec4ab62f97aab026d57c2f0cfd480a558758d9ca233bb6a79d/lxml-6.0.2-pp311-pypy311_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:21c73b476d3cfe836be731225ec3421fa2f048d84f6df6a8e70433dff1376d5a", size = 4417314, upload-time = "2025-09-22T04:04:55.024Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6c/77/d7f491cbc05303ac6801651aabeb262d43f319288c1ea96c66b1d2692ff3/lxml-6.0.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:27220da5be049e936c3aca06f174e8827ca6445a4353a1995584311487fc4e3e", size = 3518768, upload-time = "2025-09-22T04:04:57.097Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "packaging"
|
||||||
|
version = "26.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/65/ee/299d360cdc32edc7d2cf530f3accf79c4fca01e96ffc950d8a52213bd8e4/packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4", size = 143416, upload-time = "2026-01-21T20:50:39.064Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b7/b9/c538f279a4e237a006a2c98387d081e9eb060d203d8ed34467cc0f0b9b53/packaging-26.0-py3-none-any.whl", hash = "sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529", size = 74366, upload-time = "2026-01-21T20:50:37.788Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pluggy"
|
||||||
|
version = "1.6.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pydantic"
|
||||||
|
version = "2.12.5"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "annotated-types" },
|
||||||
|
{ name = "pydantic-core" },
|
||||||
|
{ name = "typing-extensions" },
|
||||||
|
{ name = "typing-inspection" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49", size = 821591, upload-time = "2025-11-26T15:11:46.471Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d", size = 463580, upload-time = "2025-11-26T15:11:44.605Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pydantic-core"
|
||||||
|
version = "2.41.5"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "typing-extensions" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e8/72/74a989dd9f2084b3d9530b0915fdda64ac48831c30dbf7c72a41a5232db8/pydantic_core-2.41.5-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:a3a52f6156e73e7ccb0f8cced536adccb7042be67cb45f9562e12b319c119da6", size = 2105873, upload-time = "2025-11-04T13:39:31.373Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/12/44/37e403fd9455708b3b942949e1d7febc02167662bf1a7da5b78ee1ea2842/pydantic_core-2.41.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7f3bf998340c6d4b0c9a2f02d6a400e51f123b59565d74dc60d252ce888c260b", size = 1899826, upload-time = "2025-11-04T13:39:32.897Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/33/7f/1d5cab3ccf44c1935a359d51a8a2a9e1a654b744b5e7f80d41b88d501eec/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:378bec5c66998815d224c9ca994f1e14c0c21cb95d2f52b6021cc0b2a58f2a5a", size = 1917869, upload-time = "2025-11-04T13:39:34.469Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6e/6a/30d94a9674a7fe4f4744052ed6c5e083424510be1e93da5bc47569d11810/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7b576130c69225432866fe2f4a469a85a54ade141d96fd396dffcf607b558f8", size = 2063890, upload-time = "2025-11-04T13:39:36.053Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/50/be/76e5d46203fcb2750e542f32e6c371ffa9b8ad17364cf94bb0818dbfb50c/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6cb58b9c66f7e4179a2d5e0f849c48eff5c1fca560994d6eb6543abf955a149e", size = 2229740, upload-time = "2025-11-04T13:39:37.753Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/ee/fed784df0144793489f87db310a6bbf8118d7b630ed07aa180d6067e653a/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88942d3a3dff3afc8288c21e565e476fc278902ae4d6d134f1eeda118cc830b1", size = 2350021, upload-time = "2025-11-04T13:39:40.94Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c8/be/8fed28dd0a180dca19e72c233cbf58efa36df055e5b9d90d64fd1740b828/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f31d95a179f8d64d90f6831d71fa93290893a33148d890ba15de25642c5d075b", size = 2066378, upload-time = "2025-11-04T13:39:42.523Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b0/3b/698cf8ae1d536a010e05121b4958b1257f0b5522085e335360e53a6b1c8b/pydantic_core-2.41.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c1df3d34aced70add6f867a8cf413e299177e0c22660cc767218373d0779487b", size = 2175761, upload-time = "2025-11-04T13:39:44.553Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b8/ba/15d537423939553116dea94ce02f9c31be0fa9d0b806d427e0308ec17145/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:4009935984bd36bd2c774e13f9a09563ce8de4abaa7226f5108262fa3e637284", size = 2146303, upload-time = "2025-11-04T13:39:46.238Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/58/7f/0de669bf37d206723795f9c90c82966726a2ab06c336deba4735b55af431/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:34a64bc3441dc1213096a20fe27e8e128bd3ff89921706e83c0b1ac971276594", size = 2340355, upload-time = "2025-11-04T13:39:48.002Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e5/de/e7482c435b83d7e3c3ee5ee4451f6e8973cff0eb6007d2872ce6383f6398/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c9e19dd6e28fdcaa5a1de679aec4141f691023916427ef9bae8584f9c2fb3b0e", size = 2319875, upload-time = "2025-11-04T13:39:49.705Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fe/e6/8c9e81bb6dd7560e33b9053351c29f30c8194b72f2d6932888581f503482/pydantic_core-2.41.5-cp311-cp311-win32.whl", hash = "sha256:2c010c6ded393148374c0f6f0bf89d206bf3217f201faa0635dcd56bd1520f6b", size = 1987549, upload-time = "2025-11-04T13:39:51.842Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/11/66/f14d1d978ea94d1bc21fc98fcf570f9542fe55bfcc40269d4e1a21c19bf7/pydantic_core-2.41.5-cp311-cp311-win_amd64.whl", hash = "sha256:76ee27c6e9c7f16f47db7a94157112a2f3a00e958bc626e2f4ee8bec5c328fbe", size = 2011305, upload-time = "2025-11-04T13:39:53.485Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/56/d8/0e271434e8efd03186c5386671328154ee349ff0354d83c74f5caaf096ed/pydantic_core-2.41.5-cp311-cp311-win_arm64.whl", hash = "sha256:4bc36bbc0b7584de96561184ad7f012478987882ebf9f9c389b23f432ea3d90f", size = 1972902, upload-time = "2025-11-04T13:39:56.488Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5f/5d/5f6c63eebb5afee93bcaae4ce9a898f3373ca23df3ccaef086d0233a35a7/pydantic_core-2.41.5-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f41a7489d32336dbf2199c8c0a215390a751c5b014c2c1c5366e817202e9cdf7", size = 2110990, upload-time = "2025-11-04T13:39:58.079Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/aa/32/9c2e8ccb57c01111e0fd091f236c7b371c1bccea0fa85247ac55b1e2b6b6/pydantic_core-2.41.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:070259a8818988b9a84a449a2a7337c7f430a22acc0859c6b110aa7212a6d9c0", size = 1896003, upload-time = "2025-11-04T13:39:59.956Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/68/b8/a01b53cb0e59139fbc9e4fda3e9724ede8de279097179be4ff31f1abb65a/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e96cea19e34778f8d59fe40775a7a574d95816eb150850a85a7a4c8f4b94ac69", size = 1919200, upload-time = "2025-11-04T13:40:02.241Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/38/de/8c36b5198a29bdaade07b5985e80a233a5ac27137846f3bc2d3b40a47360/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed2e99c456e3fadd05c991f8f437ef902e00eedf34320ba2b0842bd1c3ca3a75", size = 2052578, upload-time = "2025-11-04T13:40:04.401Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/00/b5/0e8e4b5b081eac6cb3dbb7e60a65907549a1ce035a724368c330112adfdd/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:65840751b72fbfd82c3c640cff9284545342a4f1eb1586ad0636955b261b0b05", size = 2208504, upload-time = "2025-11-04T13:40:06.072Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/77/56/87a61aad59c7c5b9dc8caad5a41a5545cba3810c3e828708b3d7404f6cef/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e536c98a7626a98feb2d3eaf75944ef6f3dbee447e1f841eae16f2f0a72d8ddc", size = 2335816, upload-time = "2025-11-04T13:40:07.835Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0d/76/941cc9f73529988688a665a5c0ecff1112b3d95ab48f81db5f7606f522d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eceb81a8d74f9267ef4081e246ffd6d129da5d87e37a77c9bde550cb04870c1c", size = 2075366, upload-time = "2025-11-04T13:40:09.804Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/43/ebef01f69baa07a482844faaa0a591bad1ef129253ffd0cdaa9d8a7f72d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d38548150c39b74aeeb0ce8ee1d8e82696f4a4e16ddc6de7b1d8823f7de4b9b5", size = 2171698, upload-time = "2025-11-04T13:40:12.004Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b1/87/41f3202e4193e3bacfc2c065fab7706ebe81af46a83d3e27605029c1f5a6/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c23e27686783f60290e36827f9c626e63154b82b116d7fe9adba1fda36da706c", size = 2132603, upload-time = "2025-11-04T13:40:13.868Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/49/7d/4c00df99cb12070b6bccdef4a195255e6020a550d572768d92cc54dba91a/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:482c982f814460eabe1d3bb0adfdc583387bd4691ef00b90575ca0d2b6fe2294", size = 2329591, upload-time = "2025-11-04T13:40:15.672Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cc/6a/ebf4b1d65d458f3cda6a7335d141305dfa19bdc61140a884d165a8a1bbc7/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bfea2a5f0b4d8d43adf9d7b8bf019fb46fdd10a2e5cde477fbcb9d1fa08c68e1", size = 2319068, upload-time = "2025-11-04T13:40:17.532Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/49/3b/774f2b5cd4192d5ab75870ce4381fd89cf218af999515baf07e7206753f0/pydantic_core-2.41.5-cp312-cp312-win32.whl", hash = "sha256:b74557b16e390ec12dca509bce9264c3bbd128f8a2c376eaa68003d7f327276d", size = 1985908, upload-time = "2025-11-04T13:40:19.309Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/86/45/00173a033c801cacf67c190fef088789394feaf88a98a7035b0e40d53dc9/pydantic_core-2.41.5-cp312-cp312-win_amd64.whl", hash = "sha256:1962293292865bca8e54702b08a4f26da73adc83dd1fcf26fbc875b35d81c815", size = 2020145, upload-time = "2025-11-04T13:40:21.548Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f9/22/91fbc821fa6d261b376a3f73809f907cec5ca6025642c463d3488aad22fb/pydantic_core-2.41.5-cp312-cp312-win_arm64.whl", hash = "sha256:1746d4a3d9a794cacae06a5eaaccb4b8643a131d45fbc9af23e353dc0a5ba5c3", size = 1976179, upload-time = "2025-11-04T13:40:23.393Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/87/06/8806241ff1f70d9939f9af039c6c35f2360cf16e93c2ca76f184e76b1564/pydantic_core-2.41.5-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:941103c9be18ac8daf7b7adca8228f8ed6bb7a1849020f643b3a14d15b1924d9", size = 2120403, upload-time = "2025-11-04T13:40:25.248Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/94/02/abfa0e0bda67faa65fef1c84971c7e45928e108fe24333c81f3bfe35d5f5/pydantic_core-2.41.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:112e305c3314f40c93998e567879e887a3160bb8689ef3d2c04b6cc62c33ac34", size = 1896206, upload-time = "2025-11-04T13:40:27.099Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/15/df/a4c740c0943e93e6500f9eb23f4ca7ec9bf71b19e608ae5b579678c8d02f/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cbaad15cb0c90aa221d43c00e77bb33c93e8d36e0bf74760cd00e732d10a6a0", size = 1919307, upload-time = "2025-11-04T13:40:29.806Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9a/e3/6324802931ae1d123528988e0e86587c2072ac2e5394b4bc2bc34b61ff6e/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:03ca43e12fab6023fc79d28ca6b39b05f794ad08ec2feccc59a339b02f2b3d33", size = 2063258, upload-time = "2025-11-04T13:40:33.544Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c9/d4/2230d7151d4957dd79c3044ea26346c148c98fbf0ee6ebd41056f2d62ab5/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc799088c08fa04e43144b164feb0c13f9a0bc40503f8df3e9fde58a3c0c101e", size = 2214917, upload-time = "2025-11-04T13:40:35.479Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e6/9f/eaac5df17a3672fef0081b6c1bb0b82b33ee89aa5cec0d7b05f52fd4a1fa/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:97aeba56665b4c3235a0e52b2c2f5ae9cd071b8a8310ad27bddb3f7fb30e9aa2", size = 2332186, upload-time = "2025-11-04T13:40:37.436Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cf/4e/35a80cae583a37cf15604b44240e45c05e04e86f9cfd766623149297e971/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:406bf18d345822d6c21366031003612b9c77b3e29ffdb0f612367352aab7d586", size = 2073164, upload-time = "2025-11-04T13:40:40.289Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/e3/f6e262673c6140dd3305d144d032f7bd5f7497d3871c1428521f19f9efa2/pydantic_core-2.41.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b93590ae81f7010dbe380cdeab6f515902ebcbefe0b9327cc4804d74e93ae69d", size = 2179146, upload-time = "2025-11-04T13:40:42.809Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/75/c7/20bd7fc05f0c6ea2056a4565c6f36f8968c0924f19b7d97bbfea55780e73/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:01a3d0ab748ee531f4ea6c3e48ad9dac84ddba4b0d82291f87248f2f9de8d740", size = 2137788, upload-time = "2025-11-04T13:40:44.752Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3a/8d/34318ef985c45196e004bc46c6eab2eda437e744c124ef0dbe1ff2c9d06b/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:6561e94ba9dacc9c61bce40e2d6bdc3bfaa0259d3ff36ace3b1e6901936d2e3e", size = 2340133, upload-time = "2025-11-04T13:40:46.66Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9c/59/013626bf8c78a5a5d9350d12e7697d3d4de951a75565496abd40ccd46bee/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:915c3d10f81bec3a74fbd4faebe8391013ba61e5a1a8d48c4455b923bdda7858", size = 2324852, upload-time = "2025-11-04T13:40:48.575Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1a/d9/c248c103856f807ef70c18a4f986693a46a8ffe1602e5d361485da502d20/pydantic_core-2.41.5-cp313-cp313-win32.whl", hash = "sha256:650ae77860b45cfa6e2cdafc42618ceafab3a2d9a3811fcfbd3bbf8ac3c40d36", size = 1994679, upload-time = "2025-11-04T13:40:50.619Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9e/8b/341991b158ddab181cff136acd2552c9f35bd30380422a639c0671e99a91/pydantic_core-2.41.5-cp313-cp313-win_amd64.whl", hash = "sha256:79ec52ec461e99e13791ec6508c722742ad745571f234ea6255bed38c6480f11", size = 2019766, upload-time = "2025-11-04T13:40:52.631Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/73/7d/f2f9db34af103bea3e09735bb40b021788a5e834c81eedb541991badf8f5/pydantic_core-2.41.5-cp313-cp313-win_arm64.whl", hash = "sha256:3f84d5c1b4ab906093bdc1ff10484838aca54ef08de4afa9de0f5f14d69639cd", size = 1981005, upload-time = "2025-11-04T13:40:54.734Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ea/28/46b7c5c9635ae96ea0fbb779e271a38129df2550f763937659ee6c5dbc65/pydantic_core-2.41.5-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:3f37a19d7ebcdd20b96485056ba9e8b304e27d9904d233d7b1015db320e51f0a", size = 2119622, upload-time = "2025-11-04T13:40:56.68Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/74/1a/145646e5687e8d9a1e8d09acb278c8535ebe9e972e1f162ed338a622f193/pydantic_core-2.41.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1d1d9764366c73f996edd17abb6d9d7649a7eb690006ab6adbda117717099b14", size = 1891725, upload-time = "2025-11-04T13:40:58.807Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/23/04/e89c29e267b8060b40dca97bfc64a19b2a3cf99018167ea1677d96368273/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25e1c2af0fce638d5f1988b686f3b3ea8cd7de5f244ca147c777769e798a9cd1", size = 1915040, upload-time = "2025-11-04T13:41:00.853Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/84/a3/15a82ac7bd97992a82257f777b3583d3e84bdb06ba6858f745daa2ec8a85/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:506d766a8727beef16b7adaeb8ee6217c64fc813646b424d0804d67c16eddb66", size = 2063691, upload-time = "2025-11-04T13:41:03.504Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/74/9b/0046701313c6ef08c0c1cf0e028c67c770a4e1275ca73131563c5f2a310a/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4819fa52133c9aa3c387b3328f25c1facc356491e6135b459f1de698ff64d869", size = 2213897, upload-time = "2025-11-04T13:41:05.804Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/cd/6bac76ecd1b27e75a95ca3a9a559c643b3afcd2dd62086d4b7a32a18b169/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2b761d210c9ea91feda40d25b4efe82a1707da2ef62901466a42492c028553a2", size = 2333302, upload-time = "2025-11-04T13:41:07.809Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4c/d2/ef2074dc020dd6e109611a8be4449b98cd25e1b9b8a303c2f0fca2f2bcf7/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22f0fb8c1c583a3b6f24df2470833b40207e907b90c928cc8d3594b76f874375", size = 2064877, upload-time = "2025-11-04T13:41:09.827Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/18/66/e9db17a9a763d72f03de903883c057b2592c09509ccfe468187f2a2eef29/pydantic_core-2.41.5-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2782c870e99878c634505236d81e5443092fba820f0373997ff75f90f68cd553", size = 2180680, upload-time = "2025-11-04T13:41:12.379Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/9e/3ce66cebb929f3ced22be85d4c2399b8e85b622db77dad36b73c5387f8f8/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:0177272f88ab8312479336e1d777f6b124537d47f2123f89cb37e0accea97f90", size = 2138960, upload-time = "2025-11-04T13:41:14.627Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a6/62/205a998f4327d2079326b01abee48e502ea739d174f0a89295c481a2272e/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:63510af5e38f8955b8ee5687740d6ebf7c2a0886d15a6d65c32814613681bc07", size = 2339102, upload-time = "2025-11-04T13:41:16.868Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3c/0d/f05e79471e889d74d3d88f5bd20d0ed189ad94c2423d81ff8d0000aab4ff/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:e56ba91f47764cc14f1daacd723e3e82d1a89d783f0f5afe9c364b8bb491ccdb", size = 2326039, upload-time = "2025-11-04T13:41:18.934Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ec/e1/e08a6208bb100da7e0c4b288eed624a703f4d129bde2da475721a80cab32/pydantic_core-2.41.5-cp314-cp314-win32.whl", hash = "sha256:aec5cf2fd867b4ff45b9959f8b20ea3993fc93e63c7363fe6851424c8a7e7c23", size = 1995126, upload-time = "2025-11-04T13:41:21.418Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/48/5d/56ba7b24e9557f99c9237e29f5c09913c81eeb2f3217e40e922353668092/pydantic_core-2.41.5-cp314-cp314-win_amd64.whl", hash = "sha256:8e7c86f27c585ef37c35e56a96363ab8de4e549a95512445b85c96d3e2f7c1bf", size = 2015489, upload-time = "2025-11-04T13:41:24.076Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4e/bb/f7a190991ec9e3e0ba22e4993d8755bbc4a32925c0b5b42775c03e8148f9/pydantic_core-2.41.5-cp314-cp314-win_arm64.whl", hash = "sha256:e672ba74fbc2dc8eea59fb6d4aed6845e6905fc2a8afe93175d94a83ba2a01a0", size = 1977288, upload-time = "2025-11-04T13:41:26.33Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/92/ed/77542d0c51538e32e15afe7899d79efce4b81eee631d99850edc2f5e9349/pydantic_core-2.41.5-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:8566def80554c3faa0e65ac30ab0932b9e3a5cd7f8323764303d468e5c37595a", size = 2120255, upload-time = "2025-11-04T13:41:28.569Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bb/3d/6913dde84d5be21e284439676168b28d8bbba5600d838b9dca99de0fad71/pydantic_core-2.41.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b80aa5095cd3109962a298ce14110ae16b8c1aece8b72f9dafe81cf597ad80b3", size = 1863760, upload-time = "2025-11-04T13:41:31.055Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5a/f0/e5e6b99d4191da102f2b0eb9687aaa7f5bea5d9964071a84effc3e40f997/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3006c3dd9ba34b0c094c544c6006cc79e87d8612999f1a5d43b769b89181f23c", size = 1878092, upload-time = "2025-11-04T13:41:33.21Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/71/48/36fb760642d568925953bcc8116455513d6e34c4beaa37544118c36aba6d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:72f6c8b11857a856bcfa48c86f5368439f74453563f951e473514579d44aa612", size = 2053385, upload-time = "2025-11-04T13:41:35.508Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/20/25/92dc684dd8eb75a234bc1c764b4210cf2646479d54b47bf46061657292a8/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cb1b2f9742240e4bb26b652a5aeb840aa4b417c7748b6f8387927bc6e45e40d", size = 2218832, upload-time = "2025-11-04T13:41:37.732Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e2/09/f53e0b05023d3e30357d82eb35835d0f6340ca344720a4599cd663dca599/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd3d54f38609ff308209bd43acea66061494157703364ae40c951f83ba99a1a9", size = 2327585, upload-time = "2025-11-04T13:41:40Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/aa/4e/2ae1aa85d6af35a39b236b1b1641de73f5a6ac4d5a7509f77b814885760c/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ff4321e56e879ee8d2a879501c8e469414d948f4aba74a2d4593184eb326660", size = 2041078, upload-time = "2025-11-04T13:41:42.323Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cd/13/2e215f17f0ef326fc72afe94776edb77525142c693767fc347ed6288728d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d0d2568a8c11bf8225044aa94409e21da0cb09dcdafe9ecd10250b2baad531a9", size = 2173914, upload-time = "2025-11-04T13:41:45.221Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/02/7a/f999a6dcbcd0e5660bc348a3991c8915ce6599f4f2c6ac22f01d7a10816c/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:a39455728aabd58ceabb03c90e12f71fd30fa69615760a075b9fec596456ccc3", size = 2129560, upload-time = "2025-11-04T13:41:47.474Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3a/b1/6c990ac65e3b4c079a4fb9f5b05f5b013afa0f4ed6780a3dd236d2cbdc64/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:239edca560d05757817c13dc17c50766136d21f7cd0fac50295499ae24f90fdf", size = 2329244, upload-time = "2025-11-04T13:41:49.992Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d9/02/3c562f3a51afd4d88fff8dffb1771b30cfdfd79befd9883ee094f5b6c0d8/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:2a5e06546e19f24c6a96a129142a75cee553cc018ffee48a460059b1185f4470", size = 2331955, upload-time = "2025-11-04T13:41:54.079Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5c/96/5fb7d8c3c17bc8c62fdb031c47d77a1af698f1d7a406b0f79aaa1338f9ad/pydantic_core-2.41.5-cp314-cp314t-win32.whl", hash = "sha256:b4ececa40ac28afa90871c2cc2b9ffd2ff0bf749380fbdf57d165fd23da353aa", size = 1988906, upload-time = "2025-11-04T13:41:56.606Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/22/ed/182129d83032702912c2e2d8bbe33c036f342cc735737064668585dac28f/pydantic_core-2.41.5-cp314-cp314t-win_amd64.whl", hash = "sha256:80aa89cad80b32a912a65332f64a4450ed00966111b6615ca6816153d3585a8c", size = 1981607, upload-time = "2025-11-04T13:41:58.889Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/11/72/90fda5ee3b97e51c494938a4a44c3a35a9c96c19bba12372fb9c634d6f57/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:b96d5f26b05d03cc60f11a7761a5ded1741da411e7fe0909e27a5e6a0cb7b034", size = 2115441, upload-time = "2025-11-04T13:42:39.557Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1f/53/8942f884fa33f50794f119012dc6a1a02ac43a56407adaac20463df8e98f/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:634e8609e89ceecea15e2d61bc9ac3718caaaa71963717bf3c8f38bfde64242c", size = 1930291, upload-time = "2025-11-04T13:42:42.169Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/79/c8/ecb9ed9cd942bce09fc888ee960b52654fbdbede4ba6c2d6e0d3b1d8b49c/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:93e8740d7503eb008aa2df04d3b9735f845d43ae845e6dcd2be0b55a2da43cd2", size = 1948632, upload-time = "2025-11-04T13:42:44.564Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2e/1b/687711069de7efa6af934e74f601e2a4307365e8fdc404703afc453eab26/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f15489ba13d61f670dcc96772e733aad1a6f9c429cc27574c6cdaed82d0146ad", size = 2138905, upload-time = "2025-11-04T13:42:47.156Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/09/32/59b0c7e63e277fa7911c2fc70ccfb45ce4b98991e7ef37110663437005af/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:7da7087d756b19037bc2c06edc6c170eeef3c3bafcb8f532ff17d64dc427adfd", size = 2110495, upload-time = "2025-11-04T13:42:49.689Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/aa/81/05e400037eaf55ad400bcd318c05bb345b57e708887f07ddb2d20e3f0e98/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:aabf5777b5c8ca26f7824cb4a120a740c9588ed58df9b2d196ce92fba42ff8dc", size = 1915388, upload-time = "2025-11-04T13:42:52.215Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6e/0d/e3549b2399f71d56476b77dbf3cf8937cec5cd70536bdc0e374a421d0599/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c007fe8a43d43b3969e8469004e9845944f1a80e6acd47c150856bb87f230c56", size = 1942879, upload-time = "2025-11-04T13:42:56.483Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f7/07/34573da085946b6a313d7c42f82f16e8920bfd730665de2d11c0c37a74b5/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76d0819de158cd855d1cbb8fcafdf6f5cf1eb8e470abe056d5d161106e38062b", size = 2139017, upload-time = "2025-11-04T13:42:59.471Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5f/9b/1b3f0e9f9305839d7e84912f9e8bfbd191ed1b1ef48083609f0dabde978c/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b2379fa7ed44ddecb5bfe4e48577d752db9fc10be00a6b7446e9663ba143de26", size = 2101980, upload-time = "2025-11-04T13:43:25.97Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a4/ed/d71fefcb4263df0da6a85b5d8a7508360f2f2e9b3bf5814be9c8bccdccc1/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:266fb4cbf5e3cbd0b53669a6d1b039c45e3ce651fd5442eff4d07c2cc8d66808", size = 1923865, upload-time = "2025-11-04T13:43:28.763Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ce/3a/626b38db460d675f873e4444b4bb030453bbe7b4ba55df821d026a0493c4/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58133647260ea01e4d0500089a8c4f07bd7aa6ce109682b1426394988d8aaacc", size = 2134256, upload-time = "2025-11-04T13:43:31.71Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/83/d9/8412d7f06f616bbc053d30cb4e5f76786af3221462ad5eee1f202021eb4e/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:287dad91cfb551c363dc62899a80e9e14da1f0e2b6ebde82c806612ca2a13ef1", size = 2174762, upload-time = "2025-11-04T13:43:34.744Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/55/4c/162d906b8e3ba3a99354e20faa1b49a85206c47de97a639510a0e673f5da/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:03b77d184b9eb40240ae9fd676ca364ce1085f203e1b1256f8ab9984dca80a84", size = 2143141, upload-time = "2025-11-04T13:43:37.701Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1f/f2/f11dd73284122713f5f89fc940f370d035fa8e1e078d446b3313955157fe/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:a668ce24de96165bb239160b3d854943128f4334822900534f2fe947930e5770", size = 2330317, upload-time = "2025-11-04T13:43:40.406Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/88/9d/b06ca6acfe4abb296110fb1273a4d848a0bfb2ff65f3ee92127b3244e16b/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f14f8f046c14563f8eb3f45f499cc658ab8d10072961e07225e507adb700e93f", size = 2316992, upload-time = "2025-11-04T13:43:43.602Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/36/c7/cfc8e811f061c841d7990b0201912c3556bfeb99cdcb7ed24adc8d6f8704/pydantic_core-2.41.5-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:56121965f7a4dc965bff783d70b907ddf3d57f6eba29b6d2e5dabfaf07799c51", size = 2145302, upload-time = "2025-11-04T13:43:46.64Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pygments"
|
||||||
|
version = "2.19.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pypdf"
|
||||||
|
version = "6.7.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/10/45/8340de1c752bfda2da912ea0fa8c9a432f7de3f6315e82f1c0847811dff6/pypdf-6.7.0.tar.gz", hash = "sha256:eb95e244d9f434e6cfd157272283339ef586e593be64ee699c620f756d5c3f7e", size = 5299947, upload-time = "2026-02-08T14:47:11.897Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ed/f1/c92e75a0eb18bb10845e792054ded113010de958b6d4998e201c029417bb/pypdf-6.7.0-py3-none-any.whl", hash = "sha256:62e85036d50839cbdf45b8067c2c1a1b925517514d7cba4cbe8755a6c2829bc9", size = 330557, upload-time = "2026-02-08T14:47:10.111Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytest"
|
||||||
|
version = "9.0.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||||
|
{ name = "iniconfig" },
|
||||||
|
{ name = "packaging" },
|
||||||
|
{ name = "pluggy" },
|
||||||
|
{ name = "pygments" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d1/db/7ef3487e0fb0049ddb5ce41d3a49c235bf9ad299b6a25d5780a89f19230f/pytest-9.0.2.tar.gz", hash = "sha256:75186651a92bd89611d1d9fc20f0b4345fd827c41ccd5c299a868a05d70edf11", size = 1568901, upload-time = "2025-12-06T21:30:51.014Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3b/ab/b3226f0bd7cdcf710fbede2b3548584366da3b19b5021e74f5bde2a8fa3f/pytest-9.0.2-py3-none-any.whl", hash = "sha256:711ffd45bf766d5264d487b917733b453d917afd2b0ad65223959f59089f875b", size = 374801, upload-time = "2025-12-06T21:30:49.154Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytest-asyncio"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "pytest" },
|
||||||
|
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/90/2c/8af215c0f776415f3590cac4f9086ccefd6fd463befeae41cd4d3f193e5a/pytest_asyncio-1.3.0.tar.gz", hash = "sha256:d7f52f36d231b80ee124cd216ffb19369aa168fc10095013c6b014a34d3ee9e5", size = 50087, upload-time = "2025-11-10T16:07:47.256Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e5/35/f8b19922b6a25bc0880171a2f1a003eaeb93657475193ab516fd87cac9da/pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5", size = 15075, upload-time = "2025-11-10T16:07:45.537Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-multipart"
|
||||||
|
version = "0.0.22"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/94/01/979e98d542a70714b0cb2b6728ed0b7c46792b695e3eaec3e20711271ca3/python_multipart-0.0.22.tar.gz", hash = "sha256:7340bef99a7e0032613f56dc36027b959fd3b30a787ed62d310e951f7c3a3a58", size = 37612, upload-time = "2026-01-25T10:15:56.219Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1b/d0/397f9626e711ff749a95d96b7af99b9c566a9bb5129b8e4c10fc4d100304/python_multipart-0.0.22-py3-none-any.whl", hash = "sha256:2b2cd894c83d21bf49d702499531c7bafd057d730c201782048f7945d82de155", size = 24579, upload-time = "2026-01-25T10:15:54.811Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-stdnum"
|
||||||
|
version = "2.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/15/7f/96c2b9de6024353177dc6139c33730d5ac25877bc33215515d6b95b84555/python_stdnum-2.2.tar.gz", hash = "sha256:e95fcfa858a703d4a40130cb3eaac133c60d8808a7f3c98efeedac968c2479b9", size = 1311813, upload-time = "2026-01-04T19:36:16.753Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2f/61/aa32d9c79f83a2fae033cd6496fb2a24aba918d31c73704271dfcfb48375/python_stdnum-2.2-py3-none-any.whl", hash = "sha256:bdf98fd117a0ca152e4047aa8ad254bae63853d4e915ddd4e0effb33ba0e9260", size = 1193213, upload-time = "2026-01-04T19:36:14.812Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "requests"
|
||||||
|
version = "2.34.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "certifi" },
|
||||||
|
{ name = "charset-normalizer" },
|
||||||
|
{ name = "idna" },
|
||||||
|
{ name = "urllib3" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/ac/c3/e2a2b89f2d3e2179abd6d00ebd70bff6273f37fb3e0cc209f48b39d00cbf/requests-2.34.2.tar.gz", hash = "sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed", size = 142856, upload-time = "2026-05-14T19:25:27.735Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "starlette"
|
||||||
|
version = "0.52.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "anyio" },
|
||||||
|
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/c4/68/79977123bb7be889ad680d79a40f339082c1978b5cfcf62c2d8d196873ac/starlette-0.52.1.tar.gz", hash = "sha256:834edd1b0a23167694292e94f597773bc3f89f362be6effee198165a35d62933", size = 2653702, upload-time = "2026-01-18T13:34:11.062Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/81/0d/13d1d239a25cbfb19e740db83143e95c772a1fe10202dda4b76792b114dd/starlette-0.52.1-py3-none-any.whl", hash = "sha256:0029d43eb3d273bc4f83a08720b4912ea4b071087a3b48db01b7c839f7954d74", size = 74272, upload-time = "2026-01-18T13:34:09.188Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typing-extensions"
|
||||||
|
version = "4.15.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typing-inspection"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "typing-extensions" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urllib3"
|
||||||
|
version = "2.7.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/53/0c/06f8b233b8fd13b9e5ee11424ef85419ba0d8ba0b3138bf360be2ff56953/urllib3-2.7.0.tar.gz", hash = "sha256:231e0ec3b63ceb14667c67be60f2f2c40a518cb38b03af60abc813da26505f4c", size = 433602, upload-time = "2026-05-07T16:13:18.596Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.151Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uvicorn"
|
||||||
|
version = "0.41.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "click" },
|
||||||
|
{ name = "h11" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/32/ce/eeb58ae4ac36fe09e3842eb02e0eb676bf2c53ae062b98f1b2531673efdd/uvicorn-0.41.0.tar.gz", hash = "sha256:09d11cf7008da33113824ee5a1c6422d89fbc2ff476540d69a34c87fab8b571a", size = 82633, upload-time = "2026-02-16T23:07:24.1Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/83/e4/d04a086285c20886c0daad0e026f250869201013d18f81d9ff5eada73a88/uvicorn-0.41.0-py3-none-any.whl", hash = "sha256:29e35b1d2c36a04b9e180d4007ede3bcb32a85fbdfd6c6aeb3f26839de088187", size = 68783, upload-time = "2026-02-16T23:07:22.357Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zugferd-service"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = { editable = "." }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "factur-x" },
|
||||||
|
{ name = "fastapi" },
|
||||||
|
{ name = "lxml" },
|
||||||
|
{ name = "pydantic" },
|
||||||
|
{ name = "pypdf" },
|
||||||
|
{ name = "python-multipart" },
|
||||||
|
{ name = "uvicorn" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
{ name = "httpx" },
|
||||||
|
{ name = "pytest" },
|
||||||
|
{ name = "pytest-asyncio" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
requires-dist = [
|
||||||
|
{ name = "factur-x", specifier = ">=2.5" },
|
||||||
|
{ name = "fastapi", specifier = ">=0.109.0" },
|
||||||
|
{ name = "httpx", marker = "extra == 'dev'", specifier = ">=0.27.0" },
|
||||||
|
{ name = "lxml", specifier = ">=5.0.0" },
|
||||||
|
{ name = "pydantic", specifier = ">=2.5.0" },
|
||||||
|
{ name = "pypdf", specifier = ">=4.0.0" },
|
||||||
|
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=8.0.0" },
|
||||||
|
{ name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.23.0" },
|
||||||
|
{ name = "python-multipart", specifier = ">=0.0.6" },
|
||||||
|
{ name = "uvicorn", specifier = ">=0.27.0" },
|
||||||
|
]
|
||||||
|
provides-extras = ["dev"]
|
||||||
@@ -0,0 +1,367 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"$id": "https://example.com/zugferd-validator-schema.json",
|
||||||
|
"title": "ZUGFeRD Invoice Validator Schema",
|
||||||
|
"description": "JSON schema for /validate endpoint of ZUGFeRD service. Use this to structure OCR-extracted invoice data for validation.\n\n⚠️ CRITICAL INSTRUCTIONS FOR LLM:\n\n1. YOUR ROLE IS EXTRACTOR, NOT CALCULATOR\n2. ONLY extract values that EXPLICITLY appear in the document\n3. DO NOT perform ANY arithmetic calculations\n4. DO NOT infer or fabricate ANY values\n5. If a value is not visible in the document, set it to null (for optional fields) or indicate it's missing\n6. The validation service WILL verify all calculations - your job is only to extract what's written\n\nExample of WRONG behavior: quantity=10, unit_price=100.0 → line_total=1000.0 (CALCULATED - WRONG!)\nExample of CORRECT behavior: line_total=1000.0 appears on invoice → line_total=1000.0 (EXTRACTED - CORRECT!)\n\nIf the document shows:\n- \"10 × 100.00 = 1,000.00\" → Extract: quantity=10.0, unit_price=100.0, line_total=1000.0\n- \"10 × 100.00\" (no total shown) → Extract: quantity=10.0, unit_price=100.0, line_total=null (DO NOT calculate!)\n\nThe validator will check required fields, amount calculations, VAT ID formats, and PDF consistency.",
|
||||||
|
"type": "object",
|
||||||
|
"required": ["xml_data", "checks"],
|
||||||
|
"properties": {
|
||||||
|
"xml_data": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Extract all data EXACTLY as it appears in the invoice document. NEVER calculate, infer, or fabricate ANY value. The validation service will perform all necessary calculations to verify the data. If a value is not visible in the document, do NOT add it.",
|
||||||
|
"required": [
|
||||||
|
"invoice_number",
|
||||||
|
"invoice_date",
|
||||||
|
"supplier",
|
||||||
|
"buyer",
|
||||||
|
"line_items",
|
||||||
|
"totals"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"invoice_number": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Invoice reference number (e.g., RE-2024-001, INV-12345)",
|
||||||
|
"examples": ["RE-2024-001", "INV-12345", "2024/001"]
|
||||||
|
},
|
||||||
|
"invoice_date": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Invoice issue date in ISO 8601 format (YYYY-MM-DD)",
|
||||||
|
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
|
||||||
|
"examples": ["2024-02-01", "2025-01-15"]
|
||||||
|
},
|
||||||
|
"buyer_reference": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Buyer reference (BT-10). On XRechnung invoices this is the Leitweg-ID and mandatory. Optional otherwise."
|
||||||
|
},
|
||||||
|
"due_date": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Payment due date in ISO 8601 format (YYYY-MM-DD). Optional but recommended.",
|
||||||
|
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
|
||||||
|
"examples": ["2024-02-28", "2025-02-15"]
|
||||||
|
},
|
||||||
|
"supplier": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Supplier/seller information (the entity sending the invoice)",
|
||||||
|
"required": ["name"],
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Legal company name of the supplier (required)",
|
||||||
|
"examples": ["Acme Corp GmbH", "Test Supplier AG", "Example Services Ltd."]
|
||||||
|
},
|
||||||
|
"street": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Street address",
|
||||||
|
"examples": ["Main Street 123", "Musterstraße 45"]
|
||||||
|
},
|
||||||
|
"postal_code": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Postal/ZIP code",
|
||||||
|
"examples": ["12345", "D-12345", "10115"]
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "City name",
|
||||||
|
"examples": ["Berlin", "München", "Hamburg"]
|
||||||
|
},
|
||||||
|
"country": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Two-letter ISO country code",
|
||||||
|
"pattern": "^[A-Z]{2}$",
|
||||||
|
"examples": ["DE", "AT", "CH", "FR"]
|
||||||
|
},
|
||||||
|
"vat_id": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "VAT identification number. Format is validated: DE + 9 digits (Germany), ATU + 8 digits (Austria), CHE + 9 digits + MWST/TVA/IVA (Switzerland).",
|
||||||
|
"examples": [
|
||||||
|
"DE123456789",
|
||||||
|
"ATU12345678",
|
||||||
|
"CHE123456789MWST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Email address for billing inquiries",
|
||||||
|
"format": "email",
|
||||||
|
"examples": ["billing@acme-corp.de", "rechnung@example.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"buyer": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Buyer/customer information (the entity receiving the invoice)",
|
||||||
|
"required": ["name"],
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Legal company name of the buyer (required)",
|
||||||
|
"examples": ["Customer GmbH", "Buyer Company AG", "Client Ltd."]
|
||||||
|
},
|
||||||
|
"street": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Street address",
|
||||||
|
"examples": ["Market Square 5", "Kundenweg 10"]
|
||||||
|
},
|
||||||
|
"postal_code": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Postal/ZIP code",
|
||||||
|
"examples": ["54321", "D-54321", "80331"]
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "City name",
|
||||||
|
"examples": ["Hamburg", "Frankfurt", "München"]
|
||||||
|
},
|
||||||
|
"country": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Two-letter ISO country code",
|
||||||
|
"pattern": "^[A-Z]{2}$",
|
||||||
|
"examples": ["DE", "AT", "CH", "NL"]
|
||||||
|
},
|
||||||
|
"vat_id": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "VAT identification number. Same format validation as supplier.",
|
||||||
|
"examples": [
|
||||||
|
"DE987654321",
|
||||||
|
"ATU87654321",
|
||||||
|
"CHE987654321TVA"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"line_items": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "List of line items (products or services billed). Extract each line exactly as it appears on the invoice. The validation service will verify calculations. DO NOT perform any arithmetic yourself.",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["position", "description", "quantity", "unit", "unit_price", "line_total"],
|
||||||
|
"properties": {
|
||||||
|
"position": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Sequential line number (1, 2, 3, ...)",
|
||||||
|
"minimum": 1,
|
||||||
|
"examples": [1, 2, 3]
|
||||||
|
},
|
||||||
|
"article_number": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Supplier's article/SKU number",
|
||||||
|
"examples": ["ART-001", "SKU-12345", "PROD-999"]
|
||||||
|
},
|
||||||
|
"article_number_buyer": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Buyer's internal article number (if different from supplier's)",
|
||||||
|
"examples": ["BUY-001", "MAT-456"]
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Item description (required). Should clearly describe the product or service.",
|
||||||
|
"examples": ["Consulting Services", "Office Chair", "Software License - Annual"]
|
||||||
|
},
|
||||||
|
"quantity": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Quantity ordered/delivered (required, must be > 0)",
|
||||||
|
"minimum": 0.01,
|
||||||
|
"examples": [1.0, 10.0, 2.5]
|
||||||
|
},
|
||||||
|
"unit": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Unit of measurement (required). Use human-readable name, not code.",
|
||||||
|
"examples": ["Stück", "Stunde", "Kilogramm", "Meter", "Set"]
|
||||||
|
},
|
||||||
|
"unit_price": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Price per unit (required, must be > 0)",
|
||||||
|
"minimum": 0.01,
|
||||||
|
"examples": [100.0, 49.99, 12.50]
|
||||||
|
},
|
||||||
|
"line_total": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Do NOT calculate. Extract the line total if it EXPLICITLY appears on the invoice (e.g., \"10 × 100.00 = 1,000.00\" shows 1,000.00). If the document shows quantity and unit_price but NO line total, set this to null. The validation service will verify the calculation. NEVER compute quantity × unit_price yourself.",
|
||||||
|
"minimum": 0.01,
|
||||||
|
"examples": [100.0, 499.90, 31.25]
|
||||||
|
},
|
||||||
|
"vat_rate": {
|
||||||
|
"type": ["number", "null"],
|
||||||
|
"description": "VAT rate percentage for this line (optional). Extract if shown on the line item (e.g., \"19%\" or \"7% USt\").",
|
||||||
|
"examples": [19.0, 7.0, 0.0]
|
||||||
|
},
|
||||||
|
"vat_amount": {
|
||||||
|
"type": ["number", "null"],
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Do NOT calculate. Extract the VAT amount for this line if it EXPLICITLY appears on the invoice. If not shown, set to null. NEVER compute line_total × (vat_rate / 100) yourself.",
|
||||||
|
"minimum": 0,
|
||||||
|
"examples": [19.0, 6.93, 0.0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"totals": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Extract totals from the invoice's totals section (usually at bottom of document). DO NOT calculate from line items. Look for: \"Netto:\", \"Zwischensumme\", \"MwSt\", \"USt\", \"Brutto\", \"Rechnungsbetrag\" labels and extract the values shown. The validation service will verify all calculations match.",
|
||||||
|
"required": ["line_total_sum", "net", "vat_total", "gross"],
|
||||||
|
"properties": {
|
||||||
|
"line_total_sum": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Look for \"Zwischensumme\", \"Summe Positionen\", \"Subtotal\" or similar label. Extract the value shown. DO NOT sum line items yourself.",
|
||||||
|
"examples": [1000.0, 2499.90, 150.0]
|
||||||
|
},
|
||||||
|
"net": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Look for \"Netto\", \"Net amount\", \"Summe netto\" label and extract that value. DO NOT calculate.",
|
||||||
|
"examples": [1000.0, 2499.90, 150.0]
|
||||||
|
},
|
||||||
|
"vat_total": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Look for \"MwSt\", \"USt\", \"VAT total\", \"Steuer\" label and extract that value. DO NOT calculate.",
|
||||||
|
"examples": [190.0, 449.98, 28.5]
|
||||||
|
},
|
||||||
|
"gross": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Look for \"Brutto\", \"Rechnungsbetrag\", \"Total\", \"Gesamtbetrag\" label and extract that value. DO NOT add net + vat_total yourself.",
|
||||||
|
"examples": [1190.0, 2949.88, 178.5]
|
||||||
|
},
|
||||||
|
"vat_breakdown": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "⚠️ EXTRACT ONLY - Look for a VAT breakdown table (e.g., \"19%\" row showing base and amount). Only extract rows that EXPLICITLY appear in the document. If no VAT breakdown table exists, set to empty array []. DO NOT calculate any values yourself.",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["rate", "base", "amount"],
|
||||||
|
"properties": {
|
||||||
|
"rate": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Extract the VAT rate shown (e.g., \"19%\", \"7%\")",
|
||||||
|
"examples": [19.0, 7.0, 0.0]
|
||||||
|
},
|
||||||
|
"base": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Extract the tax base amount shown for this rate",
|
||||||
|
"examples": [1000.0, 499.90, 150.0]
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Extract the VAT amount shown for this rate. DO NOT calculate base × rate / 100.",
|
||||||
|
"examples": [190.0, 34.99, 0.0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"currency": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Three-letter ISO currency code (default: EUR)",
|
||||||
|
"default": "EUR",
|
||||||
|
"pattern": "^[A-Z]{3}$",
|
||||||
|
"examples": ["EUR", "USD", "GBP"]
|
||||||
|
},
|
||||||
|
"payment_terms": {
|
||||||
|
"type": ["object", "null"],
|
||||||
|
"description": "Payment information (optional)",
|
||||||
|
"properties": {
|
||||||
|
"iban": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "International Bank Account Number",
|
||||||
|
"examples": ["DE89370400440532013000", "AT611904300234573201"]
|
||||||
|
},
|
||||||
|
"bic": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Bank Identifier Code / SWIFT",
|
||||||
|
"examples": ["COBADEFFXXX", "BKAUATWW"]
|
||||||
|
},
|
||||||
|
"account_holder": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Name of the account holder",
|
||||||
|
"examples": ["Acme Corp GmbH", "Test Supplier AG"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notes": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Additional notes or comments from the invoice",
|
||||||
|
"examples": ["Payment due within 30 days", "Thank you for your business"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pdf_text": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Raw text extracted from the PDF document. Used for 'pdf_abgleich' validation check to compare XML data with PDF text.",
|
||||||
|
"examples": ["Invoice RE-2024-001\nTotal: 1190.00 EUR\n..."]
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"description": "Invoice profile as returned by /extract in 'zugferd_profil' (e.g. EN16931, XRECHNUNG_3.0). Optional. Enables profile-specific rules: on XRECHNUNG_* profiles the buyer_reference is a required field.",
|
||||||
|
"examples": ["EN16931", "XRECHNUNG_3.0"]
|
||||||
|
},
|
||||||
|
"checks": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "List of validation checks to run. Each check validates different aspects of the invoice data.",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"],
|
||||||
|
"description": "Validation check type. Choose one or more:\n- pflichtfelder: Validates all required fields are present and non-empty (invoice_number, invoice_date, supplier.name, supplier.vat_id, buyer.name, totals fields, line_items)\n- betraege: Validates all monetary calculations are correct (line totals, VAT breakdown, totals)\n- ustid: Validates VAT ID format for DE, AT, CH\n- pdf_abgleich: Checks that invoice number and the net, VAT and gross totals of xml_data appear in the PDF text (requires pdf_text; mismatches are warnings)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"examples": [
|
||||||
|
{
|
||||||
|
"xml_data": {
|
||||||
|
"invoice_number": "RE-2024-001",
|
||||||
|
"invoice_date": "2024-02-01",
|
||||||
|
"due_date": "2024-02-28",
|
||||||
|
"supplier": {
|
||||||
|
"name": "Acme Corp GmbH",
|
||||||
|
"street": "Main Street 123",
|
||||||
|
"postal_code": "12345",
|
||||||
|
"city": "Berlin",
|
||||||
|
"country": "DE",
|
||||||
|
"vat_id": "DE123456789",
|
||||||
|
"email": "billing@acme-corp.de"
|
||||||
|
},
|
||||||
|
"buyer": {
|
||||||
|
"name": "Customer GmbH",
|
||||||
|
"street": "Market Square 5",
|
||||||
|
"postal_code": "54321",
|
||||||
|
"city": "Hamburg",
|
||||||
|
"country": "DE",
|
||||||
|
"vat_id": "DE987654321"
|
||||||
|
},
|
||||||
|
"line_items": [
|
||||||
|
{
|
||||||
|
"position": 1,
|
||||||
|
"article_number": "ART-001",
|
||||||
|
"description": "Consulting Services",
|
||||||
|
"quantity": 10.0,
|
||||||
|
"unit": "Stunde",
|
||||||
|
"unit_price": 100.0,
|
||||||
|
"line_total": 1000.0,
|
||||||
|
"vat_rate": 19.0,
|
||||||
|
"vat_amount": 190.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"totals": {
|
||||||
|
"line_total_sum": 1000.0,
|
||||||
|
"net": 1000.0,
|
||||||
|
"vat_total": 190.0,
|
||||||
|
"gross": 1190.0,
|
||||||
|
"vat_breakdown": [
|
||||||
|
{
|
||||||
|
"rate": 19.0,
|
||||||
|
"base": 1000.0,
|
||||||
|
"amount": 190.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"currency": "EUR",
|
||||||
|
"payment_terms": {
|
||||||
|
"iban": "DE89370400440532013000",
|
||||||
|
"bic": "COBADEFFXXX",
|
||||||
|
"account_holder": "Acme Corp GmbH"
|
||||||
|
},
|
||||||
|
"notes": "Payment due within 30 days"
|
||||||
|
},
|
||||||
|
"pdf_text": "Invoice RE-2024-001\nAcme Corp GmbH\n...\nTotal: 1190.00 EUR",
|
||||||
|
"checks": ["pflichtfelder", "betraege", "ustid", "pdf_abgleich"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user