From 723b4f8d31a0b8e979aafcaa1222a9fabf59b077 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 31 May 2026 05:23:23 +0000 Subject: [PATCH] Fix NameError in /cashier/stats crashing every request start_utc and end_utc were referenced in the return dict but never unpacked from bounds. Unpack them after _period_bounds() and guard the period_from/period_to fields against the None (all-time) case. https://claude.ai/code/session_01JuRTR5Xjx8emQsyerBgGU7 --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6ba729d..2106b39 100644 --- a/main.py +++ b/main.py @@ -803,6 +803,7 @@ def cashier_stats(period: str = "today", return f"{sym}{v / div:.2f}" bounds = _period_bounds(period, s, from_date, to_date) + start_utc, end_utc = bounds if bounds else (None, None) with db_conn() as conn: credit = conn.execute( @@ -841,8 +842,8 @@ def cashier_stats(period: str = "today", "withdrawals": stat("withdrawal"), "charges": stat("charge"), "net": {"total": net, "display": fmt(abs(net)), "negative": net < 0}, - "period_from": start_utc[:10], - "period_to": end_utc[:10], + "period_from": start_utc[:10] if start_utc else None, + "period_to": end_utc[:10] if end_utc else None, } @app.get("/members/{member_id}/transactions")