Skip to content

v1.16.23: Fix transfer detection overriding a type or category you set - #46

Open
gitluis wants to merge 2 commits into
fix-ai-summary-trend-rangefrom
fix-transfer-detection-user-type
Open

gitluis wants to merge 2 commits into
fix-ai-summary-trend-rangefrom
fix-transfer-detection-user-type

Conversation

@gitluis

@gitluis gitluis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #45 (fix-ai-summary-trend-range). Merge order: #16, #17, #19, #20, #21, #24–#38, #39–#50, then #10, then #23.
Written on top of #39, whose drawer change made the category half of this bug show; the code doesn't call anything #39 added.

Summary

Transfer detection now respects your edit. A transaction whose type you set (Expense, Income / refund, Card payment, Transfer) keeps that type: detection doesn't mark it and doesn't pair it. Categories you set are kept when detection marks a transaction as a transfer.

Example: set a ZELLE TO M TORRES transfer to Expense. Before this fix it became a transfer again at the next keyword change, import or reload. Now it stays an expense.

Cause

  • detectTransfers() (core.js) ignored txOverrides. Both passes (pairs, then keywords) marked every match as a transfer and set its categories to Transfer out / Transfer in.
  • Every detection run did it: loadFiles() (every import), reapplyTransferKeywords() (every keyword change) and DB.loadAll() (a reload from browser storage).
  • Type half: a type you set to Expense or Income was overridden all along, also before v1.16.16, when the drawer stored the type with every save.
  • Category half: before v1.16.16, saving a detected transfer in the drawer also stored type Transfer, which kept detection away from it. Since v1.16.16 only the categories are stored, so detection replaced them at the next reload (Transfer out + Housing became Transfer out). Bulk Set category had the same problem before v1.16.16.
  • master has the bug. Its detectTransfers() is the same code. A probe on a temporary worktree of origin/master (e8e18e7): with a ZELLE row's edit set to { type: 'debit' } and another's to { categories: ['Transfer out', 'Housing'] }, Re-apply to All Transactions gave transfer:Transfer out for both.

