From 20c6989ffbfbc4f340c3b83e0830be937fda885a Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 9 Aug 2025 03:45:16 -0300 Subject: [PATCH] fix(insights:emergency-fund): hide untracked accounts --- app/apps/insights/views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/apps/insights/views.py b/app/apps/insights/views.py index 098c43d..4788922 100644 --- a/app/apps/insights/views.py +++ b/app/apps/insights/views.py @@ -239,10 +239,14 @@ def late_transactions(request): @login_required @require_http_methods(["GET"]) def emergency_fund(request): - transactions_currency_queryset = Transaction.objects.filter( - is_paid=True, account__is_archived=False, account__is_asset=False - ).order_by( - "account__currency__name", + transactions_currency_queryset = ( + Transaction.objects.filter( + is_paid=True, account__is_archived=False, account__is_asset=False + ) + .exclude(account__in=request.user.untracked_accounts.all()) + .order_by( + "account__currency__name", + ) ) currency_net_worth = calculate_currency_totals( transactions_queryset=transactions_currency_queryset, ignore_empty=False @@ -262,6 +266,7 @@ def emergency_fund(request): category__mute=False, mute=False, ) + .exclude(account__in=request.user.untracked_accounts.all()) .values("reference_date", "account__currency") .annotate(monthly_total=Sum("amount")) )