From 812abbe48841880dd33f490e3768155148fac6fe Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 19 Apr 2025 12:16:21 -0300 Subject: [PATCH 1/2] feat(insights:category-overview): pick between Projected/Current/Final totals --- app/apps/insights/views.py | 14 +- .../fragments/category_overview/index.html | 159 +++++++++++++++--- 2 files changed, 144 insertions(+), 29 deletions(-) diff --git a/app/apps/insights/views.py b/app/apps/insights/views.py index bd65640..a5698a5 100644 --- a/app/apps/insights/views.py +++ b/app/apps/insights/views.py @@ -177,11 +177,14 @@ def category_overview(request): if "show_tags" in request.GET: show_tags = request.GET["show_tags"] == "on" request.session["insights_category_explorer_show_tags"] = show_tags - print(request.GET["show_tags"], show_tags) else: show_tags = request.session.get("insights_category_explorer_show_tags", True) - print(show_tags) + if "showing" in request.GET: + showing = request.GET["showing"] + request.session["insights_category_explorer_showing"] = showing + else: + showing = request.session.get("insights_category_explorer_showing", "final") # Get filtered transactions transactions = get_transactions(request, include_silent=True) @@ -193,7 +196,12 @@ def category_overview(request): return render( request, "insights/fragments/category_overview/index.html", - {"total_table": total_table, "view_type": view_type, "show_tags": show_tags}, + { + "total_table": total_table, + "view_type": view_type, + "show_tags": show_tags, + "showing": showing, + }, ) diff --git a/app/templates/insights/fragments/category_overview/index.html b/app/templates/insights/fragments/category_overview/index.html index 6825a34..b1f2968 100644 --- a/app/templates/insights/fragments/category_overview/index.html +++ b/app/templates/insights/fragments/category_overview/index.html @@ -1,15 +1,14 @@ {% load i18n %}
+ hx-include="#picker-form, #picker-type, #view-type, #show-tags, #showing">
-
+
@@ -20,29 +19,43 @@ id="bars-view" autocomplete="off" value="bars" - _="on change trigger updated" {% if view_type == "bars" %}checked{% endif %}>
- {% if total_table %} - {% if view_type == "table" %} -
-
- - - {% spaceless %} +
+
+ {% if view_type == 'table' %} + + + {% spaceless %} - {% endspaceless %} -
-
+ {% endspaceless %} + {% endif %} +
+
+ + + + + + + + +
+
+ {% if total_table %} + {% if view_type == "table" %}
@@ -58,9 +71,23 @@ -
{% if category.name %}{{ category.name }}{% else %}{% trans 'Uncategorized' %}{% endif %} + {# income #} {% for currency in category.currencies.values %} - {% if currency.total_income != 0 %} + {% if showing == 'current' and currency.income_current != 0 %} + + {% elif showing == 'projected' and currency.income_projected != 0 %} + + {% elif showing == 'final' and currency.total_income != 0 %} - + {# expenses #} {% for currency in category.currencies.values %} - {% if currency.total_expense != 0 %} + {% if showing == 'current' and currency.expense_current != 0 %} + + {% elif showing == 'projected' and currency.expense_projected != 0 %} + + {% elif showing == 'final' and currency.total_expense != 0 %} - + {# total #} {% for currency in category.currencies.values %} - {% if currency.total_final != 0 %} + {% if showing == 'current' and currency.total_current != 0 %} + + {% elif showing == 'projected' and currency.total_projected != 0 %} + + {% elif showing == 'final' and currency.total_final != 0 %} {% for currency in tag.currencies.values %} - {% if currency.total_income != 0 %} + {% if showing == 'current' and currency.income_current != 0 %} + + {% elif showing == 'projected' and currency.income_projected != 0 %} + + {% elif showing == 'final' and currency.total_income != 0 %} {% for currency in tag.currencies.values %} - {% if currency.total_expense != 0 %} + {% if showing == 'current' and currency.expense_current != 0 %} + + {% elif showing == 'projected' and currency.expense_projected != 0 %} + + {% elif showing == 'final' and currency.total_expense != 0 %} {% for currency in tag.currencies.values %} - {% if currency.total_final != 0 %} + {% if showing == 'current' and currency.total_current != 0 %} + + {% elif showing == 'projected' and currency.total_projected != 0 %} + + {% elif showing == 'final' and currency.total_final != 0 %} -
+
{{ total_table|json_script:"categoryOverviewData" }} + {{ showing|json_script:"showingString" }}