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> </div>
<div class="col-lg-3 col-12 text-lg-end align-self-end"> <div class="col-lg-3 col-12 text-lg-end align-self-end">
<c-amount.display <div class="main-amount">
:amount="transaction.amount" <c-amount.display
:prefix="transaction.account.currency.prefix" :amount="transaction.amount"
:suffix="transaction.account.currency.suffix" :prefix="transaction.account.currency.prefix"
:decimal_places="transaction.account.currency.decimal_places" :suffix="transaction.account.currency.suffix"
color="{% if transaction.type == "EX" %}red{% else %}green{% endif %}"></c-amount.display> :decimal_places="transaction.account.currency.decimal_places"
color="{% if transaction.type == "EX" %}red{% else %}green{% endif %}"></c-amount.display>
</div>
{# Exchange Rate#} {# Exchange Rate#}
{% with exchanged=transaction.exchanged_amount %} {% with exchanged=transaction.exchanged_amount %}
{% if exchanged %} {% if exchanged %}
<c-amount.display <div class="exchanged-amount">
:amount="exchanged.amount" <c-amount.display
:prefix="exchanged.prefix" :amount="exchanged.amount"
:suffix="exchanged.suffix" :prefix="exchanged.prefix"
:decimal_places="exchanged.decimal_places" :suffix="exchanged.suffix"
color="grey"></c-amount.display> :decimal_places="exchanged.decimal_places"
color="grey"></c-amount.display>
</div>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
<div>{% if transaction.account.group %}{{ transaction.account.group.name }} • {% endif %}{{ transaction.account.name }}</div> <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> <div class="vr mx-3 tw-align-middle"></div>
<span _="on selected_transactions_updated from #actions-bar <span _="on selected_transactions_updated from #actions-bar
set total to 0.0 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')) set amountValue to parseFloat(amt.getAttribute('data-amount'))
if not isNaN(amountValue) if not isNaN(amountValue)
set total to total + amountValue set total to total + amountValue