fix(validator): accept zero quantity on text-only line items

A line with quantity 0 was always reported as a missing required field.
Real invoices carry text-only positions (e.g. a delivery note reference)
with quantity 0 and line total 0. Quantity 0 is now an error only when
the line bills an amount.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 18:32:20 +01:00
co-authored by Claude Fable 5.2
parent fead1534c7
commit 6126a19bb7
2 changed files with 63 additions and 1 deletions
+4 -1
View File
@@ -88,7 +88,10 @@ def validate_pflichtfelder(xml_data: XmlData) -> list[ErrorDetail]:
if not item.description or not item.description.strip():
add_error(f"{field_prefix}.description", "critical")
if item.quantity == 0:
# 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: