mirror of
https://github.com/we-promise/sure.git
synced 2026-04-12 16:47:22 +00:00
* Show inflow/outflow totals when filtering by transfers When filtering transactions by "Transfer" type, the summary bar previously showed $0 for both Income and Expenses because transfers were excluded from those sums. Now computes transfer inflow/outflow in the same SQL pass and switches labels to "Inflow"/"Outflow" when transfer amounts are non-zero. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add mixed filter comment and transfer-only test coverage Document the intentional mixed filter behavior where transfer amounts are excluded from the summary bar when non-transfer types are present. Add test exercising Inflow/Outflow label switching for transfer-only results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
2.1 KiB
Plaintext
40 lines
2.1 KiB
Plaintext
<%# locals: (totals:) %>
|
|
<%# Show Inflow/Outflow labels only when the result set contains exclusively transfers
|
|
(income and expense are both $0). For mixed filters (e.g. Expense+Transfer),
|
|
we keep Income/Expenses labels — transfer amounts aren't included in the summary
|
|
bar in that case, though the transaction list still shows both types. %>
|
|
<% show_transfers = totals.income_money.zero? && totals.expense_money.zero? &&
|
|
(totals.transfer_inflow_money.amount > 0 || totals.transfer_outflow_money.amount > 0) %>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 bg-container rounded-xl shadow-border-xs md:divide-x divide-y md:divide-y-0 divide-alpha-black-100 theme-dark:divide-alpha-white-200">
|
|
<div class="p-4 space-y-2">
|
|
<p class="text-sm text-secondary"><%= t("transactions.summary.total_transactions") %></p>
|
|
<p class="text-primary font-medium text-xl privacy-sensitive" id="total-transactions"><%= totals.count.round(0) %></p>
|
|
</div>
|
|
<div class="p-4 space-y-2">
|
|
<% if show_transfers %>
|
|
<p class="text-sm text-secondary"><%= t("transactions.summary.inflow") %></p>
|
|
<p class="text-primary font-medium text-xl privacy-sensitive" id="total-income">
|
|
<%= (totals.income_money + totals.transfer_inflow_money).format %>
|
|
</p>
|
|
<% else %>
|
|
<p class="text-sm text-secondary"><%= t("transactions.summary.income") %></p>
|
|
<p class="text-primary font-medium text-xl privacy-sensitive" id="total-income">
|
|
<%= totals.income_money.format %>
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
<div class="p-4 space-y-2">
|
|
<% if show_transfers %>
|
|
<p class="text-sm text-secondary"><%= t("transactions.summary.outflow") %></p>
|
|
<p class="text-primary font-medium text-xl privacy-sensitive" id="total-expense">
|
|
<%= (totals.expense_money + totals.transfer_outflow_money).format %>
|
|
</p>
|
|
<% else %>
|
|
<p class="text-sm text-secondary"><%= t("transactions.summary.expenses") %></p>
|
|
<p class="text-primary font-medium text-xl privacy-sensitive" id="total-expense">
|
|
<%= totals.expense_money.format %>
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
</div>
|