Ampel prüft jetzt auch Käuferadresse und Positionsfelder (BR-7/10/22/23/25/27).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
61fc8c45a6
commit
ff88eca741
|
|
@ -252,8 +252,40 @@ def collect_blockers(data, is_xrechnung):
|
|||
_delivery = data.get("delivery_date")
|
||||
if _delivery and parse_to_strict_xml_date(_delivery) == "":
|
||||
blocker.append("Lieferdatum (BT-72) ist unlesbar (erwartet: YYYY-MM-DD). Bitte korrigieren oder leeren.")
|
||||
if not data.get("items"):
|
||||
# BG-7 Kaeuferadresse: ohne Name, Strasse, PLZ und Ort verletzt die Rechnung BR-7/BR-10 und
|
||||
# wird von einem Validator abgewiesen. Fuer BEIDE Formate Pflicht, nicht nur XRechnung.
|
||||
for _feld, _bt, _bezeichnung in (
|
||||
("recipient_name", "BT-44", "Name des Kunden"),
|
||||
("recipient_street", "BT-50", "Straße des Kunden"),
|
||||
("recipient_zip", "BT-53", "Postleitzahl des Kunden"),
|
||||
("recipient_city", "BT-52", "Ort des Kunden"),
|
||||
):
|
||||
if not str(data.get(_feld) or "").strip():
|
||||
blocker.append(f"{_bezeichnung} ({_bt}) fehlt. Die Käuferadresse ist vollständig "
|
||||
"erforderlich, sonst wird die Rechnung beim Empfänger abgewiesen.")
|
||||
|
||||
_items = data.get("items") or []
|
||||
if not _items:
|
||||
blocker.append("Die Rechnung enthält keine Position (mindestens eine ist erforderlich).")
|
||||
for _i, _item in enumerate(_items, start=1):
|
||||
if not str(_item.get("name") or "").strip():
|
||||
blocker.append(f"Position {_i}: Artikelname (BT-153) fehlt.")
|
||||
try:
|
||||
_menge = float(_item.get("quantity") or 0)
|
||||
except (TypeError, ValueError):
|
||||
_menge = 0.0
|
||||
if _menge == 0:
|
||||
blocker.append(f"Position {_i}: Menge (BT-129) ist 0 oder unlesbar.")
|
||||
if not str(_item.get("unit") or "").strip():
|
||||
blocker.append(f"Position {_i}: Einheit (BT-130) fehlt.")
|
||||
try:
|
||||
_preis = float(_item.get("unit_price") or 0)
|
||||
except (TypeError, ValueError):
|
||||
_preis = -1.0
|
||||
# 0,00 ist zulaessig (kostenlose Position), negativ nicht (BR-27).
|
||||
if _preis < 0:
|
||||
blocker.append(f"Position {_i}: Einzelpreis (BT-146) darf nicht negativ sein.")
|
||||
|
||||
_pt = str(data.get("payment_term_days") or "").strip()
|
||||
if _pt == "":
|
||||
blocker.append("Zahlungsziel (BT-9/BT-20) fehlt. Es wird KEIN Standardwert (z.B. 14 Tage) "
|
||||
|
|
|
|||
Loading…
Reference in New Issue