fix(validator): accept genuine zero totals in the required-field check
CI / test (push) Canceled after 0s
CI / docker (push) Canceled after 0s

pflichtfelder rejected every invoice whose net, VAT or gross total was 0.
The extractor reads an absent total as 0, so this could not tell a missing
value from a real zero and rejected tax-exempt / reverse-charge invoices
(VAT 0, e.g. customs agent invoices) and zero-sum invoices.

A zero total now counts as missing only when the rest of the invoice
implies another value: net vs. the line items, VAT total vs. the VAT
breakdown, gross vs. net plus VAT.

Closes zugferd-esf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 07:29:29 +01:00
co-authored by Claude Opus 5.5
parent 56f1527f1f
commit aa416d32b7
3 changed files with 100 additions and 9 deletions
+4 -2
View File
@@ -316,12 +316,14 @@ 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 (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 errors:** invoice_number, invoice_date, supplier.name, supplier.vat_id (or supplier.tax_number), buyer.name, totals.net, totals.gross, totals.vat_total (a total of 0 counts as missing only when the invoice implies another value, see below), 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.
The extractor reads an absent total as 0, so a total of 0 is only reported as missing when the rest of the invoice contradicts it: `totals.net` when the line items do not sum to 0, `totals.vat_total` when the VAT breakdown does not sum to 0, `totals.gross` when net plus VAT is not 0. Tax-exempt and reverse-charge invoices (VAT 0) and zero-sum invoices therefore pass.
### 2. betraege (Amount Calculations)
Verifies all monetary calculations are correct:
@@ -531,7 +533,7 @@ Check that all required fields are present:
- 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)
- Totals (net, gross, vat_total) that are 0 although line items, VAT breakdown or net plus VAT imply another value
- 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**