Skip to content

v1.16.26: Fix a transaction changed away from Transfer still counting as a transfer - #49

Open
gitluis wants to merge 2 commits into
fix-recategorize-all-not-savedfrom
fix-retyped-transfer-still-counted
Open

gitluis wants to merge 2 commits into
fix-recategorize-all-not-savedfrom
fix-retyped-transfer-still-counted

Conversation

@gitluis

@gitluis gitluis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #48 (fix-recategorize-all-not-saved). Merge order: #16, #17, #19, #20, #21, #24–#38, #39–#50, then #10, then #23.
Depends on #47's undoTransferDetection() and reads #48's State.ruleCategories (the two are composed in this chain; see Testing).

Summary

A transaction you change from Transfer to Expense or Income now counts as spending or income straight away, everywhere. Before, a ZELLE transfer set to Expense stayed on the Transfers screen and out of Spending's categories. It kept the category Transfer out, and after a reload it dropped out of Spending's total too.

The type now decides whether a row is a transfer, not its category. A row changed away from Transfer gets its own category instead of Transfer out / Transfer in. Detection runs again at once, so the leg it was paired with updates too.

Cause

Three parts:

  • Totals went by category. sumIncome(), sumExpense(), sumTransfers(), byCategory(), byMonth(), detectRecurring(), transferPairs(), starterBudgetList() and the Income, Spending and Bills screens treated the categories Transfer, Transfer in and Transfer out as a transfer, whatever the type. Some helpers checked all three, some only Transfer. The built-in rules give ZELLE, TRANSFER, ACH, VENMO, PAYPAL and COINBASE the category Transfer.
  • The direction category stayed. The drawer and bulk Set type left Transfer out / Transfer in on a row changed away from Transfer. A reload from browser storage replaced it with the CSV's category. A boot from finlens-state.json kept it.
  • The partner wasn't updated. A type change didn't run detection. The leg the retyped row was paired with stayed a transfer until the next import, keyword change or reload. Example: set CREDIT CARD AUTOPAY to Expense, and the card's Payment Thank You-Mobile stayed a transfer (Transfer in).

master has the bug. I probed origin/master (v1.10.5) in a temporary worktree. In master's drawer I set the Sep 23 ZELLE row and the Oct 6 autopay to Expense:

  • Both kept Transfer out. Master stores it in the edit: { type: 'debit', categories: ['Transfer out'], … }.
  • Both stayed on master's Transfers tab. The card payment stayed a transfer.
  • sumExpense() rose by $861.91, but the category breakdown didn't move.
  • After a reload, master's detection makes both rows transfers again. That part is the v1.16.23 bug, already fixed on this chain.

