fix: Summing exchanged transactions sums both amount and the exchanged amount

This commit is contained in:
Herculino Trotta
2024-11-11 00:35:09 -03:00
parent d4a3117702
commit eab04ad298
2 changed files with 17 additions and 13 deletions

View File

@@ -66,21 +66,25 @@
</div>
</div>
<div class="col-lg-3 col-12 text-lg-end align-self-end">
<c-amount.display
:amount="transaction.amount"
:prefix="transaction.account.currency.prefix"
:suffix="transaction.account.currency.suffix"
:decimal_places="transaction.account.currency.decimal_places"
color="{% if transaction.type == "EX" %}red{% else %}green{% endif %}"></c-amount.display>
<div class="main-amount">
<c-amount.display
:amount="transaction.amount"
:prefix="transaction.account.currency.prefix"
:suffix="transaction.account.currency.suffix"
:decimal_places="transaction.account.currency.decimal_places"
color="{% if transaction.type == "EX" %}red{% else %}green{% endif %}"></c-amount.display>
</div>
{# Exchange Rate#}
{% with exchanged=transaction.exchanged_amount %}
{% if exchanged %}
<c-amount.display
:amount="exchanged.amount"
:prefix="exchanged.prefix"
:suffix="exchanged.suffix"
:decimal_places="exchanged.decimal_places"
color="grey"></c-amount.display>
<div class="exchanged-amount">
<c-amount.display
:amount="exchanged.amount"
:prefix="exchanged.prefix"
:suffix="exchanged.suffix"
:decimal_places="exchanged.decimal_places"
color="grey"></c-amount.display>
</div>
{% endif %}
{% endwith %}
<div>{% if transaction.account.group %}{{ transaction.account.group.name }} • {% endif %}{{ transaction.account.name }}</div>

View File

@@ -58,7 +58,7 @@ _="on change from #transactions-list or htmx:afterSettle
<div class="vr mx-3 tw-align-middle"></div>
<span _="on selected_transactions_updated from #actions-bar
set total to 0.0
for amt in <.transaction:has(input[name='transactions']:checked) .amount/>
for amt in <.transaction:has(input[name='transactions']:checked) .main-amount .amount/>
set amountValue to parseFloat(amt.getAttribute('data-amount'))
if not isNaN(amountValue)
set total to total + amountValue