🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Add Total Value dashboard card (issue #192)
Omega (QA)a00193485b93
diff --git a/backend/statistics_routes.py b/backend/statistics_routes.pyindex 7eac26b..38a2591 100644--- a/backend/statistics_routes.py+++ b/backend/statistics_routes.py@@ -89,6 +89,11 @@ def get_statistics():cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} AND w.archived_at IS NOT NULL", params)archived_count = cur.fetchone()[0]logger.info(f"Archived warranties: {archived_count}")++ # Get total purchase value (excluding archived; issue #192)+ cur.execute(f"SELECT COALESCE(SUM(w.purchase_price), 0) {from_clause} {where_clause} AND w.archived_at IS NULL", params)+ total_value = cur.fetchone()[0]+ logger.info(f"Total purchase value: {total_value}")# Get active count (includes lifetime, excludes archived)cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'} (w.is_lifetime = TRUE OR w.expiration_date >= %s) AND w.archived_at IS NULL", params + [today])@@ -206,6 +211,7 @@ def get_statistics():'expired': expired_count,'expiring_soon': expiring_soon_count,'archived': archived_count,+ 'total_value': total_value,'timeline': timeline,'recent_warranties': recent_warranties,'all_warranties': all_warranties_list # <-- Add the new list here@@ -278,6 +284,10 @@ def get_global_statistics():# Get archived countcur.execute("SELECT COUNT(*) FROM warranties w WHERE w.archived_at IS NOT NULL")archived_count = cur.fetchone()[0]++ # Get total purchase value (excluding archived; issue #192)+ cur.execute("SELECT COALESCE(SUM(w.purchase_price), 0) FROM warranties w WHERE w.archived_at IS NULL")+ total_value = cur.fetchone()[0]# Get active count (includes lifetime, excludes archived)cur.execute("SELECT COUNT(*) FROM warranties w WHERE (w.is_lifetime = TRUE OR w.expiration_date >= %s) AND w.archived_at IS NULL", (today,))@@ -422,6 +432,7 @@ def get_global_statistics():'expired': expired_count,'expiring_soon': expiring_soon_count,'archived': archived_count,+ 'total_value': total_value,'timeline': timeline,'recent_warranties': recent_warranties,'all_warranties': all_warranties_listdiff --git a/frontend/status.html b/frontend/status.htmlindex 1dd5bee..f716952 100644--- a/frontend/status.html+++ b/frontend/status.html@@ -451,6 +451,16 @@<p class="count" id="archivedCount">0</p></div></div>++ <div class="status-card" data-status="total_value">+ <div class="card-icon">+ <i class="fas fa-dollar-sign"></i>+ </div>+ <div class="card-content">+ <h3 data-i18n="status.total_value">Total Value</h3>+ <p class="count" id="totalValueCount">-</p>+ </div>+ </div></div><!-- Charts Section -->diff --git a/frontend/status.js b/frontend/status.jsindex d07aee2..46b76a5 100644--- a/frontend/status.js+++ b/frontend/status.js@@ -419,11 +419,16 @@const expiringEl = document.getElementById('expiringCount');const expiredEl = document.getElementById('expiredCount');const archivedEl = document.getElementById('archivedCount');+ const totalValueEl = document.getElementById('totalValueCount');if (totalEl) totalEl.textContent = statusData.total || 0;if (activeEl) activeEl.textContent = statusData.active || 0;if (expiringEl) expiringEl.textContent = statusData.expiring_soon || 0;if (expiredEl) expiredEl.textContent = statusData.expired || 0;if (archivedEl) archivedEl.textContent = statusData.archived || 0;+ if (totalValueEl) {+ const val = parseFloat(statusData.total_value || 0);+ totalValueEl.textContent = userCurrencySymbol + val.toFixed(2);+ }}function createStatusChart(stats) {@@ -929,7 +934,8 @@expiring_soon: data.expiring_soon || 0,expired: data.expired || 0,total: data.total || 0,- archived: data.archived || 0+ archived: data.archived || 0,+ total_value: data.total_value || 0};if (Object.keys(statusDistributionData).length > 0 && statusDistributionData.total > 0) {diff --git a/locales/ar/translation.json b/locales/ar/translation.jsonindex 6940c4c..1ff52da 100644--- a/locales/ar/translation.json+++ b/locales/ar/translation.json@@ -691,7 +691,8 @@"connected": "متصل","version": "الإصدار","uptime": "وقت التشغيل",- "archived_warranties": "الضمانات المؤرشفة"+ "archived_warranties": "الضمانات المؤرشفة",+ "total_value": "القيمة الإجمالية"},"about": {"title": "حول Warracker",@@ -806,4 +807,4 @@"pick_color": "اختر اللون","create_with_name": "إنشاء \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/cs/translation.json b/locales/cs/translation.jsonindex 4b63c87..fa2ee72 100644--- a/locales/cs/translation.json+++ b/locales/cs/translation.json@@ -688,7 +688,8 @@"connected": "Připojeno","version": "Verze","uptime": "Doba provozu",- "archived_warranties": "Archivované záruky"+ "archived_warranties": "Archivované záruky",+ "total_value": "Celková hodnota"},"about": {"title": "O aplikaci Warracker",@@ -803,4 +804,4 @@"no_selected": "Nejsou vybrány žádné štítky","pick_color": "Vyberte barvu"}-}+}\ No newline at end of filediff --git a/locales/de/translation.json b/locales/de/translation.jsonindex 066c2e0..13cba1c 100644--- a/locales/de/translation.json+++ b/locales/de/translation.json@@ -681,7 +681,8 @@"connected": "Verbunden","version": "Version","uptime": "Betriebszeit",- "archived_warranties": "Archivierte Garantien"+ "archived_warranties": "Archivierte Garantien",+ "total_value": "Gesamtwert"},"about": {"title": "Über Warracker",@@ -796,4 +797,4 @@"no_selected": "Keine Tags ausgewählt","pick_color": "Farbe auswählen"}-}+}\ No newline at end of filediff --git a/locales/en/translation.json b/locales/en/translation.jsonindex b9aac34..dcefde7 100644--- a/locales/en/translation.json+++ b/locales/en/translation.json@@ -681,7 +681,8 @@"database_status": "Database Status","connected": "Connected","version": "Version",- "uptime": "Uptime"+ "uptime": "Uptime",+ "total_value": "Total Value"},"about": {"title": "About - Warracker",@@ -796,4 +797,4 @@"pick_color": "Pick color","create_with_name": "Create \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/es/translation.json b/locales/es/translation.jsonindex a5adec7..bd471dd 100644--- a/locales/es/translation.json+++ b/locales/es/translation.json@@ -681,7 +681,8 @@"connected": "Conectado","version": "Versión","uptime": "Tiempo de Actividad",- "archived_warranties": "Garantías archivadas"+ "archived_warranties": "Garantías archivadas",+ "total_value": "Valor total"},"about": {"title": "Acerca de Warracker",@@ -796,4 +797,4 @@"pick_color": "Elige color","create_with_name": "Crear \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/fa/translation.json b/locales/fa/translation.jsonindex ab0e3b7..c79616a 100644--- a/locales/fa/translation.json+++ b/locales/fa/translation.json@@ -681,7 +681,8 @@"connected": "متصل","version": "نسخه","uptime": "مدت فعالیت",- "archived_warranties": "گارانتی های آرشیو شده"+ "archived_warranties": "گارانتی های آرشیو شده",+ "total_value": "ارزش کل"},"about": {"title": "درباره Warracker",@@ -796,4 +797,4 @@"no_selected": "هیچ برچسبی انتخاب نشده است","pick_color": "رنگ را انتخاب کنید"}-}+}\ No newline at end of filediff --git a/locales/fr/translation.json b/locales/fr/translation.jsonindex 2d32bd3..e89589e 100644--- a/locales/fr/translation.json+++ b/locales/fr/translation.json@@ -681,7 +681,8 @@"connected": "Connecté","version": "Version","uptime": "Temps de Fonctionnement",- "archived_warranties": "Garanties archivées"+ "archived_warranties": "Garanties archivées",+ "total_value": "Valeur totale"},"about": {"title": "À Propos de Warracker",@@ -796,4 +797,4 @@"no_selected": "Aucune balise sélectionnée","pick_color": "Choisissez la couleur"}-}+}\ No newline at end of filediff --git a/locales/he/translation.json b/locales/he/translation.jsonindex 066da08..88d3365 100644--- a/locales/he/translation.json+++ b/locales/he/translation.json@@ -691,7 +691,8 @@"connected": "מחובר","version": "גרסה","uptime": "זמן פעולה",- "archived_warranties": "אחריות בארכיון"+ "archived_warranties": "אחריות בארכיון",+ "total_value": "ערך כולל"},"about": {"title": "אודות Warracker",@@ -806,4 +807,4 @@"no_selected": "לא נבחרו תגים","pick_color": "בחר צבע"}-}+}\ No newline at end of filediff --git a/locales/hi/translation.json b/locales/hi/translation.jsonindex 686bfb9..b45ea72 100644--- a/locales/hi/translation.json+++ b/locales/hi/translation.json@@ -681,7 +681,8 @@"connected": "जुड़ा हुआ","version": "संस्करण","uptime": "अपटाइम",- "archived_warranties": "संग्रहीत वारंटी"+ "archived_warranties": "संग्रहीत वारंटी",+ "total_value": "कुल मूल्य"},"about": {"title": "Warracker के बारे में",@@ -796,4 +797,4 @@"pick_color": "रंग चुनें","create_with_name": "\"{{name}}\" बनाएं"}-}+}\ No newline at end of filediff --git a/locales/it/translation.json b/locales/it/translation.jsonindex c4b0e37..e63173e 100644--- a/locales/it/translation.json+++ b/locales/it/translation.json@@ -93,7 +93,8 @@"connected": "Connesso","version": "Versione","uptime": "Tempo di Attività",- "archived_warranties": "Garanzie archiviate"+ "archived_warranties": "Garanzie archiviate",+ "total_value": "Valore totale"},"about": {"title": "Informazioni su Warracker",@@ -803,4 +804,4 @@"pick_color": "Scegli il colore","create_with_name": "Crea \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/ja/translation.json b/locales/ja/translation.jsonindex 5e156a0..415d485 100644--- a/locales/ja/translation.json+++ b/locales/ja/translation.json@@ -681,7 +681,8 @@"connected": "接続済み","version": "バージョン","uptime": "稼働時間",- "archived_warranties": "アーカイブされた保証"+ "archived_warranties": "アーカイブされた保証",+ "total_value": "合計金額"},"about": {"title": "Warrackerについて",@@ -796,4 +797,4 @@"pick_color": "色を選択してください","create_with_name": "「{{name}}」を作成します"}-}+}\ No newline at end of filediff --git a/locales/ko/translation.json b/locales/ko/translation.jsonindex 61a7bc4..8c01ae4 100644--- a/locales/ko/translation.json+++ b/locales/ko/translation.json@@ -681,7 +681,8 @@"connected": "연결됨","version": "버전","uptime": "가동 시간",- "archived_warranties": "보관된 보증"+ "archived_warranties": "보관된 보증",+ "total_value": "총 가치"},"about": {"title": "Warracker 정보",@@ -796,4 +797,4 @@"pick_color": "색상 선택","create_with_name": "\"{{name}}\" 만들기"}-}+}\ No newline at end of filediff --git a/locales/nl/translation.json b/locales/nl/translation.jsonindex 2ca7eb4..f5c36bd 100644--- a/locales/nl/translation.json+++ b/locales/nl/translation.json@@ -681,7 +681,8 @@"connected": "Verbonden","version": "Versie","uptime": "Uptime",- "archived_warranties": "Gearchiveerde garanties"+ "archived_warranties": "Gearchiveerde garanties",+ "total_value": "Totale waarde"},"about": {"title": "Over Warracker",@@ -796,4 +797,4 @@"pick_color": "Kies kleur","create_with_name": "Creëer \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/pl/translation.json b/locales/pl/translation.jsonindex d9aeca1..7799f8b 100644--- a/locales/pl/translation.json+++ b/locales/pl/translation.json@@ -681,7 +681,8 @@"connected": "Połączono","version": "Wersja","uptime": "Czas działania",- "archived_warranties": "Archiwizowane gwarancje"+ "archived_warranties": "Archiwizowane gwarancje",+ "total_value": "Całkowita wartość"},"about": {"title": "O aplikacji - Warracker",@@ -796,4 +797,4 @@"no_selected": "Nie wybrano tagów","pick_color": "Wybierz kolor"}-}+}\ No newline at end of filediff --git a/locales/pt/translation.json b/locales/pt/translation.jsonindex 6a6cdb5..d399f6e 100644--- a/locales/pt/translation.json+++ b/locales/pt/translation.json@@ -725,7 +725,8 @@"connected": "Conectado","version": "Versão","uptime": "Tempo de Atividade",- "archived_warranties": "Garantias arquivadas"+ "archived_warranties": "Garantias arquivadas",+ "total_value": "Valor total"},"about": {"title": "Sobre o Warracker",@@ -796,4 +797,4 @@"pick_color": "Escolha a cor","create_with_name": "Crie \"{{name}}\""}-}+}\ No newline at end of filediff --git a/locales/ru/translation.json b/locales/ru/translation.jsonindex 587a4fe..382458a 100644--- a/locales/ru/translation.json+++ b/locales/ru/translation.json@@ -731,7 +731,8 @@"connected": "Подключено","version": "Версия","uptime": "Время работы",- "archived_warranties": "Архивные гарантии"+ "archived_warranties": "Архивные гарантии",+ "total_value": "Общая стоимость"},"about": {"title": "О Warracker",@@ -802,4 +803,4 @@"no_selected": "Теги не выбраны","pick_color": "Выберите цвет"}-}+}\ No newline at end of filediff --git a/locales/tr/translation.json b/locales/tr/translation.jsonindex 6396fa5..b015225 100644--- a/locales/tr/translation.json+++ b/locales/tr/translation.json@@ -681,7 +681,8 @@"connected": "Bağlı","version": "Sürüm","uptime": "Çalışma Süresi",- "archived_warranties": "Arşivlenmiş Garantiler"+ "archived_warranties": "Arşivlenmiş Garantiler",+ "total_value": "Toplam Değer"},"about": {"title": "Warracker Hakkında",@@ -796,4 +797,4 @@"no_selected": "Hiçbir etiket seçilmedi","pick_color": "Renk seç"}-}+}\ No newline at end of filediff --git a/locales/uk/translation.json b/locales/uk/translation.jsonindex fa5313e..d591030 100644--- a/locales/uk/translation.json+++ b/locales/uk/translation.json@@ -687,7 +687,8 @@"connected": "Підключено","version": "Версія","uptime": "Час роботи",- "archived_warranties": "Архівні гарантії"+ "archived_warranties": "Архівні гарантії",+ "total_value": "Загальна вартість"},"about": {"title": "Про Warracker",@@ -802,4 +803,4 @@"no_selected": "Теги не вибрано","pick_color": "Виберіть колір"}-}+}\ No newline at end of filediff --git a/locales/zh_CN/translation.json b/locales/zh_CN/translation.jsonindex 7e4bf26..6e4107d 100644--- a/locales/zh_CN/translation.json+++ b/locales/zh_CN/translation.json@@ -681,7 +681,8 @@"connected": "已连接","version": "版本","uptime": "正常运行时间",- "archived_warranties": "存档的保修"+ "archived_warranties": "存档的保修",+ "total_value": "总价值"},"about": {"title": "关于 - Warracker",@@ -796,4 +797,4 @@"errors": {"error": "错误"}-}+}\ No newline at end of filediff --git a/locales/zh_HK/translation.json b/locales/zh_HK/translation.jsonindex 476889e..2ced1a1 100644--- a/locales/zh_HK/translation.json+++ b/locales/zh_HK/translation.json@@ -681,7 +681,8 @@"connected": "已連線","version": "版本","uptime": "正常執行時間",- "archived_warranties": "存檔的保固"+ "archived_warranties": "存檔的保固",+ "total_value": "總價值"},"about": {"title": "關於Warracker",@@ -796,4 +797,4 @@"no_selected": "沒有選擇標籤","pick_color": "選擇顏色"}-}+}\ No newline at end of file