mirror of
https://github.com/kbenestad/ClubLedger.git
synced 2026-06-18 09:44:33 +00:00
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
This commit is contained in:
parent
fef6f0eb03
commit
723b4f8d31
1 changed files with 3 additions and 2 deletions
5
main.py
5
main.py
|
|
@ -803,6 +803,7 @@ def cashier_stats(period: str = "today",
|
||||||
return f"{sym}{v / div:.2f}"
|
return f"{sym}{v / div:.2f}"
|
||||||
|
|
||||||
bounds = _period_bounds(period, s, from_date, to_date)
|
bounds = _period_bounds(period, s, from_date, to_date)
|
||||||
|
start_utc, end_utc = bounds if bounds else (None, None)
|
||||||
|
|
||||||
with db_conn() as conn:
|
with db_conn() as conn:
|
||||||
credit = conn.execute(
|
credit = conn.execute(
|
||||||
|
|
@ -841,8 +842,8 @@ def cashier_stats(period: str = "today",
|
||||||
"withdrawals": stat("withdrawal"),
|
"withdrawals": stat("withdrawal"),
|
||||||
"charges": stat("charge"),
|
"charges": stat("charge"),
|
||||||
"net": {"total": net, "display": fmt(abs(net)), "negative": net < 0},
|
"net": {"total": net, "display": fmt(abs(net)), "negative": net < 0},
|
||||||
"period_from": start_utc[:10],
|
"period_from": start_utc[:10] if start_utc else None,
|
||||||
"period_to": end_utc[:10],
|
"period_to": end_utc[:10] if end_utc else None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.get("/members/{member_id}/transactions")
|
@app.get("/members/{member_id}/transactions")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue