Fix format error in toggle-amount-mode: ensure double values for %f format

The format specifier $%,.2f requires floating-point values but
(reduce + 0 ...) can return a Long when all amounts sum to an integer.
Added explicit (double ...) casts and changed initial value to 0.0
to ensure the format call always receives a double.
This commit is contained in:
2026-05-21 09:14:20 -07:00
parent acd4184ef0
commit 918ddd14ff

View File

@@ -444,18 +444,18 @@
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"])
(com/data-grid-cell {:id "total"
:class "text-right"}
(format "$%,.2f" (reduce + 0 (map :transaction-account/amount accounts))))
(format "$%,.2f" (double (reduce + 0.0 (map :transaction-account/amount accounts)))))
(com/data-grid-cell {}))
(com/data-grid-row {}
(com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"])
(com/data-grid-cell {:id "total"
:class "text-right"}
(let [account-total (reduce + 0 (map :transaction-account/amount accounts))
(let [account-total (double (reduce + 0.0 (map :transaction-account/amount accounts)))
balance (- total account-total)]
[:span {:class (when-not (dollars= 0.0 balance)
"text-red-300")}
(format "$%,.2f" balance)]))
(format "$%,.2f" (double balance))]))
(com/data-grid-cell {}))
(com/data-grid-row {}
(com/data-grid-cell {})