chore(release): bump version to 2.3.29
This commit is contained in:
parent
2b4dd6b010
commit
b91f9fcc2d
@ -215,10 +215,10 @@ class EconomicImportService:
|
|||||||
self._safe_str(product.get("productNumber"), 100),
|
self._safe_str(product.get("productNumber"), 100),
|
||||||
self._safe_str(product.get("name"), 500),
|
self._safe_str(product.get("name"), 500),
|
||||||
line.get("description"),
|
line.get("description"),
|
||||||
self._parse_amount(line.get("quantity")),
|
self._parse_amount(line.get("quantity"), default=0.0),
|
||||||
self._parse_amount(line.get("unitNetPrice")),
|
self._parse_amount(line.get("unitNetPrice"), default=0.0),
|
||||||
self._parse_amount(line.get("totalNetAmount")),
|
self._parse_amount(line.get("totalNetAmount"), default=0.0),
|
||||||
self._parse_amount(line.get("discountPercentage")),
|
self._parse_amount(line.get("discountPercentage"), default=0.0),
|
||||||
json.dumps(line, ensure_ascii=False, default=str),
|
json.dumps(line, ensure_ascii=False, default=str),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -274,13 +274,13 @@ class EconomicImportService:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_amount(value: Any) -> Optional[float]:
|
def _parse_amount(value: Any, default: Optional[float] = None) -> Optional[float]:
|
||||||
if value is None or value == "":
|
if value is None or value == "":
|
||||||
return None
|
return default
|
||||||
try:
|
try:
|
||||||
return float(value)
|
return float(value)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return None
|
return default
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _safe_str(value: Any, max_length: int) -> Optional[str]:
|
def _safe_str(value: Any, max_length: int) -> Optional[str]:
|
||||||
|
|||||||
@ -74,6 +74,43 @@ def test_economic_import_service_persists_valid_json(monkeypatch):
|
|||||||
assert json.loads(captured["invoice_raw"])["bookedInvoiceNumber"] == 123
|
assert json.loads(captured["invoice_raw"])["bookedInvoiceNumber"] == 123
|
||||||
|
|
||||||
|
|
||||||
|
def test_economic_import_service_defaults_missing_line_amounts(monkeypatch):
|
||||||
|
from app.modules.invoice_error_finder.services.economic_import_service import EconomicImportService
|
||||||
|
|
||||||
|
captured = []
|
||||||
|
|
||||||
|
def fake_execute_query(query, params=None):
|
||||||
|
if "INSERT INTO invoice_error_finder_economic_invoice_lines" in query:
|
||||||
|
captured.append(params)
|
||||||
|
return []
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"app.modules.invoice_error_finder.services.economic_import_service.execute_query",
|
||||||
|
fake_execute_query,
|
||||||
|
)
|
||||||
|
|
||||||
|
service = EconomicImportService()
|
||||||
|
service._persist_lines(
|
||||||
|
99,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"lineNumber": 1,
|
||||||
|
"description": "Mobilnummer",
|
||||||
|
"quantity": None,
|
||||||
|
"unitNetPrice": None,
|
||||||
|
"totalNetAmount": None,
|
||||||
|
"discountPercentage": None,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert len(captured) == 1
|
||||||
|
assert captured[0][5] == 0.0
|
||||||
|
assert captured[0][6] == 0.0
|
||||||
|
assert captured[0][7] == 0.0
|
||||||
|
assert captured[0][8] == 0.0
|
||||||
|
|
||||||
|
|
||||||
def test_detection_service_keeps_customers_without_subscriptions(monkeypatch):
|
def test_detection_service_keeps_customers_without_subscriptions(monkeypatch):
|
||||||
from app.modules.invoice_error_finder.services.detection_service import DetectionService
|
from app.modules.invoice_error_finder.services.detection_service import DetectionService
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user