fix: extract tax number, price basis quantity, spaced VAT IDs and contact email

- supplier/buyer: extract FC tax registration (BT-32/BT-49) into new
  tax_number field; previously only VA (USt-IdNr.) was read
- pflichtfelder: critical error only when neither vat_id nor tax_number
  is present (EN 16931 BR-CO-26)
- ustid: tolerate formatting whitespace inside VAT IDs (e.g. 'DE 140 978 617')
- line items: normalize unit price by basis quantity (BT-149), so a
  price per 100 units no longer inflates line totals by factor 100
- supplier email: also look in DefinedTradeContact (BT-42)
- rewrite xrechnung fallback test to assert only our own behavior,
  independent of factur-x version specifics
This commit is contained in:
m3ta-chiron
2026-09-11 16:05:41 +02:00
parent e2e1d8c046
commit 7fcb3ff21d
7 changed files with 294 additions and 21 deletions
+3 -2
View File
@@ -109,6 +109,7 @@ Extract ZUGFeRD data from a base64-encoded PDF file.
"city": "Berlin",
"country": "DE",
"vat_id": "DE123456789",
"tax_number": null,
"email": "billing@acme-corp.de"
},
"buyer": {
@@ -276,7 +277,7 @@ The service supports four validation checks:
Validates that all critical invoice fields are present and non-empty:
- **Critical errors:** invoice_number, invoice_date, supplier.name, supplier.vat_id, buyer.name, totals.net, totals.gross, totals.vat_total, line_items array, line item fields
- **Critical errors:** invoice_number, invoice_date, supplier.name, supplier.vat_id (or supplier.tax_number), buyer.name, totals.net, totals.gross, totals.vat_total, line_items array, line item fields
- **Warnings:** due_date, payment_terms.iban
### 2. betraege (Amount Calculations)
@@ -470,7 +471,7 @@ PORT=8000 python -m src.main
Check that all required fields are present:
- invoice_number
- invoice_date (YYYY-MM-DD format)
- supplier.name and supplier.vat_id
- 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, quantity, and unit_price