π‘οΈ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Fix Total Value undercount: warranties with no currency set count as the user's default currency
Omega (QA)3602e07e723d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 708ceb0..b7db39e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,8 @@- _Files: `frontend/js/components/paperless.js`_- **Known default JWT secret removed from the compose files (security):** both shipped docker-compose files defaulted `SECRET_KEY` to a fixed value printed in this public repository, so an install that never set its own key signed its login tokens with a secret anyone could read β enough to forge an admin session. The compose default is now empty, which activates the backend's existing behavior of generating a random key and persisting it to a file; setting `SECRET_KEY` explicitly still takes precedence.- _Files: `docker-compose.yml`, `Docker/docker-compose.yml`, `Docker/.env.example`_+- **Total Value card undercounted warranties with no currency set:** since 1.0.3 the dashboard total has only summed warranties whose stored currency exactly matches the user's default currency (issue #192), which silently dropped every warranty with no currency recorded β older entries and imports without a currency column β so the card could show a single product's price instead of the total. Warranties with no currency set now count as the user's default currency in both the personal and global statistics; warranties priced in a different explicit currency are still excluded, as #192 intended.+ - _Files: `backend/statistics_routes.py`_## 1.0.3 - 2026-10-02diff --git a/backend/statistics_routes.py b/backend/statistics_routes.pyindex af1397f..a3a59c9 100644--- a/backend/statistics_routes.py+++ b/backend/statistics_routes.py@@ -118,9 +118,12 @@ def get_statistics():logger.info(f"Voided warranties: {voided_count}")# Get total purchase value (excluding archived; issue #192:- # only the user's default currency, not a cross-currency sum)+ # only the user's default currency, not a cross-currency sum.+ # Rows with no currency recorded (legacy data, imports without+ # a currency column) count as the user's default currency β+ # the exact-match filter used to drop them silently.)user_currency = get_user_currency_code(cur, user_id)- cur.execute(f"SELECT COALESCE(SUM(w.purchase_price), 0) {from_clause} {where_clause} AND w.archived_at IS NULL AND w.voided_at IS NULL AND w.currency = %s", params + [user_currency])+ cur.execute(f"SELECT COALESCE(SUM(w.purchase_price), 0) {from_clause} {where_clause} AND w.archived_at IS NULL AND w.voided_at IS NULL AND (w.currency = %s OR w.currency IS NULL)", params + [user_currency])total_value = cur.fetchone()[0]logger.info(f"Total purchase value ({user_currency}): {total_value}")@@ -334,9 +337,11 @@ def get_global_statistics():voided_count = cur.fetchone()[0]# Get total purchase value (excluding archived; issue #192:- # only the requesting user's default currency, not a cross-currency sum)+ # only the requesting user's default currency, not a cross-currency sum.+ # Rows with no currency recorded count as that default currency,+ # matching the per-user statistics above.)user_currency = get_user_currency_code(cur, request.user['id'])- cur.execute("SELECT COALESCE(SUM(w.purchase_price), 0) FROM warranties w WHERE w.archived_at IS NULL AND w.voided_at IS NULL AND w.currency = %s", (user_currency,))+ cur.execute("SELECT COALESCE(SUM(w.purchase_price), 0) FROM warranties w WHERE w.archived_at IS NULL AND w.voided_at IS NULL AND (w.currency = %s OR w.currency IS NULL)", (user_currency,))total_value = cur.fetchone()[0]logger.info(f"Global total purchase value ({user_currency}): {total_value}")