From 4efba3424d12253962cf08af9e7fddf8e88875d0 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Tue, 24 Dec 2024 11:58:23 -0300 Subject: [PATCH] feat(yearly:account): add percentage bar --- app/apps/yearly_overview/views.py | 9 ++++- .../fragments/account_data.html | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/apps/yearly_overview/views.py b/app/apps/yearly_overview/views.py index 2a60052..5a09352 100644 --- a/app/apps/yearly_overview/views.py +++ b/app/apps/yearly_overview/views.py @@ -12,6 +12,7 @@ from apps.transactions.models import Transaction from apps.transactions.utils.calculations import ( calculate_account_totals, calculate_currency_totals, + calculate_percentage_distribution, ) @@ -156,9 +157,15 @@ def yearly_overview_by_account(request, year: int): ) data = calculate_account_totals(transactions) + percentages = calculate_percentage_distribution(data) return render( request, "yearly_overview/fragments/account_data.html", - context={"year": year, "totals": data, "single": True if account else False}, + context={ + "year": year, + "totals": data, + "percentages": percentages, + "single": True if account else False, + }, ) diff --git a/app/templates/yearly_overview/fragments/account_data.html b/app/templates/yearly_overview/fragments/account_data.html index 107fef2..6ebc46b 100644 --- a/app/templates/yearly_overview/fragments/account_data.html +++ b/app/templates/yearly_overview/fragments/account_data.html @@ -1,3 +1,4 @@ +{% load tools %} {% load i18n %}
@@ -173,6 +174,38 @@
{% endif %}
+ {% with p=percentages|get_dict_item:account_id %} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% endwith %} {% empty %}