What changed

  • detectTransfers() (core.js):
    • It leaves out a transaction whose edit has a type. That transaction isn't a candidate in either pass.
    • It marks through a new mark() helper. When the edit has categories (or an older single category), mark() keeps them. Otherwise it sets Transfer out / Transfer in as before.
  • No caller changed. loadFiles(), reapplyTransferKeywords(), DB.loadAll() and Clear transaction edits all get the fix through detectTransfers(). Clear transaction edits empties the edits before it runs detection, so its result is the same as before.
  • undoTransferDetection() is unchanged. It already kept a type you set.
  • The AI Eval is unchanged. Its sandbox has no edits, so its summary doesn't change.
  • Pairing (my call):
    • A leg you retype is left out, as if it weren't there. The leg it was paired with is checked on its own: it can pair with another transaction, become a one-sided transfer by keyword, or stay as imported.
    • Example: set CREDIT CARD AUTOPAY (Oct 6) to Expense. After a reload, the card's Payment Thank You-Mobile is a Payment again (its CSV type), not a transfer.
    • Why: keeping the pair would make the other leg a transfer because of a transaction you said isn't one.
  • Docs:
    • Version: v1.16.23 in CHANGELOG, the index.html footer, README (badge and footer), Settings → General and CLAUDE.md §1.
    • CLAUDE.md: §4.1 (a stored type and stored categories win over detection) and §11 (the user's edit wins over both passes); "Last updated" line.
    • README: Transfers paragraph.

Not verified

  • Phone layouts: not checked (desktop only).
  • A real folder and the File System Access API: not tested. The state-file boot uses a fake folder handle.
  • A transaction that pairs with a different partner once its first partner is retyped: the samples have no such case, so it isn't tested. That path is the existing pass 1 code.
  • Not changed here:
    • On this branch alone, a keyword change after you retype a paired leg puts its partner back as a debit or credit with Other or Income, until a reload. A card payment then becomes Income / refund and counts in Money in. That is the separate v1.16.24 bug (v1.16.24: Fix a transaction that stops being a transfer getting Other or Income #47) (reapplyTransferKeywords()), fixed in the next PR.
    • A retyped leg's partner doesn't change right away. It changes at the next detection run: a keyword change, an import, or a reload from browser storage. Changing a type in the drawer or with bulk Set type doesn't run detection (it didn't before either). A boot from finlens-state.json doesn't run it.
    • A ZELLE row set to Expense still counts as a transfer in places, through its category. The drawer leaves its category at Transfer out; a reload from browser storage shows Transfer, from the built-in ZELLE rule. transferPairs() (the Transfers screen) and byCategory() (Spending by category) treat Transfer, Transfer out and Transfer in as transfers whatever the type, and sumExpense() (Money out) treats Transfer that way. So the row stays on the Transfers screen, out of Spending by category, and after a reload out of Money out, until you also change its category. The test logs this as INFO.
Automated checks: earlier run, not re-run · 16bacf0

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 16bacf0 (chained on #45) 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 16bacf0
boot.js 257 transactions, 24 views, 0 errors
race.js 24 views, 0 errors
test-transfer-user-type.js (new in this PR) 39/39
test-drawer-fields.js (#39's, edited in this PR) 45/45
test-clear-edits.js (#24's, edited in this PR) 48/48

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 only, one suite at a time.

run-tip.sh 15 (base suites plus every fix test of #24–#38):

Suite Base 36d0095 This branch ed1d2a4
test-clarity 55/55 55/55
test-insights 137/137 137/137
test-finances 126/126 126/126
test-plan 127/127 127/127
boot 257 transactions, 0 errors 257 transactions, 0 errors
race 7 errors, all renderImportLog 7 errors, all renderImportLog
test-clear-edits 47/47 46/47 with the original suite, 48/48 with the edited one (below)
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
  • The race errors are expected noise. Every one is renderImportLog (v1.10.5: fix Import Logs throwing when the view is left before it loads #18's fix isn't in this stack yet). None comes from this change.
  • test-clear-edits, section 5 (Rebuild with edits):
    • Original suite: 46/47 on this branch, the same on a rerun. The suite edits the card's Payment Thank You-Mobile to Income / refund. After the rebuild, detection no longer pairs it, so its CREDIT CARD AUTOPAY leg becomes an expense: a sixth changed transaction, where the check expected five. That is the pairing change above.
    • Suite edit: the check now expects that sixth transaction, and a new check confirms the autopay is debit:Other (its CSV values).
    • Edited suite: 48/48 here, 46/48 on the base.
  • test-drawer-fields.js (from v1.16.16): on the base it logs this bug as an INFO line. That line is now a check: "zelle" added back: the row typed as Expense stays an expense. It passes 45/45 here and fails on the base (44/45).
  • New test-transfer-user-type.js runs its checks on this branch, then on a temporary git worktree of the base (removed afterwards):
    • This branch: 39/39.
    • Base: 19/35. All 16 checks marked [bug] fail there, and nothing else.
    • What it covers:
      • A ZELLE row set to Expense stays an expense across keyword changes, a re-import of the checking file, a reload, a boot from finlens-state.json, and a keyword change after that boot.
      • A paired leg retyped with bulk Set type, and the autopay retyped in the drawer: the card payment is a Payment again after a reload.
      • Transfer out + Housing on a detected transfer survives a keyword change, a reload, a boot from the file and a keyword change after it. Personal set with bulk Set category on a paired leg survives a reload, and the leg stays paired.
      • Without edits, every transaction's type and categories and every pair (30 transfers, 12 pairs) match the base after an import, a keyword change, a reload and a boot from the file.
How to reproduce the bug

Run this on the base branch, fix-ai-summary-trend-range. Master has the bug too.

  1. Do the Setup from the testing steps below, but check out fix-ai-summary-trend-range instead of fix-transfer-detection-user-type. Money out starts at −$16,795.07.
  2. On Transactions, search ZELLE TO M TORRES and open the row dated Oct 16 (−$60.00).
  3. In Transaction detail, set Type to Expense and click Save changes.
  4. Read Money out. It now reads −$16,855.07.
  5. Click the Transfers pill. Under Transfer keywords, type xyz in Add keyword and click Add.
  6. Go back to Transactions, read Money out, and open the Oct 16 ZELLE row again.

What goes wrong: the keyword change undoes your edit. The row's Type is Transfer again, and Money out goes back to −$16,795.07 instead of staying at −$16,855.07.

Manual QA steps

Setup

  1. git checkout fix-transfer-detection-user-type.
  2. Open an Edge InPrivate window (Ctrl+Shift+N) and open index.html from the repo. Without a folder, a reload comes back from IndexedDB, which runs transfer detection again. That is the path this PR fixes.
  3. On the welcome screen, click choose the files. Select the three CSVs in samples/ and click Import 3 files. The range is set to All time.
  4. To open a transaction: click Transactions, type its description in Search description or notes, and click the description on the row with the date given.
  5. Check the starting numbers on Transactions: Money out −$16,795.07. Click the Transfers pill: Transfers 18, "12 paired · 6 one-sided".

1. A ZELLE row set to Expense stays an expense after a keyword change

  1. Open ZELLE TO M TORRES dated Oct 16 (−$60.00).
  2. In Transaction detail, set Type to Expense and click Save changes.
  3. Read Money out on Transactions.
  4. Click the Transfers pill. Under Transfer keywords, type xyz in Add keyword and click Add.
  5. Go back to Transactions and read Money out. Open the Oct 16 ZELLE row again and read Type.

Expected:

  • After step 3: Money out −$16,855.07 (the $60 counts).
  • After step 5: still −$16,855.07; Type still Expense.

Before this fix: after the keyword change the row was a Transfer again and Money out went back to −$16,795.07.

2. The same after a reload

  1. Press F5.
  2. Open the Oct 16 ZELLE row and read Type and Category.
  3. Read Money out on Transactions.

Expected:

  • Type Expense, Category Transfer.
  • Money out −$16,795.07. This is a known leftover, listed in the PR: the built-in ZELLE rule gives category Transfer, and Money out leaves that category out.

Before this fix: Type was Transfer again.

3. A category added to a detected transfer survives a reload

  1. Open ZELLE TO M TORRES dated Sep 23 (−$25.00). Leave Type as Transfer.
  2. Click Also count it under other categories, tick Housing, and click Save changes.
  3. Check the row's Category column shows Transfer out and Housing.
  4. Press F5 and look at the row again.
  5. On the Transfers pill, add keyword xyz2, then go back and look at the row.

Expected:

  • After the reload and after the keyword change: Transfer out and Housing.

Before this fix: after the reload only Transfer out was left.

4. A retyped leg unpairs its partner at the next reload

  1. Open CREDIT CARD AUTOPAY dated Oct 6 (−$836.91).
  2. Set Type to Expense and click Save changes.
  3. Press F5.
  4. Click the Transfers pill and read the first tile.
  5. Search Payment Thank You on Transactions, open the Oct 6 row (+$836.91) and read Type.
  6. Read Money in and Money out on Transactions.

Expected:

  • Transfers 17, "11 paired · 6 one-sided".
  • Payment Thank You-Mobile (Oct 6): Type Card payment.
  • Money in +$32,524.88 (unchanged), Money out −$17,631.98 (the autopay now counts).
  • Payments pill still lists 6 card payments.

Before this fix: after the reload the autopay was a Transfer again: Transfers 18, Money out −$16,795.07.

5. Bulk Set type is respected too

  1. On Transactions, search ZELLE.
  2. Tick the checkbox on the Jul 13 row (−$40.00).
  3. In the bar that appears, choose Expense in Set type… and click Apply type.
  4. Clear the search. On the Transfers pill, add keyword xyz3.
  5. Open the Jul 13 ZELLE row and read Type.

Expected:

  • Type Expense.

Before this fix: Transfer.

6. Re-importing the file keeps the type

  1. Go to Settings → Import → Choose CSV files, pick samples/checking_sample.csv, click Import 1 file.
  2. Open the Oct 16 ZELLE row.

Expected:

  • Type Expense.

Before this fix: Transfer.

7. Regression: no edits, nothing changes

  1. Go to Settings → Data & reset. Next to Clear transaction edits click Clear, then Click again to confirm.
  2. Click the Transfers pill and read the first tile.
  3. Read Money out on Transactions. Open the Oct 16 ZELLE and Oct 6 autopay rows.

Expected:

  • Transfers 18, "12 paired · 6 one-sided".
  • Money out −$16,795.07.
  • Both rows: Type Transfer.

8. Known on this branch alone (fixed by #47)

  1. Open CREDIT CARD AUTOPAY (Oct 6) and set Type to Expense again. Save.
  2. On the Transfers pill, add keyword xyz4 (no reload).
  3. Open Payment Thank You-Mobile (Oct 6) and read Type.

Expected on this branch:

Please check before merging

  • The pairing choice: a retyped leg is left out, and its partner is checked on its own.
  • When the partner changes: at the next detection run, not right away. Re-running detection on a type change could be a follow-up, after the v1.16.24 fix (it relies on un-transferring correctly).
  • Old drawer edits: edits saved by v1.16.15 and earlier stored a type with every drawer save. Detection now keeps those types too (Expense and Income ones included). Clear transaction edits removes them.
  • ZELLE rows set to Expense: do you want them counted as spending without also changing their category? That needs a separate change (the drawer's category, or how the totals treat the Transfer categories).
  • Suite edits: test-drawer-fields (INFO line → check) and test-clear-edits (section 5).
  • Manual QA passed in Edge/Chrome with a real folder

https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft


Generated by Claude Code

detectTransfers() (core.js) marked every pair and every keyword match as a
transfer and set its categories to Transfer out / Transfer in, without looking
at txOverrides. Every import (loadFiles()), keyword change
(reapplyTransferKeywords()) and reload from browser storage (DB.loadAll()) runs
it. So a ZELLE transfer set to Expense became a transfer again at the next
keyword change, import or reload, and a category added to a detected transfer
(Transfer out + Housing, or bulk Set category) was replaced at the next
reload. Up to v1.16.15 the drawer stored the type with every save, which kept
a saved transfer out of detection's way and hid the category half; a saved
Expense or Income type was overridden all along. master has the same
detectTransfers().

- A transaction whose edit has a type is left out of detection: it isn't
  marked and isn't paired. The leg it would have paired with is checked on its
  own: another pair, a keyword (one-sided), or as imported.
- A transaction marked a transfer keeps the edit's categories (or an older
  single category); without them it still gets Transfer out / Transfer in.
- No caller changed. Without edits the samples give the same 30 transfers and
  12 pairs, every row the same.
- Version bumped to v1.16.23 (CHANGELOG, footer, README, Settings, CLAUDE.md);
  CLAUDE.md §4.1 and §11, README Transfers updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…to fix-transfer-detection-user-type

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.23: fix transfer detection overriding a type or category you set v1.16.23: Fix transfer detection overriding a type or category you set 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