Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.

Commit 6a33c00

Browse files
committed
[claudesquad] update from 'totals-rounding-and-sum' on 23 Jul 25 18:30 EDT
1 parent 32ec571 commit 6a33c00

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/models/transaction/search.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def totals
4747
Rails.cache.fetch("transaction_search_totals/#{cache_key_base}") do
4848
result = transactions_scope
4949
.select(
50-
"COALESCE(SUM(CASE WHEN entries.amount >= 0 THEN ABS(entries.amount * COALESCE(er.rate, 1)) ELSE 0 END), 0) as expense_total",
51-
"COALESCE(SUM(CASE WHEN entries.amount < 0 THEN ABS(entries.amount * COALESCE(er.rate, 1)) ELSE 0 END), 0) as income_total",
50+
"COALESCE(SUM(CASE WHEN entries.amount >= 0 AND transactions.kind NOT IN ('funds_movement', 'cc_payment') THEN ABS(entries.amount * COALESCE(er.rate, 1)) ELSE 0 END), 0) as expense_total",
51+
"COALESCE(SUM(CASE WHEN entries.amount < 0 AND transactions.kind NOT IN ('funds_movement', 'cc_payment') THEN ABS(entries.amount * COALESCE(er.rate, 1)) ELSE 0 END), 0) as income_total",
5252
"COUNT(entries.id) as transactions_count"
5353
)
5454
.joins(
@@ -61,8 +61,8 @@ def totals
6161

6262
Totals.new(
6363
count: result.transactions_count.to_i,
64-
income_money: Money.new(result.income_total.to_i, family.currency),
65-
expense_money: Money.new(result.expense_total.to_i, family.currency)
64+
income_money: Money.new(result.income_total.round, family.currency),
65+
expense_money: Money.new(result.expense_total.round, family.currency)
6666
)
6767
end
6868
end

0 commit comments

Comments
 (0)