feat: indicate what paid/project button means

Closes #122
This commit is contained in:
Herculino Trotta
2025-02-01 19:06:04 -03:00
parent 712f5f428e
commit 9705441e2d
6 changed files with 147 additions and 76 deletions

View File

@@ -72,8 +72,12 @@ def calculate_currency_totals(transactions_queryset, ignore_empty=False):
.order_by()
)
# Process the results and calculate additional totals
# First pass: Process basic totals and store all currency data
result = {}
currencies_using_exchange = (
{}
) # Track which currencies use which exchange currencies
for total in currency_totals:
# Skip empty currencies if ignore_empty is True
if ignore_empty and all(
@@ -91,7 +95,6 @@ def calculate_currency_totals(transactions_queryset, ignore_empty=False):
total_current = total["income_current"] - total["expense_current"]
total_projected = total["income_projected"] - total["expense_projected"]
total_final = total_current + total_projected
currency_id = total["account__currency"]
from_currency = Currency.objects.get(id=currency_id)
exchange_currency = (
@@ -120,8 +123,6 @@ def calculate_currency_totals(transactions_queryset, ignore_empty=False):
# Add exchanged values if exchange_currency exists
if exchange_currency:
exchanged = {}
# Convert each value
for field in [
"expense_current",
"expense_projected",
@@ -136,7 +137,6 @@ def calculate_currency_totals(transactions_queryset, ignore_empty=False):
from_currency=from_currency,
to_currency=exchange_currency,
)
if amount is not None:
exchanged[field] = amount
if "currency" not in exchanged:
@@ -148,12 +148,48 @@ def calculate_currency_totals(transactions_queryset, ignore_empty=False):
"name": exchange_currency.name,
}
# Only add exchanged data if at least one conversion was successful
if exchanged:
currency_data["exchanged"] = exchanged
# Track which currencies are using which exchange currencies
if exchange_currency.id not in currencies_using_exchange:
currencies_using_exchange[exchange_currency.id] = []
currencies_using_exchange[exchange_currency.id].append(
{"currency_id": currency_id, "exchanged": exchanged}
)
result[currency_id] = currency_data
# Second pass: Add consolidated totals for currencies that are used as exchange currencies
for currency_id, currency_data in result.items():
if currency_id in currencies_using_exchange:
consolidated = {
"currency": currency_data["currency"].copy(),
"expense_current": currency_data["expense_current"],
"expense_projected": currency_data["expense_projected"],
"income_current": currency_data["income_current"],
"income_projected": currency_data["income_projected"],
"total_current": currency_data["total_current"],
"total_projected": currency_data["total_projected"],
"total_final": currency_data["total_final"],
}
# Add exchanged values from all currencies using this as exchange currency
for using_currency in currencies_using_exchange[currency_id]:
exchanged = using_currency["exchanged"]
for field in [
"expense_current",
"expense_projected",
"income_current",
"income_projected",
"total_current",
"total_projected",
"total_final",
]:
if field in exchanged:
consolidated[field] += exchanged[field]
result[currency_id]["consolidated"] = consolidated
return result

View File

@@ -2,13 +2,13 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-01 14:09+0000\n"
"POT-Creation-Date: 2025-02-01 22:04+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -625,7 +625,8 @@ msgid "Type"
msgstr ""
#: apps/rules/models.py:21 apps/transactions/filters.py:23
#: apps/transactions/models.py:141
#: apps/transactions/models.py:141 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30
#: templates/transactions/widgets/paid_toggle_button.html:12
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:16
msgid "Paid"
@@ -692,7 +693,8 @@ msgstr ""
msgid "Action deleted successfully"
msgstr ""
#: apps/transactions/filters.py:24 templates/includes/navbar.html:46
#: apps/transactions/filters.py:24 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30 templates/includes/navbar.html:46
#: templates/transactions/widgets/paid_toggle_button.html:8
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:12
msgid "Projected"
@@ -1221,23 +1223,23 @@ msgstr ""
msgid "Start page"
msgstr ""
#: apps/users/views.py:58
#: apps/users/views.py:60
msgid "Transaction amounts are now hidden"
msgstr ""
#: apps/users/views.py:61
#: apps/users/views.py:63
msgid "Transaction amounts are now displayed"
msgstr ""
#: apps/users/views.py:79
#: apps/users/views.py:81
msgid "Sounds are now muted"
msgstr ""
#: apps/users/views.py:82
#: apps/users/views.py:84
msgid "Sounds will now play"
msgstr ""
#: apps/users/views.py:98
#: apps/users/views.py:100
msgid "Your settings have been updated"
msgstr ""
@@ -1267,7 +1269,7 @@ msgstr ""
#: templates/account_groups/fragments/list.html:36
#: templates/accounts/fragments/list.html:41
#: templates/categories/fragments/table.html:29
#: templates/cotton/transaction/item.html:123
#: templates/cotton/transaction/item.html:126
#: templates/cotton/ui/transactions_action_bar.html:49
#: templates/currencies/fragments/list.html:37
#: templates/dca/fragments/strategy/details.html:67
@@ -1286,8 +1288,8 @@ msgstr ""
#: templates/account_groups/fragments/list.html:43
#: templates/accounts/fragments/list.html:48
#: templates/categories/fragments/table.html:36
#: templates/cotton/transaction/item.html:138
#: templates/cotton/transaction/item.html:157
#: templates/cotton/transaction/item.html:141
#: templates/cotton/transaction/item.html:160
#: templates/cotton/ui/deleted_transactions_action_bar.html:55
#: templates/cotton/ui/transactions_action_bar.html:86
#: templates/currencies/fragments/list.html:44
@@ -1309,8 +1311,8 @@ msgstr ""
#: templates/account_groups/fragments/list.html:47
#: templates/accounts/fragments/list.html:52
#: templates/categories/fragments/table.html:41
#: templates/cotton/transaction/item.html:142
#: templates/cotton/transaction/item.html:161
#: templates/cotton/transaction/item.html:145
#: templates/cotton/transaction/item.html:164
#: templates/cotton/ui/deleted_transactions_action_bar.html:57
#: templates/cotton/ui/transactions_action_bar.html:88
#: templates/currencies/fragments/list.html:48
@@ -1335,8 +1337,8 @@ msgstr ""
#: templates/account_groups/fragments/list.html:48
#: templates/accounts/fragments/list.html:53
#: templates/categories/fragments/table.html:42
#: templates/cotton/transaction/item.html:143
#: templates/cotton/transaction/item.html:162
#: templates/cotton/transaction/item.html:146
#: templates/cotton/transaction/item.html:165
#: templates/cotton/ui/deleted_transactions_action_bar.html:58
#: templates/cotton/ui/transactions_action_bar.html:89
#: templates/currencies/fragments/list.html:49
@@ -1354,8 +1356,8 @@ msgstr ""
#: templates/account_groups/fragments/list.html:49
#: templates/accounts/fragments/list.html:54
#: templates/categories/fragments/table.html:43
#: templates/cotton/transaction/item.html:144
#: templates/cotton/transaction/item.html:163
#: templates/cotton/transaction/item.html:147
#: templates/cotton/transaction/item.html:166
#: templates/currencies/fragments/list.html:50
#: templates/dca/fragments/strategy/details.html:82
#: templates/dca/fragments/strategy/list.html:48
@@ -1481,12 +1483,12 @@ msgstr ""
msgid "Select"
msgstr ""
#: templates/cotton/transaction/item.html:130
#: templates/cotton/transaction/item.html:133
#: templates/cotton/ui/transactions_action_bar.html:78
msgid "Duplicate"
msgstr ""
#: templates/cotton/transaction/item.html:151
#: templates/cotton/transaction/item.html:154
#: templates/cotton/ui/deleted_transactions_action_bar.html:47
msgid "Restore"
msgstr ""
@@ -2132,16 +2134,20 @@ msgstr ""
msgid "By currency"
msgstr ""
#: templates/net_worth/net_worth.html:65
#: templates/net_worth/net_worth.html:52
msgid "Consolidated"
msgstr ""
#: templates/net_worth/net_worth.html:81
#: templates/yearly_overview/pages/overview_by_account.html:7
msgid "By account"
msgstr ""
#: templates/net_worth/net_worth.html:172
#: templates/net_worth/net_worth.html:188
msgid "Evolution by currency"
msgstr ""
#: templates/net_worth/net_worth.html:236
#: templates/net_worth/net_worth.html:252
msgid "Evolution by account"
msgstr ""

View File

@@ -2,13 +2,13 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-01 14:09+0000\n"
"POT-Creation-Date: 2025-02-01 22:04+0000\n"
"PO-Revision-Date: 2025-01-29 06:12+0100\n"
"Last-Translator: Dimitri Decrock <dimitri@fam-decrock.eu>\n"
"Language-Team: \n"
@@ -631,7 +631,8 @@ msgid "Type"
msgstr "Soort"
#: apps/rules/models.py:21 apps/transactions/filters.py:23
#: apps/transactions/models.py:141
#: apps/transactions/models.py:141 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30
#: templates/transactions/widgets/paid_toggle_button.html:12
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:16
msgid "Paid"
@@ -698,7 +699,8 @@ msgstr "Actie succesvol bijgewerkt"
msgid "Action deleted successfully"
msgstr "Actie succesvol verwijderd"
#: apps/transactions/filters.py:24 templates/includes/navbar.html:46
#: apps/transactions/filters.py:24 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30 templates/includes/navbar.html:46
#: templates/transactions/widgets/paid_toggle_button.html:8
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:12
msgid "Projected"
@@ -1237,23 +1239,23 @@ msgstr "Tijdszone"
msgid "Start page"
msgstr "Startpagina"
#: apps/users/views.py:58
#: apps/users/views.py:60
msgid "Transaction amounts are now hidden"
msgstr "Verrichtingsbedragen worden nu verborgen"
#: apps/users/views.py:61
#: apps/users/views.py:63
msgid "Transaction amounts are now displayed"
msgstr "Verrichtingsbedragen worden nu weergegeven"
#: apps/users/views.py:79
#: apps/users/views.py:81
msgid "Sounds are now muted"
msgstr "De Geluiden zijn nu gedempt"
#: apps/users/views.py:82
#: apps/users/views.py:84
msgid "Sounds will now play"
msgstr "De geluiden worden nu afgespeeld"
#: apps/users/views.py:98
#: apps/users/views.py:100
msgid "Your settings have been updated"
msgstr "Jouw instellingen zijn bijgewerkt"
@@ -1283,7 +1285,7 @@ msgstr "Acties"
#: templates/account_groups/fragments/list.html:36
#: templates/accounts/fragments/list.html:41
#: templates/categories/fragments/table.html:29
#: templates/cotton/transaction/item.html:123
#: templates/cotton/transaction/item.html:126
#: templates/cotton/ui/transactions_action_bar.html:49
#: templates/currencies/fragments/list.html:37
#: templates/dca/fragments/strategy/details.html:67
@@ -1302,8 +1304,8 @@ msgstr "Bijwerken"
#: templates/account_groups/fragments/list.html:43
#: templates/accounts/fragments/list.html:48
#: templates/categories/fragments/table.html:36
#: templates/cotton/transaction/item.html:138
#: templates/cotton/transaction/item.html:157
#: templates/cotton/transaction/item.html:141
#: templates/cotton/transaction/item.html:160
#: templates/cotton/ui/deleted_transactions_action_bar.html:55
#: templates/cotton/ui/transactions_action_bar.html:86
#: templates/currencies/fragments/list.html:44
@@ -1325,8 +1327,8 @@ msgstr "Verwijderen"
#: templates/account_groups/fragments/list.html:47
#: templates/accounts/fragments/list.html:52
#: templates/categories/fragments/table.html:41
#: templates/cotton/transaction/item.html:142
#: templates/cotton/transaction/item.html:161
#: templates/cotton/transaction/item.html:145
#: templates/cotton/transaction/item.html:164
#: templates/cotton/ui/deleted_transactions_action_bar.html:57
#: templates/cotton/ui/transactions_action_bar.html:88
#: templates/currencies/fragments/list.html:48
@@ -1351,8 +1353,8 @@ msgstr "Weet je het zeker?"
#: templates/account_groups/fragments/list.html:48
#: templates/accounts/fragments/list.html:53
#: templates/categories/fragments/table.html:42
#: templates/cotton/transaction/item.html:143
#: templates/cotton/transaction/item.html:162
#: templates/cotton/transaction/item.html:146
#: templates/cotton/transaction/item.html:165
#: templates/cotton/ui/deleted_transactions_action_bar.html:58
#: templates/cotton/ui/transactions_action_bar.html:89
#: templates/currencies/fragments/list.html:49
@@ -1370,8 +1372,8 @@ msgstr "Je kunt dit niet meer terugdraaien!"
#: templates/account_groups/fragments/list.html:49
#: templates/accounts/fragments/list.html:54
#: templates/categories/fragments/table.html:43
#: templates/cotton/transaction/item.html:144
#: templates/cotton/transaction/item.html:163
#: templates/cotton/transaction/item.html:147
#: templates/cotton/transaction/item.html:166
#: templates/currencies/fragments/list.html:50
#: templates/dca/fragments/strategy/details.html:82
#: templates/dca/fragments/strategy/list.html:48
@@ -1497,12 +1499,12 @@ msgstr "Zoeken"
msgid "Select"
msgstr "Selecteer"
#: templates/cotton/transaction/item.html:130
#: templates/cotton/transaction/item.html:133
#: templates/cotton/ui/transactions_action_bar.html:78
msgid "Duplicate"
msgstr "Dupliceren"
#: templates/cotton/transaction/item.html:151
#: templates/cotton/transaction/item.html:154
#: templates/cotton/ui/deleted_transactions_action_bar.html:47
msgid "Restore"
msgstr ""
@@ -2153,16 +2155,20 @@ msgstr "Verwachte Nettowaarde"
msgid "By currency"
msgstr "Op munteenheid"
#: templates/net_worth/net_worth.html:65
#: templates/net_worth/net_worth.html:52
msgid "Consolidated"
msgstr ""
#: templates/net_worth/net_worth.html:81
#: templates/yearly_overview/pages/overview_by_account.html:7
msgid "By account"
msgstr "Op rekening"
#: templates/net_worth/net_worth.html:172
#: templates/net_worth/net_worth.html:188
msgid "Evolution by currency"
msgstr "Evolutie per munteenheid"
#: templates/net_worth/net_worth.html:236
#: templates/net_worth/net_worth.html:252
msgid "Evolution by account"
msgstr "Evolutie per rekening"

View File

@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-01 14:09+0000\n"
"PO-Revision-Date: 2025-02-01 11:10-0300\n"
"POT-Creation-Date: 2025-02-01 22:04+0000\n"
"PO-Revision-Date: 2025-02-01 19:04-0300\n"
"Last-Translator: Herculino Trotta\n"
"Language-Team: \n"
"Language: pt_BR\n"
@@ -629,7 +629,8 @@ msgid "Type"
msgstr "Tipo"
#: apps/rules/models.py:21 apps/transactions/filters.py:23
#: apps/transactions/models.py:141
#: apps/transactions/models.py:141 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30
#: templates/transactions/widgets/paid_toggle_button.html:12
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:16
msgid "Paid"
@@ -696,7 +697,8 @@ msgstr "Ação atualizada com sucesso"
msgid "Action deleted successfully"
msgstr "Ação apagada com sucesso"
#: apps/transactions/filters.py:24 templates/includes/navbar.html:46
#: apps/transactions/filters.py:24 templates/cotton/transaction/item.html:20
#: templates/cotton/transaction/item.html:30 templates/includes/navbar.html:46
#: templates/transactions/widgets/paid_toggle_button.html:8
#: templates/transactions/widgets/unselectable_paid_toggle_button.html:12
msgid "Projected"
@@ -1230,23 +1232,23 @@ msgstr "Fuso horário"
msgid "Start page"
msgstr "Página inicial"
#: apps/users/views.py:58
#: apps/users/views.py:60
msgid "Transaction amounts are now hidden"
msgstr "Os valores das transações agora estão ocultos"
#: apps/users/views.py:61
#: apps/users/views.py:63
msgid "Transaction amounts are now displayed"
msgstr "Os valores das transações agora estão sendo exibidos"
#: apps/users/views.py:79
#: apps/users/views.py:81
msgid "Sounds are now muted"
msgstr "Os sons agora estão silenciados"
#: apps/users/views.py:82
#: apps/users/views.py:84
msgid "Sounds will now play"
msgstr "Os sons agora serão reproduzidos"
#: apps/users/views.py:98
#: apps/users/views.py:100
msgid "Your settings have been updated"
msgstr "Suas configurações foram atualizadas"
@@ -1276,7 +1278,7 @@ msgstr "Ações"
#: templates/account_groups/fragments/list.html:36
#: templates/accounts/fragments/list.html:41
#: templates/categories/fragments/table.html:29
#: templates/cotton/transaction/item.html:123
#: templates/cotton/transaction/item.html:126
#: templates/cotton/ui/transactions_action_bar.html:49
#: templates/currencies/fragments/list.html:37
#: templates/dca/fragments/strategy/details.html:67
@@ -1295,8 +1297,8 @@ msgstr "Editar"
#: templates/account_groups/fragments/list.html:43
#: templates/accounts/fragments/list.html:48
#: templates/categories/fragments/table.html:36
#: templates/cotton/transaction/item.html:138
#: templates/cotton/transaction/item.html:157
#: templates/cotton/transaction/item.html:141
#: templates/cotton/transaction/item.html:160
#: templates/cotton/ui/deleted_transactions_action_bar.html:55
#: templates/cotton/ui/transactions_action_bar.html:86
#: templates/currencies/fragments/list.html:44
@@ -1318,8 +1320,8 @@ msgstr "Apagar"
#: templates/account_groups/fragments/list.html:47
#: templates/accounts/fragments/list.html:52
#: templates/categories/fragments/table.html:41
#: templates/cotton/transaction/item.html:142
#: templates/cotton/transaction/item.html:161
#: templates/cotton/transaction/item.html:145
#: templates/cotton/transaction/item.html:164
#: templates/cotton/ui/deleted_transactions_action_bar.html:57
#: templates/cotton/ui/transactions_action_bar.html:88
#: templates/currencies/fragments/list.html:48
@@ -1344,8 +1346,8 @@ msgstr "Tem certeza?"
#: templates/account_groups/fragments/list.html:48
#: templates/accounts/fragments/list.html:53
#: templates/categories/fragments/table.html:42
#: templates/cotton/transaction/item.html:143
#: templates/cotton/transaction/item.html:162
#: templates/cotton/transaction/item.html:146
#: templates/cotton/transaction/item.html:165
#: templates/cotton/ui/deleted_transactions_action_bar.html:58
#: templates/cotton/ui/transactions_action_bar.html:89
#: templates/currencies/fragments/list.html:49
@@ -1363,8 +1365,8 @@ msgstr "Você não será capaz de reverter isso!"
#: templates/account_groups/fragments/list.html:49
#: templates/accounts/fragments/list.html:54
#: templates/categories/fragments/table.html:43
#: templates/cotton/transaction/item.html:144
#: templates/cotton/transaction/item.html:163
#: templates/cotton/transaction/item.html:147
#: templates/cotton/transaction/item.html:166
#: templates/currencies/fragments/list.html:50
#: templates/dca/fragments/strategy/details.html:82
#: templates/dca/fragments/strategy/list.html:48
@@ -1490,12 +1492,12 @@ msgstr "Buscar"
msgid "Select"
msgstr "Selecionar"
#: templates/cotton/transaction/item.html:130
#: templates/cotton/transaction/item.html:133
#: templates/cotton/ui/transactions_action_bar.html:78
msgid "Duplicate"
msgstr "Duplicar"
#: templates/cotton/transaction/item.html:151
#: templates/cotton/transaction/item.html:154
#: templates/cotton/ui/deleted_transactions_action_bar.html:47
msgid "Restore"
msgstr "Restaurar"
@@ -2147,16 +2149,20 @@ msgstr "Patrimônio Previsto"
msgid "By currency"
msgstr "Por moeda"
#: templates/net_worth/net_worth.html:65
#: templates/net_worth/net_worth.html:52
msgid "Consolidated"
msgstr "Consolidado"
#: templates/net_worth/net_worth.html:81
#: templates/yearly_overview/pages/overview_by_account.html:7
msgid "By account"
msgstr "Por conta"
#: templates/net_worth/net_worth.html:172
#: templates/net_worth/net_worth.html:188
msgid "Evolution by currency"
msgstr "Evolução por moeda"
#: templates/net_worth/net_worth.html:236
#: templates/net_worth/net_worth.html:252
msgid "Evolution by account"
msgstr "Evolução por conta"

View File

@@ -111,7 +111,8 @@
{% endif %}
{% endwith %}
<div>
{% if transaction.account.group %}{{ transaction.account.group.name }} • {% endif %}{{ transaction.account.name }}</div>
{% if transaction.account.group %}{{ transaction.account.group.name }} • {% endif %}{{ transaction.account.name }}
</div>
</div>
<div>
{# Item actions#}

View File

@@ -46,6 +46,22 @@
color="grey"></c-amount.display>
</div>
{% endif %}
{% if currency.consolidated %}
<div class="d-flex align-items-baseline w-100">
<div class="account-name text-start font-monospace tw-text-gray-300">
<span class="hierarchy-line-icon"></span>{% trans 'Consolidated' %}</div>
<div class="dotted-line flex-grow-1"></div>
<div class="">
<c-amount.display
:amount="currency.consolidated.total_final"
:prefix="currency.consolidated.currency.prefix"
:suffix="currency.consolidated.currency.suffix"
:decimal_places="currency.consolidated.currency.decimal_places"
color="{% if currency.total_final > 0 %}green{% elif currency.total_final < 0 %}red{% endif %}"
text-end></c-amount.display>
</div>
</div>
{% endif %}
{% endfor %}
</c-ui.info-card>
</div>