From f4a3495bd6c03d61eaf98d3899d483d918ce503f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 14:06:37 +0000 Subject: [PATCH] Fix the edit drawer freezing a transaction's type and category when you change something else (v1.16.16) Saving the transaction drawer (showTxDrawer() in views-main.js) wrote the description, categories, type and notes into txOverrides on every save, changed or not. A stored type wins over the transfer keywords (reapplyTransferKeywords() doesn't reset it), and stored categories win over the category rules (Re-categorize all skips them, an import's mkTx() uses them). So a ZELLE transfer saved with only a note stayed a transfer when the "zelle" keyword was removed, and a row saved with only a note kept its category when a category rule and Re-categorize all changed the others. v1.16.9 fixed the same thing for the flags. The bug is also on master. The drawer now reads its fields back when it opens, and Save stores a field only if it was changed from that. Changing the type to Transfer still stores the direction category. A description changed back to the original, or an emptied note, is removed from the edit, and an edit left empty is removed. The transfer drawer stored both legs' description and notes on every save; it now stores only what changed, through the same storeChangedText(). Plan links and bulk edits are unchanged. Fields stored by earlier versions are not removed: they can't be told apart from deliberate edits. Clear transaction edits removes them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft --- CHANGELOG.md | 30 ++++++++++++++++++++++ CLAUDE.md | 13 +++++++--- README.md | 6 ++--- index.html | 2 +- js/views-main.js | 61 +++++++++++++++++++++++++++++++++----------- js/views-settings.js | 2 +- 6 files changed, 90 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56fe6b4..8fa11fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,36 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.16.16] — 2026-11-02 + +### Fixed +- **Saving the transaction drawer froze a transaction's type and category, even when you only changed something else.** + - **Symptom:** a ZELLE TO M TORRES transfer saved in the drawer with only a note stayed a transfer after you removed the "zelle" keyword. The other 5 ZELLE rows went back to expenses. A WALMART row saved with only a note kept its category when a WALMART category rule and **Re-categorize all** changed the others. + - **Cause:** the drawer's Save (`showTxDrawer()` in `views-main.js`) wrote the description, categories, type and notes into `txOverrides` every time, changed or not. A stored type wins over the transfer keywords: `reapplyTransferKeywords()` doesn't reset it. Stored categories win over the category rules: Re-categorize all (`recategorizeAll()`) skips them, and an import (`mkTx()`) uses them. v1.16.9 fixed the same thing for the three flags. + - **The bug is also on `master`.** Its drawer stores the same four fields on every save. + - **Fix:** the drawer reads its fields back when it opens. Save stores a field only if you changed it from that. A field you didn't touch stores nothing, and keeps following the keywords and rules, or keeps the edit already stored for it. +- **The transfer drawer stored both legs' description and notes on every save.** That froze nothing, since nothing else changes a description or a note, but every leg you saved became an edit. It now stores a leg's description or note only when you change it. + +### Details +- **Changing the type to Transfer** still stores its direction (Transfer out or Transfer in) as the category, when the categories don't have one. +- **A description changed back to the original, or a note emptied,** is removed from the edit instead of being stored: it shows the same as no edit. Emptying the description still brings back the original. +- **An edit with nothing left in it is removed,** as unlinking a plan item already did. Saving without changing anything stores nothing. + +### Unchanged +- **Your own edits still win.** A type, category, description or note you change is stored and beats the keywords and rules, as before. +- **Plan links** ("Link to a budget, bucket or debt") are stored as before. +- **Bulk Set category and Set type** already stored only the field they set. They aren't changed. +- **Edits stored by earlier versions stay.** A transaction saved in the drawer before v1.16.16 has all four fields stored and keeps them. FinLens can't tell them apart from fields you changed on purpose, so it doesn't remove them. **Clear transaction edits** (Settings → Data & reset) removes them, with your other edits. + +### Technical +- **`views-main.js`:** `showTxDrawer()` keeps its fields as they opened (`opened`) and stores only the changed ones. New `storeChangedText()` handles Description and Notes for it and for `showTransferDrawer()`. + +### Docs +- **CLAUDE.md** — §1 version; §4.1 the drawers store only what you change; §11 transfer keywords; §12 state mutations. +- **README.md** — Transactions: a type or category you leave alone keeps following the keywords and rules. + +--- + ## [1.16.15] — 2026-11-02 Housekeeping: dead code, the in-app changelog, and wording that pointed to screens that no longer exist. diff --git a/CLAUDE.md b/CLAUDE.md index 6b4445f..01dc108 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.15 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.16.16 (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. @@ -234,6 +234,11 @@ The optional fields live inside `bills`, so they're saved, loaded, exported and - **Links point at an item's `id`, never its position.** Up to v1.16.6 a link was `{ type, idx }`, so deleting an item left the links of the items after it pointing at the wrong one. `PLAN_LINK_TYPES` (core.js) maps a link type to its State key and id prefix. - **Read links through the helpers** (ui.js, §9): `planItem(type, id)` finds the item; `linkedTransactions(type, id)` lists its transactions. A link whose item is gone matches nothing, and the drawer shows it as None. - **Deleting an item removes the links to it** (`unlinkPlanItems(type, id)`, saved as `txOverrides`). So does clearing its list in Data & reset (§20). An edit left with nothing else in it is removed. +- **The drawers store only what the user changes (v1.16.16).** `showTxDrawer()` reads its fields back from the form when it opens. On save, a description, category list, type or note that differs from that is stored; an untouched one stores nothing. That matters because a stored `type` wins over the transfer keywords (`reapplyTransferKeywords()` doesn't reset it and `undoTransferDetection()` keeps it, §11), and stored `categories` win over the category rules (Re-categorize all, `recategorizeAll()`, skips them; an import's `mkTx()` uses them). The flags follow the same rule (§4.2); the link is stored as the drawer shows it. + - **Changing the type to Transfer** also stores its direction (`Transfer out` / `Transfer in`) as the category, when the categories don't have one. + - **A description changed back to the original, or a note emptied,** is removed from the edit: it would show the same as no edit. An edit left empty is removed, so a save that changes nothing stores nothing. + - **`showTransferDrawer()`** stores each leg's description and note the same way (`storeChangedText()`, shared with `showTxDrawer()`). Bulk edits store only the field they set. + - **Up to v1.16.15 every drawer save stored all four fields**, so a transfer saved for a note stopped following the keywords and a category stopped following the rules. Those edits are kept: they can't be told apart from deliberate ones. Clear transaction edits removes them. ### 4.2 The Transaction Model @@ -770,7 +775,7 @@ 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 unedited transfers back to income/expense and calls `detectTransfers()`). 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 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). **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. @@ -820,7 +825,7 @@ el.innerHTML = ``; - **Always** call `lsSet(key, value)` after mutating a State array or object — State is in-memory and not a proxy. - **Always** call `renderActive()` after mutations that should update the UI. - Do not mutate transaction `amount` or `date` — these are immutable source-of-truth values. -- Edits to transaction fields (description, categories, type, notes, flags) go into `State.txOverrides[tx.id]`. A flag goes in only when the user changes it (§4.2). +- Edits to transaction fields (description, categories, type, notes, flags) go into `State.txOverrides[tx.id]`. A field or flag goes in only when the user changes it (§4.1, §4.2). ### Adding a new persisted field @@ -1047,7 +1052,7 @@ Multiple credit card files can be loaded simultaneously. Each gets a unique `acc --- -*Last updated: v1.16.15 — 2026-11-02 (§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.16 — 2026-11-02 (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 60c1ca6..11f763b 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.15  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.16.16  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -107,7 +107,7 @@ FinLens stores all your data — budgets, bills, transaction edits, settings, AI Net worth with a trend chart (1M, 3M or all of your history) and the change since the end of last month. The latest month's money in, money out, net and savings rate, next to your 6-month average. A card per account with a balance sparkline (or, for a credit card, how much of the limit you're using). Six months of cash flow with the net for each month, bills due in the next three weeks, and the largest card purchases of the latest month. Double-click an account name to rename it; clear the name to go back to the default. ### Transactions -Filter pills across the top: **All**, **Income**, **Spending**, **Bills**, **Payments** and **Transfers**. All and Payments filter the list; the other four open their own screens. The list has search, a category filter, sorting, an amount filter, bulk edits and 50 rows per page. Click a transaction to edit its description, categories, type, notes and flags (Bill, Recurring, Subscription). Edits are kept separately from the imported row, so re-importing never overwrites them. **Transaction rules** flag matching transactions automatically (e.g. "NETFLIX → Subscription"). A flag you tick or untick yourself wins over the rules; one you leave alone keeps following them. **Payments** lists the payments made to your credit cards. +Filter pills across the top: **All**, **Income**, **Spending**, **Bills**, **Payments** and **Transfers**. All and Payments filter the list; the other four open their own screens. The list has search, a category filter, sorting, an amount filter, bulk edits and 50 rows per page. Click a transaction to edit its description, categories, type, notes and flags (Bill, Recurring, Subscription). Edits are kept separately from the imported row, so re-importing never overwrites them. Saving keeps only what you changed: a type or category you leave alone keeps following the transfer keywords and category rules. **Transaction rules** flag matching transactions automatically (e.g. "NETFLIX → Subscription"). A flag you tick or untick yourself wins over the rules; one you leave alone keeps following them. **Payments** lists the payments made to your credit cards. ### Income Total income, average per month, interest earned and refunds. Income by source as a stacked bar, monthly income (an unfinished month is shaded lighter), recurring deposits with their rhythm, next expected date and confidence, and every deposit. @@ -263,4 +263,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.16.15 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.16.16 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index 2834914..032791e 100644 --- a/index.html +++ b/index.html @@ -1202,7 +1202,7 @@
-
v1.16.15 · FinLens
+
v1.16.16 · FinLens
diff --git a/js/views-main.js b/js/views-main.js index 57582db..ab6ac42 100644 --- a/js/views-main.js +++ b/js/views-main.js @@ -792,6 +792,16 @@ function showTxDrawer(id) {

Edits are stored separately from the imported row, so re-importing the CSV never overwrites them.

`,{ title:'Transaction detail', footer:`` }); + // The fields as the form shows them on opening, read back from it. Saving stores a field + // only when it's changed from this, as the flags above (v1.16.16). An untouched type keeps + // following the transfer keywords and an untouched category the category rules, or each + // keeps an edit already stored (CLAUDE.md §4.1). Until v1.16.15 every save stored all four. + const fields=()=>{ + const primary=$('#dCat').value; + return { description:$('#dDesc').value, notes:$('#dNotes').value, type:$('#dType').value, + categories:[primary,...$$('.dCatCheck:checked').map(cb=>cb.value).filter(c=>c!==primary)] }; + }; + const opened=fields(); const lt=$('#dLinkType'); if (lt) lt.onchange=()=>{ const tgt=$('#dLinkTarget'); @@ -800,27 +810,47 @@ function showTxDrawer(id) { }; $('#dSave').onclick=()=>{ const o=State.txOverrides[t.id]||{}; - const primary=$('#dCat').value; - const more=$$('.dCatCheck:checked').map(cb=>cb.value).filter(c=>c!==primary); - o.description=$('#dDesc').value.trim()||t._originalDesc; - o.categories=[primary,...more]; - o.type=$('#dType').value; - // A transfer needs its direction as a category so the Transfers screen picks it up - if (o.type==='transfer'&&!o.categories.includes('Transfer in')&&!o.categories.includes('Transfer out')) o.categories=[t.amount<0?'Transfer out':'Transfer in']; - o.notes=$('#dNotes').value; + const now=fields(); + const same=(a,b)=>a.length===b.length&&a.every((c,i)=>c===b[i]); + storeChangedText(t,o,opened,now); + const typeChanged=now.type!==opened.type; + if (typeChanged) { o.type=now.type; t.type=now.type; } + let cats=now.categories; + // A transfer needs its direction as a category so the Transfers screen picks it up. + // Checked only when you change the type or the categories, so neither is stored unchanged. + if ((typeChanged||!same(cats,opened.categories))&&now.type==='transfer'&&!cats.includes('Transfer in')&&!cats.includes('Transfer out')) cats=[t.amount<0?'Transfer out':'Transfer in']; + if (!same(cats,opened.categories)) { o.categories=cats; t.categories=[...cats]; } for (const [key,box] of flagBoxes) { const v=$('#'+box).checked; if (v!==shown[key]) o[key]=v; } const linkType=lt?lt.value:''; const linkId=linkType?$('#dLinkTarget').value:''; if (linkType&&planItem(linkType,linkId)) o.link={ type:linkType, id:linkId }; else delete o.link; - State.txOverrides[t.id]=o; + // An edit with nothing left in it goes, as unlinkPlanItems() does. + if (Object.keys(o).length) State.txOverrides[t.id]=o; else delete State.txOverrides[t.id]; lsSet('txOverrides',State.txOverrides); - t.description=o.description; t.categories=o.categories; t.type=o.type; t.notes=o.notes; Object.assign(t, txFlags(t._originalDesc||t.description, o)); closeDrawer(); renderActive(); }; } +// The Description and Notes fields of the transaction and transfer drawers (v1.16.16). +// Stores each in edit `o` only when it's changed from what the field showed on opening +// (`was`), and updates `t` to match. An emptied description means the original one. A +// description changed back to the original, or a note emptied, is removed from the edit +// instead: it would show the same as no edit at all. +function storeChangedText(t, o, was, now) { + const desc=(v)=>v.trim()||t._originalDesc; + if (desc(now.description)!==desc(was.description)) { + const d=desc(now.description); + if (d===t._originalDesc) delete o.description; else o.description=d; + t.description=d; + } + if (now.notes!==was.notes) { + if (now.notes) o.notes=now.notes; else delete o.notes; + t.notes=now.notes; + } +} + /* =================== INCOME =================== */ let incomeShowAll=false; const SOURCE_HUES=['accent','warn','teal','pink','sky']; @@ -1362,14 +1392,15 @@ function showTransferDrawer(outId, inId) {

To change a leg's category or type, open it from the Transactions list.

`,{ title:'Transfer detail', footer:`` }); + // Each leg's fields on opening: Save stores only what's changed (v1.16.16). Until + // v1.16.15 it stored both legs' description and notes, so a leg you didn't touch became an edit. + const fields=(i)=>({ description:$(`#tdDesc_${i}`).value, notes:$(`#tdNotes_${i}`).value }); + const opened=txs.map((t,i)=>fields(i)); $('#tdSave').onclick=()=>{ txs.forEach((t,i)=>{ const ov=State.txOverrides[t.id]||{}; - ov.description=$(`#tdDesc_${i}`).value.trim()||t._originalDesc; - ov.notes=$(`#tdNotes_${i}`).value; - State.txOverrides[t.id]=ov; - t.description=ov.description; - t.notes=ov.notes; + storeChangedText(t,ov,opened[i],fields(i)); + if (Object.keys(ov).length) State.txOverrides[t.id]=ov; else delete State.txOverrides[t.id]; }); lsSet('txOverrides',State.txOverrides); closeDrawer(); renderActive(); diff --git a/js/views-settings.js b/js/views-settings.js index 5330204..2263264 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -67,7 +67,7 @@ function _renderGeneralSettings(root) { ``).join('')} -
VersionFinLens v1.16.15
+
VersionFinLens v1.16.16
`); const opts=$$('[data-theme-opt]',root); opts.forEach((b,i)=>{