From ea3e9fd68fa1527f7df272e01f3af39c042fde0f Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 15 Aug 2026 01:30:57 -0300 Subject: [PATCH] feat(monthly): show asset accounts/currencies on specific sumaries --- .../monthly_overview/tests/test_summary.py | 38 +++++++++++++++++++ app/apps/monthly_overview/views.py | 2 - 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/apps/monthly_overview/tests/test_summary.py b/app/apps/monthly_overview/tests/test_summary.py index 590cab6..eaed8bc 100644 --- a/app/apps/monthly_overview/tests/test_summary.py +++ b/app/apps/monthly_overview/tests/test_summary.py @@ -107,6 +107,25 @@ class MonthlySummaryFilterBehaviorTests(TestCase): return data return None + def _create_asset_income(self): + asset_account = Account.objects.create( + name="Asset Account", + group=self.account_group, + currency=self.currency, + is_asset=True, + ) + Transaction.objects.create( + account=asset_account, + type=Transaction.Type.INCOME, + is_paid=True, + date=date(2025, 12, 25), + reference_date=date(2025, 12, 1), + amount=Decimal("50.00"), + description="Asset Income", + owner=self.user, + ) + return asset_account + # --- monthly_summary view tests --- def test_monthly_summary_no_filter_returns_200(self): @@ -304,6 +323,15 @@ class MonthlySummaryFilterBehaviorTests(TestCase): ) self.assertEqual(response.status_code, 200) + def test_monthly_account_summary_includes_asset_accounts(self): + asset_account = self._create_asset_income() + response = self.client.get( + "/monthly/12/2025/summary/accounts/", + HTTP_HX_REQUEST="true", + ) + + self.assertIn(asset_account.id, response.context["account_data"]) + def test_monthly_account_summary_with_filter_returns_200(self): """Test that monthly_account_summary returns 200 with filter""" response = self.client.get( @@ -322,6 +350,16 @@ class MonthlySummaryFilterBehaviorTests(TestCase): ) self.assertEqual(response.status_code, 200) + def test_monthly_currency_summary_includes_asset_account_transactions(self): + self._create_asset_income() + response = self.client.get( + "/monthly/12/2025/summary/currencies/", + HTTP_HX_REQUEST="true", + ) + + usd_data = self._get_currency_data(response.context["currency_data"]) + self.assertEqual(usd_data["income_current"], Decimal("1050.00")) + def test_monthly_currency_summary_with_filter_returns_200(self): """Test that monthly_currency_summary returns 200 with filter""" response = self.client.get( diff --git a/app/apps/monthly_overview/views.py b/app/apps/monthly_overview/views.py index b78da05..c4a4c81 100644 --- a/app/apps/monthly_overview/views.py +++ b/app/apps/monthly_overview/views.py @@ -226,7 +226,6 @@ def monthly_account_summary(request, month: int, year: int): Q(Q(category__mute=True) & ~Q(category=None)) | Q(mute=True) ) .exclude(account__in=request.user.untracked_accounts.all()) - .exclude(account__is_asset=True) ) account_data = calculate_account_totals(transactions_queryset=queryset.all()) @@ -280,7 +279,6 @@ def monthly_currency_summary(request, month: int, year: int): Q(Q(category__mute=True) & ~Q(category=None)) | Q(mute=True) ) .exclude(account__in=request.user.untracked_accounts.all()) - .exclude(account__is_asset=True) ) currency_data = calculate_currency_totals(queryset.all(), ignore_empty=True)