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) <noreply@anthropic.com>
This commit is contained in:
@@ -332,7 +332,7 @@ async def order_detail(order_number: str):
|
|||||||
|
|
||||||
# Enrich with invoice data
|
# Enrich with invoice data
|
||||||
order = detail.get("order", {})
|
order = detail.get("order", {})
|
||||||
if order.get("factura_numar"):
|
if order.get("factura_numar") and order.get("factura_data"):
|
||||||
order["invoice"] = {
|
order["invoice"] = {
|
||||||
"facturat": True,
|
"facturat": True,
|
||||||
"serie_act": order.get("factura_serie"),
|
"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
|
# Enrich orders with invoice data — prefer SQLite cache, fallback to Oracle
|
||||||
all_orders = result["orders"]
|
all_orders = result["orders"]
|
||||||
for o in all_orders:
|
for o in all_orders:
|
||||||
if o.get("factura_numar"):
|
if o.get("factura_numar") and o.get("factura_data"):
|
||||||
# Use cached invoice data from SQLite
|
# Use cached invoice data from SQLite (only if complete)
|
||||||
o["invoice"] = {
|
o["invoice"] = {
|
||||||
"facturat": True,
|
"facturat": True,
|
||||||
"serie_act": o.get("factura_serie"),
|
"serie_act": o.get("factura_serie"),
|
||||||
|
|||||||
Reference in New Issue
Block a user