diff --git a/app/apps/insights/utils/overview.py b/app/apps/insights/utils/overview.py index 29b9008f..f2bdee24 100644 --- a/app/apps/insights/utils/overview.py +++ b/app/apps/insights/utils/overview.py @@ -148,6 +148,11 @@ def _build_currency_data(metric, showing): "name": exchange_currency.name, } if exchanged: + exchanged["shown"] = { + "income": exchanged.get(income), + "expense": exchanged.get(expense), + "total": exchanged.get(total), + } currency_data["exchanged"] = exchanged return currency_data diff --git a/app/apps/transactions/tests/test_exchanged_amounts.py b/app/apps/transactions/tests/test_exchanged_amounts.py index 1c1a8a1f..bc09d16b 100644 --- a/app/apps/transactions/tests/test_exchanged_amounts.py +++ b/app/apps/transactions/tests/test_exchanged_amounts.py @@ -9,6 +9,7 @@ from apps.accounts.models import Account, AccountGroup from apps.common.middleware.thread_local import delete_current_user, write_current_user from apps.currencies.models import Currency, ExchangeRate from apps.insights.utils.month_by_month import get_month_by_month_data +from apps.insights.utils.overview import get_grouped_totals from apps.insights.utils.year_by_year import get_year_by_year_data from apps.transactions.models import Transaction, TransactionCategory from apps.transactions.utils.calculations import ( @@ -161,12 +162,18 @@ class TotalsExchangedAmountTests(ExchangedAmountsTestBase): year_data["year_totals"][2026]["currencies"][self.eur.id], ] + def overview_total(): + overview = get_grouped_totals(Transaction.objects.all(), ["categories"]) + return next(iter(overview.values()))["currencies"][self.eur.id] + for total in exchanged_totals(): self.assertEqual(total["exchanged"]["final_total"], Decimal("200")) + self.assertEqual(overview_total()["exchanged"]["shown"]["total"], Decimal("200")) self._hide_for(self.eur) for total in exchanged_totals(): self.assertNotIn("exchanged", total) + self.assertNotIn("exchanged", overview_total()) def test_net_worth_keeps_the_consolidated_total(self): self._hide_for(self.eur) diff --git a/app/templates/insights/fragments/overview/_row.html b/app/templates/insights/fragments/overview/_row.html index 9cd493d9..7878d991 100644 --- a/app/templates/insights/fragments/overview/_row.html +++ b/app/templates/insights/fragments/overview/_row.html @@ -20,6 +20,15 @@ :suffix="currency.currency.suffix" :decimal_places="currency.currency.decimal_places" color="green"> + {% if currency.exchanged %} +