mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-24 17:48:41 +02:00
feat(transactions): properly sum income and expense when selected
also added a flatTotal (old behavior) for future use
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
<div class="transaction d-flex my-1">
|
<div class="transaction d-flex my-1 {% if transaction.type == "EX" %}expense{% else %}income{% endif %}">
|
||||||
{% if not disable_selection %}
|
{% if not disable_selection %}
|
||||||
<label class="px-3 d-flex align-items-center justify-content-center">
|
<label class="px-3 d-flex align-items-center justify-content-center">
|
||||||
<input class="form-check-input" type="checkbox" name="transactions" value="{{ transaction.id }}" id="check-{{ transaction.id }}" aria-label="{% translate 'Select' %}" hx-preserve>
|
<input class="form-check-input" type="checkbox" name="transactions" value="{{ transaction.id }}" id="check-{{ transaction.id }}" aria-label="{% translate 'Select' %}" hx-preserve>
|
||||||
|
|||||||
@@ -57,15 +57,23 @@
|
|||||||
</button>
|
</button>
|
||||||
<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 realTotal to 0.0
|
||||||
for amt in <.transaction:has(input[name='transactions']:checked) .main-amount .amount/>
|
set flatTotal to 0.0
|
||||||
|
for transaction in <.transaction:has(input[name='transactions']:checked)/>
|
||||||
|
set amt to first <.main-amount .amount/> in transaction
|
||||||
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 * 100)
|
set flatTotal to flatTotal + (amountValue * 100)
|
||||||
|
|
||||||
|
if transaction match .income
|
||||||
|
set realTotal to realTotal + (amountValue * 100)
|
||||||
|
else
|
||||||
|
set realTotal to realTotal - (amountValue * 100)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set total to total / 100
|
set realTotal to realTotal / 100
|
||||||
put total.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me
|
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me
|
||||||
end
|
end
|
||||||
on click
|
on click
|
||||||
set original_value to my innerText
|
set original_value to my innerText
|
||||||
|
|||||||
Reference in New Issue
Block a user