From 1544c6cca29cb364ced8575d49522528e2acbf72 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 18 Nov 2024 10:08:54 -0300 Subject: [PATCH] fix: wrong calculations --- app/apps/transactions/utils/calculations.py | 1 - app/apps/yearly_overview/views.py | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/apps/transactions/utils/calculations.py b/app/apps/transactions/utils/calculations.py index 96bab5c..6710db3 100644 --- a/app/apps/transactions/utils/calculations.py +++ b/app/apps/transactions/utils/calculations.py @@ -163,7 +163,6 @@ def calculate_account_totals(transactions_queryset, ignore_empty=False): "account__currency__prefix", "account__currency__suffix", "account__exchange_currency", - "id", ).annotate( expense_current=Coalesce( Sum( diff --git a/app/apps/yearly_overview/views.py b/app/apps/yearly_overview/views.py index 839c105..771c6d9 100644 --- a/app/apps/yearly_overview/views.py +++ b/app/apps/yearly_overview/views.py @@ -146,8 +146,13 @@ def yearly_overview_by_account(request, year: int): if account: filter_params["account_id"] = int(account) - transactions = Transaction.objects.filter(**filter_params).exclude( - Q(category__mute=True) & ~Q(category=None) + transactions = ( + Transaction.objects.filter(**filter_params) + .exclude(Q(category__mute=True) & ~Q(category=None)) + .order_by( + "account__group__name", + "account__name", + ) ) data = calculate_account_totals(transactions)