From ce93e93231933de7d4dc84c0caed26f6b0d8cbeb Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 14:54:45 +0000 Subject: [PATCH] Fix a transaction that stops being a transfer getting Other or Income (v1.16.24) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ CLAUDE.md | 15 +++++++++++---- README.md | 6 +++--- index.html | 2 +- js/core.js | 39 ++++++++++++++++++++++----------------- js/views-main.js | 18 ++++++++---------- js/views-settings.js | 2 +- 7 files changed, 77 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8527ef7..ff2db9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,37 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.16.24] — 2026-11-02 + +### Fixed +- **A transaction that stopped being a transfer got the category Other or Income, not its own.** + - **Symptom:** add an "uber" keyword and remove it again, and the UBER TRIP card rows showed Other instead of Travel (their Category in the card's file). The AMAZON MKTPL return showed Income instead of Shopping, and T-MOBILE AUTOPAY showed Other instead of Bills & Utilities. With CREDIT CARD AUTOPAY set to Expense, the next keyword change made the card's Payment Thank You-Mobile an Income / refund with category Income, counted in Money in. A ZELLE row you gave Transfer out + Housing showed only Housing once "zelle" was removed. + - **It stayed wrong.** A reload from browser storage put the categories right, but finlens-state.json is saved after a keyword change, so a boot from it kept Other and Income. + - **Cause:** `reapplyTransferKeywords()` (`views-main.js`) put every 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 you set. + - **The bug is also on `master`.** Its **Re-apply to All Transactions** runs the same code. master's transactions don't record their CSV category or type, so this fix doesn't apply to it as is. + - **Fix:** `reapplyTransferKeywords()` puts each transfer back with `undoTransferDetection()`, which an import already uses for the transfers it keeps. + +### Details +- **What a transaction gets back:** its type: the one you set, else the CSV's (a card's Sale, Return or Payment; a bank's Withdrawal or Deposit). Its categories: the ones you set; else the category Re-categorize all gave it while it was a transfer; else the CSV's: the card file's own Category, otherwise the category the import worked out (your category rules first, then the built-in ones). That is what a reload from browser storage already showed. +- **`undoTransferDetection()` now takes the category Re-categorize all gave a transfer before the CSV's** (from v1.16.3 to v1.16.23 it took the CSV's). Re-categorize all gives every transaction without a category edit its rule's category, transfers included, so a transfer that stops being one now matches the others. Without Re-categorize all nothing changes. +- **ZELLE rows go back to the category Transfer.** The built-in category rules give ZELLE (and TRANSFER, ACH, VENMO, PAYPAL, COINBASE) the category Transfer, and the totals and the Transfers screen count that category as a transfer, whatever the type. So with "zelle" removed, the ZELLE rows are expenses with the category Transfer: they stay out of Spending and on the Transfers screen. That's what a reload already showed; before, they were Other, in Spending, until the next reload. To count them as spending, add a category rule (ZELLE → a category) and click **Re-categorize all**. +- **A category rule added after the import** reaches a transaction that stops being a transfer through Re-categorize all (above) or the next import, as for every other transaction. + +### Unchanged +- **Transactions an earlier version already put back wrong** keep Other or Income: they aren't transfers any more, so nothing puts them back. **Reload CSVs** (Settings → Import) or **Rebuild from your folder** gives them their CSV values again. +- **Without a keyword change nothing changes.** The import path (`mergeImported()`) gives the same result as before unless Re-categorize all ran. +- **A transaction from a finlens-state.json written by v1.16.0 or earlier** doesn't record its CSV values. As before, its IndexedDB row gives them; without a row its type goes by its sign and its category is worked out from its description. + +### Technical +- **`views-main.js`:** `reapplyTransferKeywords()` calls `undoTransferDetection()` for each transaction, then `detectTransfers()`. +- **`core.js`:** `undoTransferDetection()` takes the type and the categories separately: the type from the edit, `_originalType`, the row, then the sign; the categories from the edit, the categories besides Transfer out / in, `_originalCategories`, the row, then `autoCategory()`. + +### Docs +- **CLAUDE.md** — §1 version; §8 `undoTransferDetection()`; §11 a transfer that stops being one, the built-in Transfer category; §11.1 a card payment that stops being a transfer. +- **README.md** — Transfers: a transaction that stops being a transfer gets its own type and category back. + +--- + ## [1.16.23] — 2026-11-02 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index d401121..7cd8fd6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,7 +59,7 @@ Until then, this section is the rule. FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance dashboard** that runs entirely in the browser. There is no server, no npm, no bundler, no framework, and no TypeScript. The entry point is `index.html`; everything else is a plain `.js` file in the `js/` folder. -**Current version:** v1.16.23 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.16.24 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). **What it does:** Imports CSV exports from a bank (checking + savings) and credit cards, parses and normalizes them into a unified transaction model, and renders a multi-tab financial dashboard with budgeting, debt tracking, savings forecasting, investment planning, and Claude-powered AI analysis. @@ -621,6 +621,7 @@ reloadFromDirHandle(handle, opts?) // (views-data.js) the folder's CSVs → load mergeImported(loaded, fresh) // loaded + the files' transactions by id, leftover copies out, kept transfers undetected (v1.16.3); // one transaction per id, the first file's when two files give it (v1.16.19) undoTransferDetection(t, row?) // a detected transfer back to its CSV type and category, with its edit, before detectTransfers() + // (mergeImported(), reapplyTransferKeywords() since v1.16.24; §11 has the order it takes them in) accountFiles(a) // the CSV names an account came from: a.files, else [a.sourceFile] (saved before v1.16.17) earlierCopies(read) // (v1.16.17) loaded rows a re-read file gave under another account → Map(old id → { id, from, file }); reads only moveEarlierCopies(moves, read, fresh) // removes them (memory, IndexedDB), moves their edits to the new ids, drops accounts left empty @@ -809,7 +810,13 @@ The account id comes last on purpose: `migrate.js` relies on it to rename accoun **Both legs of a transfer are kept.** There is no deduplication. The `Transfers` view pairs them visually. -**Transfer keywords** are edited on the Transfers screen. Adding or removing one re-runs detection right away (`addTransferKeyword()` / `removeTransferKeyword()` → `reapplyTransferKeywords()`, which puts transfers without a stored `type` back to income/expense and calls `detectTransfers()`). The drawer stores a type only when the user changes it (§4.1), so a transaction saved for its note or category still follows the keywords. There's no separate Re-apply button any more (v1.14.0). +**Transfer keywords** are edited on the Transfers screen. Adding or removing one re-runs detection right away (`addTransferKeyword()` / `removeTransferKeyword()` → `reapplyTransferKeywords()`, which puts every transfer without a stored Transfer type back as `undoTransferDetection()` does and calls `detectTransfers()`). The drawer stores a type only when the user changes it (§4.1), so a transaction saved for its note or category still follows the keywords. There's no separate Re-apply button any more (v1.14.0). + +**A transfer that stops being one (v1.16.24)** gets back what it was before detection, from `undoTransferDetection()`. `loadFiles()` uses it for the transfers it keeps (§4.5), `reapplyTransferKeywords()` for every transfer before it runs detection again. Detection then marks again the ones that still match. +- **Type:** the stored `type`; else the CSV's (`_originalType`: a card's Sale, Return or Payment, a bank's Withdrawal or Deposit); else its IndexedDB row's; else debit or credit by sign. A stored Transfer type stays a transfer. +- **Categories:** the stored ones; else the ones it has besides `Transfer out` / `Transfer in` (on this version only Re-categorize all puts one there, `recategorizeAll()`); else the CSV's (`_originalCategories`: a card file's own Category, otherwise what the import's `autoCategory()` gave, category rules first); else the row's; else `autoCategory()` now. +- **Before v1.16.24** `reapplyTransferKeywords()` didn't use it: a transfer went back as debit or credit by sign, with `Other` or `Income` when it had no other category. A card Payment then counted as income, and the wrong category was saved to `finlens-state.json`. Rows saved that way keep it until their CSV is imported again (Reload CSVs, Rebuild from your folder). +- **The built-in rules give ZELLE, TRANSFER, ACH, VENMO, PAYPAL and COINBASE the category `Transfer`** (`DEFAULT_RULES`), and the sums and `transferPairs()` count that category as a transfer whatever the type. So a ZELLE row back from a transfer stays out of Spending and on the Transfers screen, as it did after a reload before. A category rule for them changes that, from the next import or Re-categorize all. **Pairs for display:** `transferPairs(txs)` (aggregation.js) pairs the two legs for the Transfers screen and the Overview's card footnotes. A leg with no partner has `to` (or `from`) = null: money that left (or came from) outside FinLens. @@ -819,7 +826,7 @@ The account id comes last on purpose: `migrate.js` relies on it to rename accoun `type='payment'` is set in `normalizeRow()` when `rawType` equals `"Payment"` (case-insensitive). This occurs on credit card uploads where a payment toward the card balance is recorded as a positive-amount transaction with `Type = "Payment"`. Payment transactions are **excluded from income sums** (`sumIncome()` filters them out) to avoid double-counting. They are distinct from `'credit'` (which represents purchase refunds/credits) and `'transfer'` (which represents inter-account moves). -A card payment that `detectTransfers()` pairs with the bank's autopay becomes `type='transfer'` (category `Transfer in`). `isCardPayment(t)` counts both kinds; the Transactions **Payments** pill and its KPIs use it (v1.14.0). +A card payment that `detectTransfers()` pairs with the bank's autopay becomes `type='transfer'` (category `Transfer in`). `isCardPayment(t)` counts both kinds; the Transactions **Payments** pill and its KPIs use it (v1.14.0). A card payment that stops being a transfer (its bank leg retyped, v1.16.23) goes back to `payment` with its CSV category (`undoTransferDetection()`, v1.16.24); before, a keyword change made it `credit` / `Income` and it counted as income. --- @@ -1095,7 +1102,7 @@ Multiple credit card files can be loaded simultaneously. Each gets a unique `acc --- -*Last updated: v1.16.23 — 2026-11-02 (transfer detection respects the user's type and categories: §1 version, §4.1 the drawers note, §11 the user's edit wins; v1.16.22: §13 the AI summary's trend stops at a past period's end, subscriptions labelled current; §21 the parser finds sections by their heading's start; v1.16.21: §8 `overrideBalanceAt()`, `balanceAt()`; §18 a card's amount owed is taken back plus the later transactions, a bank balance minus them; the sign of a card's balance; v1.16.20: §18 a balance override at the end of every range is the override less the later transactions, no 7-day exception; v1.16.19: overlapping exports of one account count each shared row once: §4.5 one transaction per id; §8 `mergeImported()`, `importParsedCsv()`; §10 overlapping exports of one account; §19 the leftover-copy check keeps the import's ids; v1.16.18: a JSON import's transaction edits show at once: §9 `applyImportedEdits()`; §20 what takes effect without a reload; v1.16.17: a file read into another account takes its rows with it: §4.3 the account's `files`, `accountFiles()`; §4.5 the exception to an import never dropping rows; §8 `accountFiles()`, `earlierCopies()`, `moveEarlierCopies()`; §10 Read as changes the ids; §19 `DB.removeTransactions()`, `DB.patchAccount()`; §22 `_rekey()` is also used by imports; v1.16.16: the transaction and transfer drawers store only the fields you change: §4.1 TxOverride, §11 transfer keywords, §12 state mutations; v1.16.15: §1 desktop only; §3 `views-database.js` removed, the Changelog view reads CHANGELOG.md; §6, §18, §19 point to the current screens; v1.16.14: §9 the drawer is a modal dialog: inert page, Tab wraps, first field focused, focus returns after a re-render; v1.16.13: account order: §4.1 `accountOrder` keeps ids not loaded; §8 `orderedAccounts()`; §18 display order; v1.16.12: account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)* +*Last updated: v1.16.24 — 2026-11-02 (a transfer that stops being one gets its own type and category back: §8 `undoTransferDetection()`, §11 un-transferring; v1.16.23: transfer detection respects the user's type and categories: §1 version, §4.1 the drawers note, §11 the user's edit wins; v1.16.22: §13 the AI summary's trend stops at a past period's end, subscriptions labelled current; §21 the parser finds sections by their heading's start; v1.16.21: §8 `overrideBalanceAt()`, `balanceAt()`; §18 a card's amount owed is taken back plus the later transactions, a bank balance minus them; the sign of a card's balance; v1.16.20: §18 a balance override at the end of every range is the override less the later transactions, no 7-day exception; v1.16.19: overlapping exports of one account count each shared row once: §4.5 one transaction per id; §8 `mergeImported()`, `importParsedCsv()`; §10 overlapping exports of one account; §19 the leftover-copy check keeps the import's ids; v1.16.18: a JSON import's transaction edits show at once: §9 `applyImportedEdits()`; §20 what takes effect without a reload; v1.16.17: a file read into another account takes its rows with it: §4.3 the account's `files`, `accountFiles()`; §4.5 the exception to an import never dropping rows; §8 `accountFiles()`, `earlierCopies()`, `moveEarlierCopies()`; §10 Read as changes the ids; §19 `DB.removeTransactions()`, `DB.patchAccount()`; §22 `_rekey()` is also used by imports; v1.16.16: the transaction and transfer drawers store only the fields you change: §4.1 TxOverride, §11 transfer keywords, §12 state mutations; v1.16.15: §1 desktop only; §3 `views-database.js` removed, the Changelog view reads CHANGELOG.md; §6, §18, §19 point to the current screens; v1.16.14: §9 the drawer is a modal dialog: inert page, Tab wraps, first field focused, focus returns after a re-render; v1.16.13: account order: §4.1 `accountOrder` keeps ids not loaded; §8 `orderedAccounts()`; §18 display order; v1.16.12: account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)* --- diff --git a/README.md b/README.md index be3d92e..94f0ffb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > A zero-install, browser-native finance dashboard. Drop in your bank CSVs, get instant clarity on your money. -**Version:** v1.16.23  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.16.24  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -119,7 +119,7 @@ Total income, average per month, interest earned and refunds. Income by source a Total spent, average per day, top category and highest month. Categories ranked by spend: pick one to see its transactions. A daily spending heatmap, the monthly trend, top merchants, and **category rules** (keyword → category). ### Transfers -Both legs of a transfer are paired automatically. A diagram shows where money moved between your accounts, and what left FinLens (e.g. Zelle payments). Filter the list by From and To account. **Transfer keywords** decide which unpaired transactions count as transfers; changing them re-runs detection right away. A type you set on a transaction wins: detection leaves that transaction alone, so one you set to Expense stays an expense and isn't paired. Categories you add to a detected transfer are kept. +Both legs of a transfer are paired automatically. A diagram shows where money moved between your accounts, and what left FinLens (e.g. Zelle payments). Filter the list by From and To account. **Transfer keywords** decide which unpaired transactions count as transfers; changing them re-runs detection right away. A type you set on a transaction wins: detection leaves that transaction alone, so one you set to Expense stays an expense and isn't paired. Categories you add to a detected transfer are kept. A transaction that stops being a transfer (say, you remove its keyword) gets its own type and category back: a card's Category and Sale, Return or Payment from its file, otherwise the category it was imported with (your category rules first, then the built-in ones). ### Budget Pick a month with ‹ and ›. Each category shows a progress bar, what you spent, its budget and what's left; the pencil changes the amount right in the row, and the name opens the full edit (name, categories, delete). Alerts flag categories over budget or at 90% and up. A chart compares 6 months of spending with the total budget. **Use starter budget** fills in a budget per category from what you usually spend (the average of up to 3 recent complete months, rounded up to $10) and never replaces one you have. @@ -263,4 +263,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.16.23 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.16.24 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index 588203d..16a1dbc 100644 --- a/index.html +++ b/index.html @@ -1202,7 +1202,7 @@
-
v1.16.23 · FinLens
+
v1.16.24 · FinLens
diff --git a/js/core.js b/js/core.js index 9c3d0aa..a77c07b 100644 --- a/js/core.js +++ b/js/core.js @@ -1015,27 +1015,32 @@ async function mergeImported(loaded, fresh) { return kept.concat(fresh); } -// Puts a transfer found by detectTransfers() back to what an import makes before detection -// (v1.16.3): its CSV type and category (_originalType, _originalCategories), with its edit. -// Detection only pairs transactions that aren't transfers yet, so a leg kept by -// mergeImported() must go back first or its partner, re-read from a file, stays unpaired. -// A type the user set to transfer stays. Without the CSV values (a transaction from a -// ≤v1.16.0 finlens-state.json), its IndexedDB `row` gives them; without a row, the type -// goes back to debit or credit by its sign and the category is worked out from the -// description, as Clear transaction edits does. Changes `t` in place, as detection does. +// Puts a transfer found by detectTransfers() back to what it was before detection (v1.16.3), +// with its edit. mergeImported() does it for the transfers an import keeps: detection only +// pairs transactions that aren't transfers yet, so a kept leg must go back first or its +// partner, re-read from a file, stays unpaired. reapplyTransferKeywords() does it for every +// transfer before detection runs again (v1.16.24), so one that no longer matches is itself again. +// A type the user set to transfer stays (detection leaves any other type the user set alone). +// - Type: the user's; else the CSV's (_originalType: a card's Sale, Return or Payment, a bank's +// Withdrawal or Deposit); else its IndexedDB `row`'s; else debit or credit by its sign. +// - Categories: the user's; else the ones it has besides Transfer out / Transfer in (Re-categorize +// all gives a transfer its rule's category too); else the CSV's (_originalCategories: a card +// file's own Category, otherwise the one the import worked out from the category rules and +// the built-in ones); else the row's; else worked out from the description now. +// Only a transaction from a ≤v1.16.0 finlens-state.json lacks the CSV values; without a row, +// its type and category are worked out as Clear transaction edits does. Changes `t` in place. function undoTransferDetection(t, row) { const ov = State.txOverrides[t.id] || {}; if (t.type !== 'transfer' || ov.type === 'transfer') return; - const has = (c, ty) => Array.isArray(c) && c.length > 0 && !!ty; - let cats = t._originalCategories, type = t._originalType; - if (!has(cats, type) && row) { cats = row.categories; type = row.type; } - if (!has(cats, type)) { - const keep = (t.categories || []).filter(c => c !== 'Transfer out' && c !== 'Transfer in'); - cats = keep.length ? keep : [autoCategory(t._originalDesc || t.description)]; - type = t.amount < 0 ? 'debit' : 'credit'; - } + const has = (c) => Array.isArray(c) && c.length > 0; + const keep = (t.categories || []).filter(c => c !== 'Transfer out' && c !== 'Transfer in'); + const cats = has(keep) ? keep + : has(t._originalCategories) ? t._originalCategories + : row && has(row.categories) ? row.categories + : [autoCategory(t._originalDesc || t.description)]; + const type = t._originalType || (row && row.type) || (t.amount < 0 ? 'debit' : 'credit'); t.type = ov.type || type; - t.categories = ov.categories && ov.categories.length ? [...ov.categories] : (ov.category ? [ov.category] : [...cats]); + t.categories = has(ov.categories) ? [...ov.categories] : (ov.category ? [ov.category] : [...cats]); } // A file's earlier rows under another account (v1.16.17, for loadFiles(), before anything is diff --git a/js/views-main.js b/js/views-main.js index ab6ac42..ebd6a1f 100644 --- a/js/views-main.js +++ b/js/views-main.js @@ -1424,17 +1424,15 @@ function removeTransferKeyword(i) { lsSet('transferKeywords',State.transferKeywords); reapplyTransferKeywords(); } -// Re-run transfer detection on every transaction. Transfers without a type set by the user -// go back to income/expense first, so a removed keyword stops counting. +// Re-run transfer detection on every transaction. Each transfer goes back first to what it +// was before detection, with its edit (undoTransferDetection(), core.js), so one that a removed +// keyword no longer matches is itself again: its CSV type and category, or the ones you set. +// A type you set to Transfer stays. Before v1.16.24 a transfer went back as a debit or credit +// by its sign, with Other or Income when it had no category besides Transfer out / in (the +// usual case): a card's Payment became Income / refund, its Travel or Shopping became Other, +// a checking row lost the category its rules gave it, and categories you set lost Transfer out / in. function reapplyTransferKeywords() { - for (const t of State.transactions) { - const ov=State.txOverrides[t.id]||{}; - if (!ov.type && t.type==='transfer') { - t.type=t.amount<0?'debit':'credit'; - const keep=t.categories.filter(c=>c!=='Transfer out'&&c!=='Transfer in'); - t.categories=keep.length?keep:[t.amount<0?'Other':'Income']; - } - } + for (const t of State.transactions) undoTransferDetection(t); detectTransfers(); renderActive(); } diff --git a/js/views-settings.js b/js/views-settings.js index ec37d3a..94da85f 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -67,7 +67,7 @@ function _renderGeneralSettings(root) { ``).join('')} -
VersionFinLens v1.16.23
+
VersionFinLens v1.16.24
`); const opts=$$('[data-theme-opt]',root); opts.forEach((b,i)=>{