What changed

  • Totals by type (aggregation.js, views-main.js). The eight helpers above and the Income, Spending and Bills screens test t.type === 'transfer' only. The Overview, Trends, Budget and the AI summary get this through the helpers.

  • The category Transfer is now a label. On a row that isn't a transfer, it counts as spending or income like any other category. My reasons:

    • One rule. The type is the field that says whether money moved between your accounts. Letting a category override it is what made the expense above half a transfer.
    • No change without edits. The built-in rules give Transfer only to descriptions that also contain one of the built-in keywords. With the default keywords, every such row is already a transfer by type.
    • Options I rejected:
      • Making the category set the type. That changes a field you didn't touch.
      • Keeping the category out of the totals. That overrides the type you set, which is the bug.
    • Behavior change. The category Transfer from a category rule or a card file's Category column no longer hides a row. A transfer keyword or the Transfer type does.
  • A row's own category: ownCategories() (core.js). It takes the first of these, each without Transfer out / Transfer in:

    1. The categories you set.
    2. Re-categorize all's saved category (State.ruleCategories; skipped when that key doesn't exist).
    3. The categories it has now.
    4. The CSV's category, else the IndexedDB row's.
    5. autoCategory(), else Other.

    For the ZELLE and ONLINE TRANSFER rows, that's Transfer.

  • Drawer and bulk Set type. Changing the type away from Transfer:

    • takes Transfer out / Transfer in off the categories you chose, or off the edit's when you changed only the type;
    • deletes an edit's categories when nothing is left, so the row keeps following the rules;
    • then calls redetectTransfers(), which is the pass a keyword change already ran (reapplyTransferKeywords() now calls it).

    Changing a row to Transfer works as before.

  • Transfer out / in show only on transfers. undoTransferDetection(), mkTx() and reconstituteTx() use ownCategories() for a non-transfer whose categories hold a direction. That covers:

    • a keyword removed from a transfer you gave extra categories;
    • edits saved by master's drawer;
    • finlens-state.json entries saved by the old code.

    The edit keeps the direction, so detection puts it back if the row becomes a transfer again.

  • Behavior change from v1.16.24. A ZELLE transfer you gave Transfer out + Housing shows Housing once "zelle" is removed. v1.16.24 showed both. Under the type rule, Transfer out would have become a spending category holding half the amount.

  • Version: v1.16.26 in CHANGELOG, footer, README, Settings and CLAUDE.md §1.

  • Docs: CLAUDE.md §4.1, §8, §11, §11.1, §13 and "Last updated"; README Transfers.

AI Eval

  • Unchanged. With no edits, the samples give the same numbers in every total and screen, and the same AI summary.
  • Eval sandbox summary. AIEval.loadSamples() → dataset.summary is byte-identical to d98069a's: 941 characters, sha256 df5557eab27fcfeb… on both. Checked in test-retype-transfer.js (section N).
  • All-time summary. Byte-identical to d98069a's too (sha256 f2d6875b8675ae3d…).
  • Request bodies. test-insights.js passes: each quick analysis and your own question send the same body, headers and URL as the baseline.
  • No re-run needed. The request doesn't change, so EVAL.md stays as it is. The real Anthropic API was never called; fetch was stubbed.
  • Sandbox keys (§21). mkTx() now calls ownCategories(), which can read State.ruleCategories, but only when an edit holds a direction. The sandbox has no edits. Once v1.16.25 is chained, its sandbox has ruleCategories: {} too.

Not verified

  • Real data: only the synthetic samples (257 rows). Not tried on real CSVs, or on category rules or card Category values that give Transfer to rows without a keyword (the behavior change above).
  • Composition with v1.16.25 (1710fdd): checked only by setting State.ruleCategories by hand (section X). Not run with 1710fdd's code.
  • Speed: redetectTransfers() now runs after every type change. It's the same pass a keyword change runs; I didn't time it on a large dataset.
  • Browsers: headless Chromium only. Not Safari or Firefox; desktop only, as decided.
  • master: probed, not fixed.
Automated checks: earlier run, not re-run · 3c9add8

Moved unchanged from this PR's "Test results" comment on 2026-11-04; not re-run, so not in the new table format. Originally a description section titled "How it was tested".

