diff --git a/app/sales_routes.py b/app/sales_routes.py index e898702..64004e2 100644 --- a/app/sales_routes.py +++ b/app/sales_routes.py @@ -151,12 +151,6 @@ async def _load_sale(db, sale_id): return s, items, cust -@router.get("/{sale_id}") -async def sale_detail(sale_id: int, ident=Depends(require_token), db=Depends(get_db)): - s, items, cust = await _load_sale(db, sale_id) - return {"sale": s, "items": items, "customer": cust} - - @router.get("/{sale_id}/receipt") async def sale_receipt(sale_id: int, ident=Depends(require_token), db=Depends(get_db)): """Rendered receipt HTML (for the print window) + the customer's email if on file.""" @@ -335,3 +329,11 @@ async def past_sales(q: str = Query(""), ident=Depends(require_token), db=Depend {where} ORDER BY s.sale_date DESC NULLS LAST LIMIT 100 """), params) return {"sales": [dict(r) for r in rows.mappings()]} + + +# Parametric catch-all LAST so it doesn't swallow /settings, /customers, /past, /discounts +# (FastAPI matches by registration order; "/{sale_id}" regex matches any single segment). +@router.get("/{sale_id}") +async def sale_detail(sale_id: int, ident=Depends(require_token), db=Depends(get_db)): + s, items, cust = await _load_sale(db, sale_id) + return {"sale": s, "items": items, "customer": cust}