Allow zero-euro line item amounts

This commit is contained in:
2026-06-03 07:52:52 +02:00
parent d497a4cb5b
commit e2e1d8c046
5 changed files with 71 additions and 36 deletions
+4 -4
View File
@@ -8,7 +8,7 @@ import io
import time
from facturx import get_flavor, get_level, get_xml_from_pdf
from lxml import etree
import lxml.etree as etree
from pypdf import PdfReader
from pypdf.errors import PdfReadError, PyPdfError
@@ -63,7 +63,7 @@ def extract_text_from_pdf(pdf_bytes: bytes) -> str:
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:
@@ -235,8 +235,8 @@ def parse_line_items(xml_root: etree._Element) -> list[LineItem]:
description=description[0] if description else "",
quantity=float(quantity[0]) if quantity else 0.0,
unit=unit,
unit_price=float(unit_price[0]) if unit_price else 0.0,
line_total=float(line_total[0]) if line_total else 0.0,
unit_price=float(unit_price[0]) if unit_price else None,
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,
)