From 52a0279fc83dbda444893c81d0c2ef5090f47249 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 18 Nov 2024 10:40:09 -0300 Subject: [PATCH] fix: rounding erros when summing transactions --- app/templates/cotton/ui/transactions_action_bar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/cotton/ui/transactions_action_bar.html b/app/templates/cotton/ui/transactions_action_bar.html index c7e9320..8ed9d06 100644 --- a/app/templates/cotton/ui/transactions_action_bar.html +++ b/app/templates/cotton/ui/transactions_action_bar.html @@ -60,11 +60,11 @@ _="on change from #transactions-list or htmx:afterSettle set total to 0.0 for amt in <.transaction:has(input[name='transactions']:checked) .main-amount .amount/> set amountValue to parseFloat(amt.getAttribute('data-amount')) - log amountValue if not isNaN(amountValue) - set total to total + amountValue + set total to (total * 100) + (amountValue * 100) end end + set total to total / 100 put total.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me end on click