From 5cb828b1556ab301b096be7a79ffe6010a031589 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 14:23:48 +0000 Subject: [PATCH] Fix the AI summary's monthly trend running past a past date range (v1.16.22) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildFinancialSummary() built "Recent monthly trend" from all transactions, whatever the range, and listed the subscriptions under a plain heading. On a past range (Last year, a custom range ending in August, Last month with transactions from this month) the model saw the latest three months, after the period it was asked about. v1.16.11 dated the balances on such ranges but left these two sections alone. - views-ai.js: when summaryBalanceEnd() gives a date, the trend lists up to three months of the transactions up to it, under "Recent monthly trend, up to the end of the period (Aug 15, 2026):". partialMonthNote() takes the end and marks its month "(through Aug 15)" unless the end is the month's last day. Fewer months when the data starts later; none when the range ends before the first transaction. - Subscriptions stay the current ones (all transactions, as on the Bills screen: what you'd cancel now). On a past range the heading says so: "Subscriptions (current, found in all transactions, not just the period):". - All time, This month and any range reaching the last transaction are byte-identical to v1.16.21. The AI Eval's sandbox uses All time, so its summary is byte-identical and the published results still hold. parseSummary() reads the new headings unchanged (it matches section headings by their start). - CHANGELOG; version in index.html, README and Settings -> General; README AI Analysis wording; CLAUDE.md §1, §13, §21 and Last updated. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft --- CHANGELOG.md | 16 ++++++++++++++++ CLAUDE.md | 11 ++++++++--- README.md | 6 +++--- index.html | 2 +- js/views-ai.js | 27 +++++++++++++++++++-------- js/views-settings.js | 2 +- 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 402ba13..7d391e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.16.22] — 2026-11-02 + +### AI Analysis +- **On a past date range, the summary's monthly trend stops at the end of the period.** Before, "Recent monthly trend" was always the latest three months of all your transactions. So on a past range (Last year, a custom range ending in August, or Last month when you have transactions from this month), the model saw months after the period it was asked about. + - **What went wrong:** `buildFinancialSummary()` (`views-ai.js`) built the trend from `byMonth(State.transactions)`, whatever the range. v1.16.11 dated the balances on a past range but left the trend and the subscriptions as they were. + - **Fix:** on a range that ends before the last transaction (`summaryBalanceEnd()`), the trend lists up to three months up to the range end, under "Recent monthly trend, up to the end of the period (Aug 15, 2026):". The month holding the end is marked "(through Aug 15)", unless the end is that month's last day: `partialMonthNote()` takes the end. There are fewer months when the data starts less than three months before the end, and none when the range ends before the first transaction. +- **Subscriptions stay the current ones, and on a past range the heading says so:** "Subscriptions (current, found in all transactions, not just the period):". + - **Why not as of the end of the period:** the list is what you'd cancel now ("Subscriptions to cancel"). Found as of a past date, it could list subscriptions you've already ended and miss new ones. It's the list the Bills screen shows, and the Debts heading on a past range already works this way (v1.16.11). +- **Unchanged:** All time, This month and every range that reaches the last transaction send the same summary as before, byte for byte. +- **The AI Eval's summary is unchanged.** Its sandbox always uses All time, so the published results still hold. `parseSummary()` reads the new headings without a change: it finds the sections by how their headings start (`Recent monthly`, `Subscriptions`). + +### Docs +- **README:** what the AI summary holds: the monthly trend up to the end of the dates on screen, and your current debts and subscriptions. + +--- + ## [1.16.21] — 2026-11-02 ### Overview and balances diff --git a/CLAUDE.md b/CLAUDE.md index c47dfbd..01dd284 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.21 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.16.22 (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. @@ -936,6 +936,11 @@ Views build a fresh DOM on every `showView()` call. This is intentional. Do not - **Null** (All time, This month, any range reaching the last transaction): `currentBalances()`, which equals `periodEndBalance()` there, and the summary is byte-identical to v1.16.10. - **A date:** each account's `periodEndBalance()`, with the date on both balance lines: "Accounts at the end of the period (Aug 15, 2026): …" and "… Net Worth: $10,602.37 (all on Aug 15, 2026)". The Debts heading becomes "Debts (current balances, not at the end of the period):". - **Why:** up to v1.16.10 the summary sent today's balances under a past period's "Period:" line, and the model read them as that period's. The eval sandbox always uses All time, so the eval's summary didn't change. + - **Trend and subscriptions on a past range (v1.16.22).** With `summaryBalanceEnd()` a date: + - **The trend** is the last three months of the transactions up to it, under "Recent monthly trend, up to the end of the period (Aug 15, 2026):". `partialMonthNote(m, txs, end)` marks the month holding the end "(through Aug 15)", unless the end is that month's last day. There are fewer months when the data starts later, and none when the period ends before the first transaction. + - **Subscriptions** stay the current ones (`detectRecurring()` on every transaction, as the Bills screen shows them), under "Subscriptions (current, found in all transactions, not just the period):". They're what you'd cancel now; found as of a past date, they'd include ones already ended. + - **Null:** both as before, so All time, This month and any range reaching the last transaction are byte-identical to v1.16.21. + - **Why:** up to v1.16.21 the trend was always the latest three months, so on a past range the model saw months after the period it was asked about. Without them the model guessed the period length (6, 6.5 or even 9 months) to work out monthly figures, so the same data gave different answers. Never send totals without the dates they cover. - The summary is sent inside `` tags, and the system prompt tells the model to treat that content as data, not instructions (account names and merchant descriptions come from CSVs and are untrusted). @@ -1084,7 +1089,7 @@ Multiple credit card files can be loaded simultaneously. Each gets a unique `acc --- -*Last updated: v1.16.21 — 2026-11-02 (§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.22 — 2026-11-02 (§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)* --- @@ -1186,7 +1191,7 @@ A developer-only view (`showView('ai-eval')`) that measures how well AI Analysis - **Declined runs** (`stop_reason` `refusal`) have no answer: they are counted in the *Calls* row, like failed calls, and left out of the scoring and token averages. - **Nothing persisted.** Results live in memory only and leave via the download buttons, so §20 needs no entry. Don't add `lsSet()` calls here. The API key is never put in results, exports or logs. - **A summary loaded from a results JSON is never sent.** It can be re-scored locally (`loadResults()` sets `dataset.fromFile`), but Run stays disabled until samples are reloaded and verified. -- **The summary format is parsed** by `parseSummary()`: the period line (`S.days`, `S.periodMonths`) and month lines with an optional `(through …)` / `(from …)` note. If `buildFinancialSummary()` changes, update the parser and its derivations *before* the next run. Example: the per-month figures over the period (total ÷ months as stated, or ÷ days/30.44) were added in v1.10.2 together with the dates. The balance lines are matched by how they start (`Total Cash: `, `Debts`), so keep those starts: a past range's notes (v1.16.11, §13) go after `Accounts` and at the end of the Total Cash line, hold no amounts, and needed no parser change. +- **The summary format is parsed** by `parseSummary()`: the period line (`S.days`, `S.periodMonths`) and month lines with an optional `(through …)` / `(from …)` note. If `buildFinancialSummary()` changes, update the parser and its derivations *before* the next run. Example: the per-month figures over the period (total ÷ months as stated, or ÷ days/30.44) were added in v1.10.2 together with the dates. The balance lines are matched by how they start (`Total Cash: `, `Debts`), so keep those starts: a past range's notes (v1.16.11, §13) go after `Accounts` and at the end of the Total Cash line, hold no amounts, and needed no parser change. Sections are found by how their heading starts (`Recent monthly`, `Subscriptions`, `Debts`) and a heading ends with `:`: a past range's trend and Subscriptions headings (v1.16.22) keep both, hold no amounts, and needed no parser change either. A trend with fewer than three months, or none, parses as it is. - **Publishing a new run:** move the current `docs/EVAL.md` and `docs/eval-results.json` to `docs/eval-runs/v/` unchanged except for a one-line "Archived" banner, its JSON link label, and relative links the move would break (`eval-runs/vX/…` becomes `../vX/…`). Put the new results JSON in `docs/`, generate EVAL.md by loading it in the view (**Load results JSON** → **Download EVAL.md**), then add the hand-written sections before *Method*: the **Runs** table (one column per run: `max_tokens`, cut-off answers, tokens, figures, grounded, derived, traceable, unsupported), what changed between runs, and *Changes made after the run*. Keep README's Evaluation numbers in step. - **Changing the matcher after a run:** fix only bugs against the method EVAL.md states. Record each fix in EVAL.md's "Changes made after the run" with before and after numbers. Never add a rule just because it raises the score on answers you've already seen. - **Classification** (`classifyText()`): grounded → explicit equation (a wrong one is a math error) → standard derivations (`_candidates()`, each with context keys) → restatements, correct equations and same-line arithmetic on anchored figures → forecast (the 12-month prediction prompt only) or unsupported. When adding a derivation, give it context keys; check the chance-match rate in the report doesn't rise noticeably — it is the matcher's false-positive rate and is published alongside the headline. diff --git a/README.md b/README.md index e873f29..7478c51 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.21  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.16.22  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -140,7 +140,7 @@ Reference lists for learning, not financial advice. Type your own % next to nine **Savings:** start from your checking, savings and debt, add what you save each month, and pick an interest rate (APY) and the tax on it, for 1–30 years. Save up to 10 scenarios and load them back. **Investments:** a starting amount, monthly additions, 1–40 years and a yearly return (5%, 8%, 11% or your own), shown in future and in today's dollars, year by year. Growth compounds monthly so that a yearly rate compounds to exactly that rate. ### AI Analysis -Ask Claude about your finances: eight quick analyses (a monthly spending review, where to cut back, a subscription audit, a savings-rate check, a debt payoff plan, budget suggestions, a 12-month forecast and a summary) or your own question. Claude receives a text summary of your balances, income, spending by category, debts and subscriptions for the dates on screen, never your CSV files. Answers can be copied or saved as Markdown, and a cut-off answer says so. History keeps up to 50 answers in your browser; open any of them again, or export them all as Markdown. Requires your own [Anthropic API key](https://console.anthropic.com). +Ask Claude about your finances: eight quick analyses (a monthly spending review, where to cut back, a subscription audit, a savings-rate check, a debt payoff plan, budget suggestions, a 12-month forecast and a summary) or your own question. Claude receives a text summary of your balances, income and spending by category for the dates on screen, the monthly trend up to their end, and your current debts and subscriptions, never your CSV files. Answers can be copied or saved as Markdown, and a cut-off answer says so. History keeps up to 50 answers in your browser; open any of them again, or export them all as Markdown. Requires your own [Anthropic API key](https://console.anthropic.com). ### Settings Six tabs: **General** (theme and your API key), **Import** (your CSV folder, how each file is read and the import log), **Accounts** (names, display order and starting balances), **Credit cards** (balance, credit limit, APR and payment due day), **Categories** (add or delete; deleting moves a category's transactions to Other) and **Data & reset** (what's stored, clean up, JSON export and import, start over). @@ -263,4 +263,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.16.21 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.16.22 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index 8f17163..f5d088c 100644 --- a/index.html +++ b/index.html @@ -1202,7 +1202,7 @@
-
v1.16.21 · FinLens
+
v1.16.22 · FinLens
diff --git a/js/views-ai.js b/js/views-ai.js index 7b0d981..f3224b3 100644 --- a/js/views-ai.js +++ b/js/views-ai.js @@ -24,6 +24,8 @@ const AI_PROMPTS=[ // summarySpan(txs) -> " (transactions from May 1, 2026 to Oct 20, 2026: 173 days, about 5.7 months)" // partialMonthNote(m, all) -> " (through Oct 20)" for the latest month, " (from May 15)" for the first, // when the data doesn't cover that whole calendar month +// partialMonthNote(m, all, end) -> on a past period (v1.16.22): " (through Aug 15)" for the month +// holding its end, unless the end is that month's last day function summarySpan(txs) { if (!txs.length) return ''; const times=txs.map(t=>t.date.getTime()); @@ -32,19 +34,21 @@ function summarySpan(txs) { const months=days>=45?`, about ${(days/30.44).toFixed(1)} months`:''; return ` (transactions from ${dayjs(first).format('MMM D, YYYY')} to ${dayjs(last).format('MMM D, YYYY')}: ${days} day${days===1?'':'s'}${months})`; } -function partialMonthNote(monthKeyStr, allTxs) { +function partialMonthNote(monthKeyStr, allTxs, end) { const inMonth=allTxs.filter(t=>monthKey(t.date)===monthKeyStr).map(t=>t.date.getTime()); if (!inMonth.length) return ''; const all=allTxs.map(t=>t.date.getTime()); const first=new Date(Math.min(...inMonth)), last=new Date(Math.max(...inMonth)); const notes=[]; if (Math.min(...all)===first.getTime() && first.getDate()!==1) notes.push(`from ${dayjs(first).format('MMM D')}`); - if (Math.max(...all)===last.getTime() && last.getDate()!==endOfMonth(last).getDate()) notes.push(`through ${dayjs(last).format('MMM D')}`); + if (end) { if (monthKey(end)===monthKeyStr && end.getDate()!==endOfMonth(end).getDate()) notes.push(`through ${dayjs(end).format('MMM D')}`); } + else if (Math.max(...all)===last.getTime() && last.getDate()!==endOfMonth(last).getDate()) notes.push(`through ${dayjs(last).format('MMM D')}`); return notes.length?` (${notes.join(', ')})`:''; } -// The date the summary's balances are at, when the selected period ends before the last -// transaction (Last year, a custom range ending in August…); null otherwise (v1.16.11). +// The date the summary's balances are at, and its monthly trend stops at (v1.16.22), when the +// selected period ends before the last transaction (Last year, a custom range ending in +// August…); null otherwise (v1.16.11). // Up to v1.16.10 the summary always sent today's balances (currentBalances()) under the // period's "Period:" line, so on a past range the model read them as that period's. // When the period ends at or after the last transaction (All time, This month, any range @@ -67,7 +71,12 @@ function buildFinancialSummary() { if (asOf) Object.values(State.accounts).forEach(a=>{ balances[a.id]=periodEndBalance(a.id); }); const asOfText=asOf?dayjs(asOf).format('MMM D, YYYY'):''; const txs=filteredTx(); - const allMonths=byMonth(State.transactions); + // The trend: up to three months, the last one holding the period's end (v1.16.22). On a past + // period it stops at the end, with the date on its heading; the month holding the end is + // marked "(through Aug 15)" unless the end is its last day. Up to v1.16.21 it was always the + // latest three months, so on a past range the model saw months after the period. + const trendTxs=asOf?State.transactions.filter(t=>t.date<=asOf):State.transactions; + const allMonths=byMonth(trendTxs); const recent3=allMonths.slice(-3); const cats=byCategory(txs,'expense').slice(0,8); const incomeCats=byCategory(txs,'income').slice(0,5); @@ -85,10 +94,12 @@ function buildFinancialSummary() { cats.forEach(c=>lines.push(` - ${c.category}: ${fmt(c.amount)}`)); lines.push(''); lines.push('Top income sources:'); incomeCats.forEach(c=>lines.push(` - ${c.category}: ${fmt(c.amount)}`)); - lines.push(''); lines.push('Recent monthly trend:'); - recent3.forEach(m=>lines.push(` - ${m.month}${partialMonthNote(m.month, State.transactions)}: income ${fmt(m.income)}, expense ${fmt(m.expense)}, net ${fmt(m.income-m.expense)}`)); + lines.push(''); lines.push(asOf?`Recent monthly trend, up to the end of the period (${asOfText}):`:'Recent monthly trend:'); + recent3.forEach(m=>lines.push(` - ${m.month}${partialMonthNote(m.month, trendTxs, asOf)}: income ${fmt(m.income)}, expense ${fmt(m.expense)}, net ${fmt(m.income-m.expense)}`)); if (State.debts&&State.debts.length){ lines.push(''); lines.push(asOf?'Debts (current balances, not at the end of the period):':'Debts:'); State.debts.forEach(d=>lines.push(` - ${d.name}: balance ${fmt(debtBalance(d))}, APR ${(d.apr||0).toFixed(2)}%, min pmt ${fmt(d.minPayment||0)}`)); } - if (recurring.length){ lines.push(''); lines.push('Subscriptions:'); recurring.forEach(r=>lines.push(` - ${r.merchant}: ${fmt(r.avg)} ${r.freq}`)); } + // Subscriptions are the current ones, found in all transactions as on the Bills screen: what + // you'd cancel now. On a past period the heading says so, as the Debts heading does (v1.16.22). + if (recurring.length){ lines.push(''); lines.push(asOf?'Subscriptions (current, found in all transactions, not just the period):':'Subscriptions:'); recurring.forEach(r=>lines.push(` - ${r.merchant}: ${fmt(r.avg)} ${r.freq}`)); } return lines.join('\n'); } diff --git a/js/views-settings.js b/js/views-settings.js index 3ac0f62..08e0dd3 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -67,7 +67,7 @@ function _renderGeneralSettings(root) { ``).join('')} -
VersionFinLens v1.16.21
+
VersionFinLens v1.16.22
`); const opts=$$('[data-theme-opt]',root); opts.forEach((b,i)=>{