From 8827782acae375d071d8b8cff8ed4944bee5b105 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 16 Mar 2026 17:40:30 +0000 Subject: [PATCH] fix(invoice): require factura_data in cache to avoid missing invoice date Orders cached before the factura_data column was populated show "-" for invoice date. Now both detail and dashboard endpoints require factura_data to be present before using SQLite cache, falling through to Oracle live query which fetches and caches the date. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/app/routers/sync.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/app/routers/sync.py b/api/app/routers/sync.py index ed8e7ba..d416589 100644 --- a/api/app/routers/sync.py +++ b/api/app/routers/sync.py @@ -332,7 +332,7 @@ async def order_detail(order_number: str): # Enrich with invoice data order = detail.get("order", {}) - if order.get("factura_numar"): + if order.get("factura_numar") and order.get("factura_data"): order["invoice"] = { "facturat": True, "serie_act": order.get("factura_serie"), @@ -396,8 +396,8 @@ async def dashboard_orders(page: int = 1, per_page: int = 50, # Enrich orders with invoice data — prefer SQLite cache, fallback to Oracle all_orders = result["orders"] for o in all_orders: - if o.get("factura_numar"): - # Use cached invoice data from SQLite + if o.get("factura_numar") and o.get("factura_data"): + # Use cached invoice data from SQLite (only if complete) o["invoice"] = { "facturat": True, "serie_act": o.get("factura_serie"),