feat(safety): invoice reconciliation on order detail

Add invoice total comparison in the order detail modal. When an order
has been invoiced, shows whether the invoice total matches the order
total — green badge if OK, red badge with difference amount if not.

Backend: compute reconciliation (difference, match) from existing
invoice.total_cu_tva vs order_total in order_detail endpoint.

Frontend: reconciliation badge below invoice info in modal, hidden
when no invoice exists.

Cache-bust: shared.js?v=17

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-27 12:30:21 +00:00
parent a10a00aa4d
commit 1b2b1d8b24
3 changed files with 33 additions and 1 deletions

View File

@@ -456,6 +456,19 @@ async def order_detail(order_number: str):
except Exception:
pass
# Invoice reconciliation
inv = order.get("invoice")
if inv and inv.get("facturat") and inv.get("total_cu_tva") is not None:
order_total = float(order.get("order_total") or 0)
inv_total = float(inv["total_cu_tva"])
difference = round(inv_total - order_total, 2)
inv["reconciliation"] = {
"order_total": order_total,
"invoice_total": inv_total,
"difference": difference,
"match": abs(difference) < 0.01,
}
# Parse discount_split JSON string
if order.get("discount_split"):
try: