Skip to content

v1.16.24: Fix a transaction that stops being a transfer getting Other or Income - #47

Open
gitluis wants to merge 2 commits into
fix-transfer-detection-user-typefrom
fix-untransfer-category
Open

gitluis wants to merge 2 commits into
fix-transfer-detection-user-typefrom
fix-untransfer-category

Conversation

@gitluis

@gitluis gitluis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #46 (fix-transfer-detection-user-type). Merge order: #16, #17, #19, #20, #21, #24–#38, #39–#50, then #10, then #23.
Uses earlier fixes' code: undoTransferDetection() (#26), the recorded CSV values _originalType / _originalCategories (#24), and #46's detection rule.

Summary

A transaction that stops being a transfer now gets its own type and category back. This happens when you remove the keyword that matched it, or when the leg it was paired with is retyped. Before, it became a debit or credit with the category Other or Income.

  • UBER TRIP card rows (after an "uber" keyword is added and removed) go back to Travel, the Category in the card's file, instead of Other.
  • The AMAZON MKTPL return goes back to Shopping, instead of Income.
  • T-MOBILE AUTOPAY goes back to Bills & Utilities, instead of Other.
  • The card's Payment Thank You-Mobile, after its autopay is set to Expense, is a card payment again. Before, it was Income / refund, counted in Money in.
  • Categories you set are kept whole: Transfer out + Housing stays Transfer out + Housing, not Housing alone.

Cause

  • reapplyTransferKeywords() (views-main.js) runs on every keyword change. It put each transfer without a stored type back as a debit or credit by its sign, with the categories it had besides Transfer out / Transfer in.
  • Usually there were none, so the transfer got Other (money out) or Income (money in).
  • It ignored the CSV's own values. Transactions record them in _originalType and _originalCategories since v1.16.1 (v1.16.1: Fix "Clear transaction edits" wiping every transaction when the browser database is empty #24).
  • It ignored the categories you set. It kept only the ones that weren't a transfer direction.
  • The wrong values were saved. A reload from browser storage put them right, but finlens-state.json is saved after the keyword change, so a boot from it kept Other and Income.
  • master has the bug. Its Re-apply to All Transactions runs the same reset code. A probe on a temporary worktree of origin/master (e8e18e7): an "uber" keyword added and removed turned UBER TRIP from debit:Travel into debit:Other. master's transactions don't record their CSV values, so this fix can't be applied to master as it is.
  • undoTransferDetection() (core.js, v1.16.3) didn't have the bug. An import uses it for the transfers it keeps, and it already restored _originalType / _originalCategories and the categories you set.

What changed

  • reapplyTransferKeywords() calls undoTransferDetection() for each transaction, then detectTransfers(). The keyword path and the import path now put transfers back the same way.
  • undoTransferDetection() works out the type and the categories separately:
    • Type: the one you set; else the CSV's (Sale → debit, Return → credit, Payment; Withdrawal / Deposit); else the IndexedDB row's; else by sign.
    • Categories: the ones you set; else the ones it has besides Transfer out / in; else the CSV's (_originalCategories: the card file's own Category, otherwise what the import's autoCategory() gave, category rules first); else the row's; else autoCategory().
  • One behaviour change in undoTransferDetection() (my call): it now takes "the ones it has besides Transfer out / in" before the CSV's category.
    • On this base, only Re-categorize all puts such a category there. recategorizeAll() overwrites every transaction without a category edit, transfers included.
    • Why: without this, adding a LIBERTY INTERNET → Health rule, clicking Re-categorize all, then removing a "liberty" keyword would give Housing (the import's category). The keyword code before this fix gave Health, and the other transactions show Health.
    • The import path only changes after Re-categorize all.
  • Docs:
    • Version: v1.16.24 in CHANGELOG, the index.html footer, README (badge and footer), Settings → General and CLAUDE.md §1.
    • CLAUDE.md: §8 (undoTransferDetection()), §11 (a new block on what a transfer that stops being one gets back, and the built-in Transfer category) and §11.1 (a card payment that stops being a transfer); "Last updated" line.
    • README: Transfers paragraph.

Not verified

  • Phone layouts: not checked (desktop only).
  • A real folder: not tested. The state-file boot uses a fake folder handle.
  • A ≤v1.16.0 finlens-state.json (no _originalType / _originalCategories) going through a keyword change: not tested. That path keeps the old fallback (IndexedDB row when there is one; else by sign and autoCategory()), and can't recover a card's own Category.
  • Not changed here:
    • Transactions an earlier version already put back as Other / Income in finlens-state.json keep those values: they aren't transfers any more, so nothing touches them. Reload CSVs or Rebuild from your folder gives them their CSV values again.
    • ZELLE (and TRANSFER, ACH, VENMO, PAYPAL, COINBASE) rows take the category Transfer from the built-in category rules. The totals and the Transfers screen treat that category as a transfer whatever the type. So removing the "zelle" keyword no longer moves ZELLE rows into Spending, as a reload already showed. A category rule (ZELLE → a category) plus Re-categorize all changes that.
    • Changing a transfer's type to Expense in the drawer keeps its Transfer out category until a reload from browser storage (a boot from finlens-state.json keeps it). The drawer doesn't un-transfer through this code.
Automated checks: earlier run, not re-run · ce93e93

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 ce93e93 (chained on #46) 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 ce93e93
boot.js 257 transactions, 24 views, 0 errors
race.js 24 views, 0 errors
test-untransfer-category.js (new in this PR) 27/27
test-finances.js (edited in this PR) 126/126

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.

  • test-untransfer-category.js also runs on the parent commit: 11/11 [bug] checks fail there, as expected.

  • No phone checks (desktop only).

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:

Suite v1.16.23 ed1d2a4 This branch d98069a
test-clarity 55/55 55/55
test-insights 137/137 137/137
test-finances 126/126 125/126 with the original suite, 126/126 with the edited one (below)
test-plan 127/127 127/127
boot 257 transactions, 0 errors 257 transactions, 0 errors
race 7 errors, all renderImportLog 6 errors, all renderImportLog
test-clear-edits (edited in the v1.16.23 PR) 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
  • 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-finances, one check changed: Keywords: removing one re-runs detection (Zelle becomes spending).
    • What it asserted: with "zelle" removed, Spending goes up.
    • Why that changes: that came from this bug. The ZELLE rows got Other until the next reload. Their own category is Transfer, from the built-in ZELLE → Transfer rule, and sumExpense() leaves that category out.
    • Now it checks: the ZELLE rows are debit:Transfer and Spending doesn't change, which is what a reload already showed.
    • Original suite: 125/126 here (the same on a rerun), 126/126 on ed1d2a4. Edited suite: 126/126 here, 125/126 on ed1d2a4 (debit:Other, Spending up by $230). The transfer counts in test-finances are unchanged.
  • test-drawer-fields.js (with the check added in the v1.16.23 PR): 45/45 here.
  • test-transfer-user-type.js (v1.16.23): 39/39 here. Its parent run (against 36d0095) still shows the v1.16.23 bug: 16/16 [bug] checks fail there.
  • New test-untransfer-category.js runs its checks on this branch, then on a temporary git worktree of ed1d2a4 (removed afterwards):
    • This branch: 27/27.
    • ed1d2a4: 16/27. All 11 checks marked [bug] fail there, and nothing else.
    • What it covers:
      • Card rows go back to their CSV Sale / Travel (UBER TRIP) and Shopping, including the Return as a credit (AMAZON MKTPL).
      • With CREDIT CARD AUTOPAY set to Expense, the card's payment is a Payment again, still counts as a card payment, and Money in is unchanged.
      • Checking rows go back to their built-in-rule category (T-MOBILE → Bills & Utilities) and to a category rule set before the import (LIBERTY INTERNET → Housing). Savings interest goes back to Income.
      • A category you set wins: bulk Personal on a T-MOBILE transfer, and Transfer out + Housing on a ZELLE transfer.
      • The other ZELLE rows go back to Transfer.
      • Re-categorize all while a transaction is a transfer: its category is kept when it stops being one.
      • The import path (undoTransferDetection() in mergeImported()) gives the CSV category.
      • After it all, every transaction is as imported, and a reload and a boot from finlens-state.json show the same.
How to reproduce the bug

Run this on the base branch, fix-transfer-detection-user-type. Master has the bug too.

  1. Do the Setup from the testing steps below, but check out fix-transfer-detection-user-type instead of fix-untransfer-category.
  2. On Transactions, click the Transfers pill. In Transfer keywords, type uber in Add keyword and click Add.
  3. Search UBER on Transactions. Every UBER row shows Transfer out.
  4. Go back to the Transfers pill and remove uber with its ×.
  5. Search UBER TRIP, then UBER EATS, and read the Category column.

What goes wrong: the UBER TRIP rows show Other, not Travel, and the UBER EATS rows show Other, not Food & Drink. They stay that way until a reload, and a boot from finlens-state.json keeps Other.

Manual QA steps

Setup

  1. git checkout fix-untransfer-category.
  2. Open an Edge InPrivate window (Ctrl+Shift+N) and open index.html from the repo.
  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. Keyword changes happen on Transactions → Transfers pill → Transfer keywords panel: type in Add keyword and click Add; remove one with its ×.
  5. To check a row: on Transactions (All pill), type its description in Search description or notes and read the Category column, or click the description and read Type and Category in Transaction detail.
  6. Starting numbers on Transactions: Money in +$32,524.88, Money out −$16,795.07.

1. Card rows get their own category back (UBER)

  1. Add keyword uber.
  2. Search UBER on Transactions: every UBER row shows Transfer out.
  3. Remove uber (its ×).
  4. Search UBER TRIP, then UBER EATS.
  5. Clear the search and read Money in / Money out.

Expected:

  • UBER TRIP rows: Travel, Type Expense.
  • UBER EATS rows: Food & Drink.
  • Money in +$32,524.88, Money out −$16,795.07.

Before this fix: both went to Other until a reload.

2. A card Return goes back to Shopping and stays a credit

  1. Add keyword amazon, then remove it.
  2. Search AMAZON MKTPL. Find the Jul 22 row of +$42.17 and open it.

Expected:

  • Type Income / refund, Category Shopping.
  • The other AMAZON MKTPL rows: Shopping.

Before this fix: the return got Income, the sales Other.

3. A checking row gets its rule category back

  1. Add keyword t-mobile, then remove it.
  2. Search T-MOBILE.

Expected:

  • Every T-MOBILE AUTOPAY row: Bills & Utilities.

Before this fix: Other.

4. A card payment stays a card payment when its partner is retyped

  1. Search CREDIT CARD AUTOPAY and open the Oct 6 row (−$836.91).
  2. Set Type to Expense and click Save changes.
  3. Add keyword xyz (any keyword: it re-runs detection).
  4. Search Payment Thank You and open the Oct 6 row (+$836.91).
  5. Read Money in on Transactions (search cleared), then click the Payments pill.

Expected:

  • Payment Thank You-Mobile: Type Card payment.
  • Money in +$32,524.88 (unchanged); Money out −$17,631.98 (the autopay now counts as spending).
  • Payments pill: "Showing 6 of 6 card payments".

Before this fix: Type Income / refund, Money in +$33,361.79, Payments listed 5.

5. Categories you set are kept whole

  1. Search ZELLE and open the Sep 23 row (−$25.00). Leave Type as Transfer.
  2. Click Also count it under other categories, tick Housing, and click Save changes.
  3. Remove the keyword zelle.
  4. Look at the Sep 23 row and the Oct 16 ZELLE row.
  5. Add zelle back and look again.

Expected:

  • After step 3: Sep 23 shows Transfer out and Housing, Type Expense. Oct 16 shows Transfer, Type Expense.
  • After step 5: both are transfers again; Sep 23 still shows Transfer out and Housing.

Before this fix: Sep 23 kept only Housing; the other ZELLE rows got Other and Money out jumped by about $230.

6. Re-categorize all while a row is a transfer

  1. Add keyword liberty. The LIBERTY INTERNET AUTOPAY rows become Transfer out.
  2. Click the Spending pill. In Category rules, type LIBERTY INTERNET in Description contains, choose Health in Category, click Add rule.
  3. Click Re-categorize all.
  4. Remove the keyword liberty.
  5. Search LIBERTY on Transactions.
  6. Press F5 and search again.

Expected:

Note: in the other order (rule and Re-categorize all first, then add and remove liberty), the rows come back as Bills & Utilities, the category from the import: detection replaced Health with Transfer out, so there's nothing besides it to keep.

7. Reload keeps it all

  1. Press F5.
  2. Check UBER TRIP (Travel), T-MOBILE AUTOPAY (Bills & Utilities), Payment Thank You-Mobile Oct 6 (Card payment), ZELLE Sep 23 (Transfer out, Housing).
  3. Read Money in / Money out and the Payments pill.

Expected:

  • All four as listed.
  • Money in +$32,524.88, Money out −$17,631.98, 6 card payments.

8. The state file keeps the right values

Use a copy of samples/ in a scratch folder for this one (it writes finlens-state.json).

  1. Close every InPrivate window. Open a new one and open index.html.
  2. Click Pick your CSV folder, choose the scratch folder and allow both prompts.
  3. Add keyword uber, then remove it.
  4. Wait about 10 seconds for the auto-save (hover the Synced badge: "last saved " should be just now).
  5. Press F5 (folder access lasts until the tab closes, so boot reads finlens-state.json). F12 → Console should say Boot: Loaded state from finlens-state.json.
  6. Search UBER TRIP.

Expected:

  • UBER TRIP rows: Travel.

Before this fix: Other: the file was saved after the keyword change, and a boot from it kept the wrong value.

9. Version

  1. Settings → General, read Version. Check the footer too.

Expected:

  • FinLens v1.16.24 in both places.

Please check before merging

  • ZELLE with "zelle" removed: you're OK with ZELLE rows staying out of Spending (category Transfer), now right away rather than only after a reload. If not, the built-in category rules or the totals need a separate change.
  • Re-categorize all: a transfer's Re-categorize all category is taken before its CSV category (undoTransferDetection()).
  • Composition with v1.16.25: Fix "Re-categorize all" changes being lost after a reload #48 (fix-recategorize-all-not-saved, v1.16.25), done in this chain by v1.16.26: Fix a transaction changed away from Transfer still counting as a transfer #49: that change stops recategorizeAll() writing a category onto detected transfers, and keeps the result in State.ruleCategories. Once both are in, undoTransferDetection() should take State.ruleCategories[t.id] at the "besides Transfer out / in" step, as mkTx() and reconstituteTx() do there. Otherwise a transfer that stops being one shows its import category until the next reload.
  • Suite edit: the test-finances "Zelle becomes spending" check (above).
  • Manual QA passed in Edge/Chrome with a real folder

https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft


Generated by Claude Code

… (v1.16.24)

reapplyTransferKeywords() (views-main.js), run on every keyword change, put
each transfer without a stored type back as a debit or credit by its sign,
with the categories it had besides Transfer out / Transfer in, or Other /
Income when it had none (the usual case). It used neither the CSV's type
and category (_originalType, _originalCategories, recorded since v1.16.1)
nor the categories the user set. So an "uber" keyword added and removed left
the UBER TRIP card rows as Other (their file says Travel), the AMAZON MKTPL
return as Income, T-MOBILE AUTOPAY as Other; a card's Payment whose autopay
leg was set to Expense became Income / refund and counted as income; and a
ZELLE row given Transfer out + Housing kept only Housing. A reload from
browser storage put them right, but finlens-state.json is saved after the
keyword change, so a boot from it kept them wrong. master's Re-apply to All
Transactions runs the same code.

- reapplyTransferKeywords() puts each transfer back with
  undoTransferDetection(), which the import already uses for kept transfers,
  then runs detectTransfers().
- undoTransferDetection() takes the type and the categories separately. Type:
  the edit's, _originalType, the IndexedDB row's, then by sign. Categories:
  the edit's; the ones besides Transfer out / in (what Re-categorize all
  gives a transfer); _originalCategories; the row's; then autoCategory().
  Taking Re-categorize all's category first is new; it keeps what the old
  keyword code kept in that case.
- ZELLE rows go back to their own category, Transfer (DEFAULT_RULES), which
  the sums count as a transfer: as a reload already showed.
- Version bumped to v1.16.24 (CHANGELOG, footer, README, Settings,
  CLAUDE.md); CLAUDE.md §8, §11 and §11.1, README Transfers updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
….0) into fix-untransfer-category

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.24: fix a transaction that stops being a transfer getting Other or Income v1.16.24: Fix a transaction that stops being a transfer getting Other or Income 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