mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-13 12:23:44 +01:00
fix(insights): show exchanged amounts in the overview
This commit is contained in:
1 parent
4d886a4fea
commit
220ccee140
3 files changed
+39
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -20,6 +20,15 @@
|
||||
:suffix="currency.currency.suffix"
|
||||
:decimal_places="currency.currency.decimal_places"
|
||||
color="green"></c-amount.display>
|
||||
{% if currency.exchanged %}
|
||||
<div class="text-xs text-base-content/60">
|
||||
<c-amount.display
|
||||
:amount="currency.exchanged.shown.income"
|
||||
:prefix="currency.exchanged.currency.prefix"
|
||||
:suffix="currency.exchanged.currency.suffix"
|
||||
:decimal_places="currency.exchanged.currency.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div>-</div>
|
||||
{% endif %}
|
||||
@@ -34,6 +43,15 @@
|
||||
:suffix="currency.currency.suffix"
|
||||
:decimal_places="currency.currency.decimal_places"
|
||||
color="red"></c-amount.display>
|
||||
{% if currency.exchanged %}
|
||||
<div class="text-xs text-base-content/60">
|
||||
<c-amount.display
|
||||
:amount="currency.exchanged.shown.expense"
|
||||
:prefix="currency.exchanged.currency.prefix"
|
||||
:suffix="currency.exchanged.currency.suffix"
|
||||
:decimal_places="currency.exchanged.currency.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div>-</div>
|
||||
{% endif %}
|
||||
@@ -48,6 +66,15 @@
|
||||
:suffix="currency.currency.suffix"
|
||||
:decimal_places="currency.currency.decimal_places"
|
||||
color="{% if currency.total_final < 0 %}red{% else %}green{% endif %}"></c-amount.display>
|
||||
{% if currency.exchanged %}
|
||||
<div class="text-xs text-base-content/60">
|
||||
<c-amount.display
|
||||
:amount="currency.exchanged.shown.total"
|
||||
:prefix="currency.exchanged.currency.prefix"
|
||||
:suffix="currency.exchanged.currency.suffix"
|
||||
:decimal_places="currency.exchanged.currency.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div>-</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in new issue
Block a user