Fix TypeError: Decimal + float in cart_total computation
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 49s

ticket_total() returned float while total() returns Decimal, causing
a crash when summing cart totals. Standardise all total functions to
return Decimal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-21 09:36:22 +00:00
parent fd89426ed9
commit 28c10a3411
2 changed files with 8 additions and 5 deletions

3
app.py
View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import path_setup # noqa: F401 # adds shared_lib to sys.path
from decimal import Decimal
from pathlib import Path
from quart import g, abort
@@ -61,7 +62,7 @@ async def cart_context() -> dict:
# Global counts for cart-mini (always global)
cart_qty = sum(ci.quantity for ci in all_cart) if all_cart else 0
ctx["cart_count"] = cart_qty + len(all_cal) + len(all_tickets)
ctx["cart_total"] = (total(all_cart) or 0) + (calendar_total(all_cal) or 0) + (ticket_total(all_tickets) or 0)
ctx["cart_total"] = (total(all_cart) or Decimal(0)) + (calendar_total(all_cal) or Decimal(0)) + (ticket_total(all_tickets) or Decimal(0))
# Page-scoped data when viewing a page cart
page_post = getattr(g, "page_post", None)