Light checks, by Luis's call to save usage: on this branch's final commit 3c9add8 (chained on #48) only boot.js, race.js and this PR's own tests ran. Headless Chromium at 1280×900 against samples/, with the pinned CDN libraries served from npm; each script ran as NODE_PATH=$(npm root -g) node <script> <repo> <outdir>.

Script Result on 3c9add8
boot.js 257 transactions, 24 views, 0 errors
race.js 24 views, 0 errors
test-retype-transfer.js (new in this PR) 135/135
test-finances.js (edited again in this PR) 126/126
test-clear-edits.js (edited again in this PR) 48/48
test-untransfer-category.js (#47's, edited in this PR) 27/27
test-recategorize.js (from #48) 55/55

Full set, once, on the top of the stack (#23, 819e809: every PR below it merged in): every base suite and every fix test from #24 to #50, plus #10's and #23's, each in its final variant. All pass: test-clarity.js 55/55, test-insights.js 137/137, test-finances.js 126/126, test-plan.js 127/127, boot.js 257 transactions and 0 errors, race.js 0 errors; #24–#38's tests (clear-edits 48/48, rebuild-folder 57/57, partial-import 47/47, json-import 28/28, new-browser-copy 10/10, json-export 31/31, plan-links 60/60, rule-flags 67/67, drawer-flags 36/36, start-balance 193/193, ai-summary-period 78/78, account-names 40/40, account-order 32/32, drawer-focus 167/167, cleanup 21/21); #39–#50's tests (drawer-fields 45/45, read-as 52/52, json-import-edits 29/29, overlapping-exports 46/46, override-balance 160/160, card-override 277/277, ai-summary-trend 91/91, transfer-user-type 39/39, untransfer-category 27/27, recategorize 55/55, retype-transfer 135/135, minor-fixes 34/34); test-dbtab.js 73/73, test-save-status.js 64/64, test-master-port.js 16/16. Three scripts needed a test-only change on that run, listed in #23 and in the PRs they belong to; the app code wasn't changed.

Measured before the chain

The numbers below are the PR author's, on the commit before it was chained (built on the old #38 tip ecfcab2, v1.16.15, or on the fix below it there; version numbers renumbered to the chain's).

Headless Chromium against samples/, desktop viewport, one suite at a time. Before = d98069a; after = this commit (f7b83c8).

Suite Before (d98069a) After (f7b83c8)
test-clarity 55/55 55/55
test-insights 137/137 137/137
test-finances (edited, see below) 126/126 126/126
test-plan 127/127 127/127
boot 257 transactions, 0 errors 257 transactions, 0 errors
race 6 errors, all renderImportLog 6 errors, all renderImportLog
test-clear-edits (edited, see below) 48/48 48/48
test-rebuild-folder 57/57 57/57
test-partial-import 47/47 47/47
test-json-import 28/28 28/28
test-new-browser-copy 10/10 10/10
test-json-export 31/31 31/31
test-plan-links 60/60 60/60
test-rule-flags 67/67 67/67
test-drawer-flags 36/36 36/36
test-start-balance 193/193 193/193
test-ai-summary-period 78/78 78/78
test-account-names 40/40 40/40
test-account-order 32/32 32/32
test-drawer-focus 167/167 167/167
test-cleanup 21/21 21/21
test-drawer-fields 45/45 45/45
test-transfer-user-type (parent 36d0095) 39/39 39/39 (16/16 [bug] checks fail on 36d0095)
test-untransfer-category (parent ed1d2a4, edited) 27/27 27/27 (10/10 [bug] checks fail on ed1d2a4)
test-retype-transfer (new, parent d98069a) — 135/135

run-tip.sh 15 ran every suite from test-clarity to test-cleanup. The race errors are the known Import Logs race (#18 isn't merged into this chain); none of them come from this change.

New: test-retype-transfer.js. It runs on this branch, then on a temporary worktree of d98069a (removed afterwards). Checks marked [bug] must fail there.

  • N (no edits):

    • every number on the screens: totals, categories, months, pairs, recurring charges, starter budget, savings pace, the AI summary;
    • every row, and the text of 13 screens;
    • the eval sandbox summary.

    Each is the same as on d98069a after an import, a keyword change, a reload and a boot from finlens-state.json.

  • A, B, C:

    • A: a ZELLE row set to Expense in the drawer.
    • B: bulk Set type → Expense on a ZELLE row and the $525 checking leg.
    • C: Income on the $500 savings leg.

    Checked in memory, after a reload, and after a file boot from a file saved before and after the reload:

    • each row's own category;
    • Spending's total and categories, Income;
    • the cash flow;
    • the Transfers screen, with the partners now one-sided;
    • the starter budget, the AI summary;
    • the Spending, Income, Transfers and Transactions screens' KPIs.
  • D: all four set back to Transfer. Every number returns to the base.

  • P: the autopay set to Expense. The card payment is its CSV Payment at once, still a card payment, not income. Same after a reload and both file boots.

  • K: Transfer out + Housing, then "zelle" removed. The row shows Housing; the other ZELLE rows count in Spending. "zelle" re-added gives Transfer out + Housing back.

  • G: an edit as master's drawer saved it, and a finlens-state.json record left with Transfer out. Both show the row's own category.

  • H: the category Transfer on an UBER TRIP charge. It counts in Spending under Transfer and stays off the Transfers screen.

  • X (branch only): with State.ruleCategories set by hand, a retyped ZELLE row and a keyword-removed one get the saved category.

Result: 135/135 on this branch. On d98069a 59/126 pass: all 67 [bug] checks fail (the bug) and no other check fails.

Suites I edited (my copies), because a check legitimately changes:

  • test-finances.js: "Keywords: removing one re-runs detection". With "zelle" removed, Spending now rises by the ZELLE amounts. Before: 125/126 on this branch; after the edit: 126/126.
  • test-clear-edits.js: sections 1 and 2, "before — the edits show". The drawer now re-runs detection, so the card payment typed Income unpairs CREDIT CARD AUTOPAY at once. Section 5 already expected this after a rebuild. Before: 46/48; after: 48/48.
  • test-untransfer-category.js: check D. The ZELLE row with Transfer out + Housing shows Housing once "zelle" is removed; its edit keeps both. Before: 26/27; after: 27/27, with 10/10 [bug] checks still failing on ed1d2a4.

The unedited copies are kept next to them as *.v1623.js.

How to reproduce the bug

Run this on the base branch, fix-recategorize-all-not-saved. Master has the bug too.

  1. Do the Setup from the testing steps below, but check out fix-recategorize-all-not-saved instead of fix-retyped-transfer-still-counted. Write down Total spent (Spending pill) and the Transfers tile and Sent outside FinLens (Transfers pill).
  2. On Transactions (pill All), search ZELLE and open the Sep 23 ZELLE TO M TORRES row (−$25.00).
  3. Change Type from Transfer to Expense. Leave Category alone and click Save changes.
  4. Look at the row's Category column.
  5. Click the Spending pill and read By category.
  6. Click the Transfers pill and look for the Sep 23 ZELLE row.

What goes wrong:

  • The row still shows Transfer out, though it's now an expense.
  • By category on Spending has no Transfer category with $25.00. The row is missing from the breakdown, and after a reload it drops out of Total spent too.
  • The Sep 23 ZELLE row is still listed on the Transfers screen.
Manual QA steps

Setup

  1. git checkout fix-retyped-transfer-still-counted.
  2. Copy the three CSVs from samples/ into a new scratch folder (e.g. C:\temp\finlens-49). This PR changes saved edits, so never use your real folder.
  3. Open index.html in Edge. Settings (gear) → Import → Pick a folder, choose the scratch folder, allow read and write access.
  4. In the top bar, set the date range to All time.
  5. Note these starting numbers (write them down):
    • Transactions → Spending pill: the Total spent tile.
    • Transactions → Transfers pill: the Transfers tile (count and "paired · one-sided") and Sent outside FinLens.

Rows used below (checking account): ZELLE TO M TORRES on Sep 23 (−$25.00, a one-sided transfer by the "zelle" keyword) and CREDIT CARD AUTOPAY on Oct 6 (−$836.91, paired with the card's Payment Thank You-Mobile of +$836.91).

1. A ZELLE transfer set to Expense counts as spending at once

  1. Go to Transactions (pill All), type ZELLE in Search description or notes.
  2. Click the Sep 23 ZELLE TO M TORRES row to open the drawer.
  3. Change Type from Transfer to Expense. Leave Category alone.
  4. Click Save changes.
  5. Look at the row's Category column.
  6. Click the Spending pill.
  7. Click the Transfers pill.

Expected:

  • The row's category is Transfer (its own category), not Transfer out.
  • Total spent is $25.00 higher than the starting number.
  • By category on Spending now lists a Transfer category with $25.00.
  • On Transfers, the count is one lower and Sent outside FinLens is $25.00 lower; the Sep 23 ZELLE row is gone from the Transfers list.

Before this fix: the row kept Transfer out, stayed on the Transfers screen, and was missing from By category (and after a reload from Spending's total too).

2. Retyping one leg of a pair updates the other leg right away

  1. On Transactions, search CREDIT CARD AUTOPAY. Open the Oct 6 row (−$836.91).
  2. Set Type to Expense. Click Save changes.
  3. Clear the search, then search Payment Thank You.
  4. Look at the Oct 6 row (+$836.91, credit card account).
  5. Click the Payments pill.
  6. Click the Transfers pill.

Expected:

  • The autopay row shows Other (no rule matches it), not Transfer out, and counts in Spending's Total spent (+$836.91 vs. test 1).
  • The card's Oct 6 Payment Thank You-Mobile is no longer a transfer: no Transfer in category. It appears on Payments as a card payment.
  • On Transfers, the Oct 6 checking → card pair is gone from the list; the "paired" count dropped by one.

Before this fix: the card payment stayed a transfer (Transfer in) until the next import, keyword change or reload.

3. Survives a reload, and a boot from finlens-state.json

  1. Press F5. Set All time if needed.
  2. Repeat the checks from tests 1 and 2 (ZELLE row category, Total spent, Transfers list).
  3. Wait 10 seconds (auto-save). Open an InPrivate window, open index.html, Settings → Import → Pick a folder, choose the same scratch folder.
  4. Set All time and repeat the same checks there. Close the InPrivate window.

Expected:

  • Same results in both: ZELLE Sep 23 and the Oct 6 autopay are expenses with their own categories, not on Transfers; Total spent the same as after test 2.
  • Optional, F12 → Application → IndexedDB → finlens_db → app_state → txOverrides: the two edits hold type: "debit" and no "Transfer out".

4. Bulk Set type does the same

  1. On Transactions, search ZELLE.
  2. Tick the checkboxes of two other ZELLE rows (e.g. Oct 16 and Aug 12).
  3. In the bar that appears, choose Expense in Set type…, click Apply type.

Expected:

  • Both rows show Transfer as category, not Transfer out.
  • Spending → Total spent rises by $100.00 ($60 + $40). They're gone from the Transfers list.

5. Setting a row back to Transfer

  1. Open the Sep 23 ZELLE row again. Set Type to Transfer. Save changes.
  2. Open the Oct 6 CREDIT CARD AUTOPAY row. Set Type to Transfer. Save changes.
  3. Search Payment Thank You and check the Oct 6 card row.

Expected:

  • ZELLE Sep 23 shows Transfer out, is back on Transfers, and Total spent drops by $25.00.
  • The autopay shows Transfer out and is a transfer again.
  • Known, unchanged (v1.16.23): the card's Payment Thank You-Mobile stays a card payment and isn't re-paired with it, because a leg you set to Transfer yourself isn't paired by detection.

6. Edge case: a transfer with an extra category, retyped

  1. Open the Oct 16 ZELLE row (set to Expense in test 4). Set Type to Transfer, Save changes.
  2. Open it again. Open Also count it under other categories and tick Housing. Save changes. The row shows Transfer out and Housing.
  3. Open it again, set Type to Expense, Save changes.

Expected:

  • The row shows only Housing (Transfer out removed), and Spending's By category has it under Housing.

7. Regression: no edits, same numbers as the base

  1. Go to Settings → Data & reset → Clean up → Clear transaction edits → Clear, click again to confirm.
  2. Compare Spending → Total spent and the Transfers tiles with the numbers from Setup.
  3. Open Overview and Trends and scan for errors (F12 → Console tab: no red errors).

Expected:

  • Total spent and the Transfers tiles match the Setup numbers exactly.
  • All ZELLE and ONLINE TRANSFER rows show Transfer out / Transfer in again.

8. Regression: removing a transfer keyword still works

  1. Transfers → Transfer keywords, click × on zelle.
  2. Search ZELLE on Transactions.
  3. Add zelle back with Add keyword → Add.

Expected:

  • After removal, the ZELLE rows show Transfer (category) with type Expense and count in Spending; after adding it back they're Transfer out and gone from Spending.

Please check before merging

  • The decision that the category Transfer is a label. Rows that a category rule, or a card file's Category, gives Transfer without a keyword now count as spending or income.
  • The change from v1.16.24: Transfer out + Housing shows Housing on a row that stops being a transfer.
  • Chaining after 1710fdd. Expect conflicts:
    • mkTx() and reconstituteTx(): keep 1710fdd's category order, then this commit's direction check. In reconstituteTx(), pass its ruleCats on: ownCategories(tx, ov, undefined, ruleCats).
    • undoTransferDetection(): this commit's version. 1710fdd doesn't touch it, and ownCategories() already takes State.ruleCategories after your own categories, which matches 1710fdd's order.
  • Known and unchanged: a leg you set to Transfer yourself isn't paired by detection (v1.16.23). Set the autopay to Expense and back to Transfer, and the card payment stays a card payment. That already happened at the next reload; it now shows at once.
  • Manual QA passed in Edge/Chrome with a real folder

https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft


Generated by Claude Code

…sfer (v1.16.26)

A ZELLE transfer set to Expense (drawer or bulk Set type) stayed on the
Transfers screen and out of Spending's categories, kept the category
Transfer out, and after a reload dropped out of Spending's total too.
Three causes:

- The totals went by category: sumIncome(), sumExpense(), sumTransfers(),
  byCategory(), byMonth(), detectRecurring(), transferPairs(),
  starterBudgetList() and the Income, Spending and Bills screens counted
  the categories Transfer / Transfer in / Transfer out as a transfer
  whatever the type. The built-in rules give ZELLE, TRANSFER, ACH, VENMO,
  PAYPAL and COINBASE the category Transfer.
- The drawer and bulk Set type left Transfer out / in on the row; a
  reload replaced it, finlens-state.json kept it.
- A type change didn't run detection, so the retyped leg's partner (the
  card's payment for CREDIT CARD AUTOPAY) stayed a transfer until the
  next import, keyword change or reload.

master has the same category checks, stores Transfer out in the edit of a
row set to Expense, and doesn't run detection on a type change.

The type now decides. The aggregation helpers and the three screens test
t.type only; the category Transfer is a label. A row that isn't a
transfer never shows Transfer out / in: ownCategories() (core.js) gives
its own category (the user's, Re-categorize all's saved one where
State.ruleCategories exists, the current ones, the CSV's, the row's,
autoCategory()). The drawer and bulk Set type take the direction off the
row and its edit and run redetectTransfers() after a type change;
undoTransferDetection(), mkTx() and reconstituteTx() use ownCategories()
for a non-transfer whose categories hold a direction. Changing a row to
Transfer works as before.

Without edits nothing changes: every number, screen and the AI summary
on the samples match d98069a, and the eval sandbox summary is
byte-identical.

Version bumped to v1.16.26 (CHANGELOG, footer, README, Settings,
CLAUDE.md); CLAUDE.md §4.1, §8, §11, §11.1, §13 and README Transfers updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…) into fix-retyped-transfer-still-counted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi

# Conflicts:
#	js/views-settings.js
@gitluis gitluis changed the title v1.16.26: fix a transaction changed away from Transfer still counting as a transfer v1.16.26: Fix a transaction changed away from Transfer still counting as a transfer Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants