Hide transfers in the transactions view by default
ci / lint-test (push) Successful in 51s

Transfers move money between your own accounts; at 433 of 3,996 rows
(~11%) they crowd out the rows that represent actual spending.

getTransactions gains `exclude_categories`, opt-in per caller and
deliberately not defaulted in queries.ts: the rules preview and the bulk
rule-apply path both read candidate rows through getTransactions, and a
default exclusion there would silently shrink what a rule can see and
reach — invisibly, since a rule that matches nothing looks the same as a
rule with nothing to do.

Two behaviours the filter needs, both tested:

- An explicit category pick beats the exclusion. Selecting "Transfers"
  while the default is on subtracts it from the hidden list instead of
  returning zero rows and reading as "you have no transfers".
- COALESCE the effective category to '' before `<> ALL`. NULL <> ALL(...)
  is NULL, not true, so an uncategorised row would disappear from a
  filter that never named its category — the trap EXCLUDE_NON_SPEND
  already documents.

The default is off when the view is scoped to a statement: that is a
reconciliation view, the row count has to match the statement, and a
credit-card payment is the row you went there to check.
This commit is contained in:
2026-07-30 23:34:31 +10:00
parent 549abd8cca
commit f6c500b27a
6 changed files with 141 additions and 1 deletions
+1
View File
@@ -14,6 +14,7 @@ export async function GET(req: NextRequest) {
from: sp.get("from") || undefined,
to: sp.get("to") || undefined,
categories: parseArr("categories"),
exclude_categories: parseArr("exclude_categories"),
bank_names: parseArr("bank_names"),
tag_ids: parseArr("tag_ids"),
transaction_types: parseArr("transaction_types"),
+39 -1
View File
@@ -518,6 +518,14 @@ function TransactionsContent() {
from: "",
to: "",
categories: [] as string[],
// Transfers move money between your own accounts — they are not spending,
// and at ~380 rows they crowd out everything that is. Hidden by default,
// with a visible toggle: a filter you cannot see is one you forget is on.
//
// Off when the view is scoped to a statement. That is a reconciliation
// view — the row count has to match the statement, and a credit-card
// payment is exactly the row you are there to check.
exclude_categories: (initialStatementId ? [] : ["transfers"]) as string[],
bank_names: [] as string[],
tag_ids: [] as string[],
transaction_types: [] as string[],
@@ -716,9 +724,39 @@ function TransactionsContent() {
<MultiSelect
options={CATEGORIES.map((c) => ({ value: c, label: formatCategory(c) }))}
value={filters.categories}
onChange={(v) => setFilters((f) => ({ ...f, categories: v, offset: 0 }))}
onChange={(v) =>
setFilters((f) => ({
...f,
categories: v,
// Asking for a category you are also hiding is a contradiction the
// server resolves in favour of the explicit pick; drop it here too
// so the toggle does not claim to be hiding what is on screen.
exclude_categories: f.exclude_categories.filter((c) => !v.includes(c)),
offset: 0,
}))
}
placeholder="All Categories"
/>
<label className="flex items-center gap-1.5 px-3 py-1.5 bg-zinc-900 border border-zinc-700 rounded text-sm text-zinc-300 cursor-pointer select-none">
<input
type="checkbox"
checked={filters.exclude_categories.includes("transfers")}
onChange={(e) =>
setFilters((f) => ({
...f,
exclude_categories: e.target.checked
? [...f.exclude_categories, "transfers"]
: f.exclude_categories.filter((c) => c !== "transfers"),
categories: e.target.checked
? f.categories.filter((c) => c !== "transfers")
: f.categories,
offset: 0,
}))
}
className="accent-indigo-500"
/>
Hide transfers
</label>
<MultiSelect
options={(banks ?? []).map((b) => ({ value: b, label: b }))}
value={filters.bank_names}