Repository navigation
Conversation
…16.10) currentBalances() added up an account's transactions but never its starting balance (manualBalances[id+'_initial']). periodEndBalance() uses it for All time, and the AI summary, Savings buckets and Forecast read it directly, so all of them left the starting balance out. Every other range, the net worth chart, the sparklines and Trends (balanceAt()) added it, so the Overview's numbers changed with the range. - aggregation.js: currentBalances() adds the starting balance. A new startingBalance() reads it; periodEndBalance() and balanceAt() share it. - A balance override (a card's amount owed, or a bank balance saved before v1.16.0) still wins and still replaces the starting balance. - With no manual balances every number and the AI summary are unchanged. The AI Eval's sandbox sets none, so its summary is byte-identical and the published results still hold. - CHANGELOG; version in index.html, README and Settings → General; CLAUDE.md §1, §8, §13, §18 and Last updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
This was referenced Nov 2, 2026
…time-start-balance Carries master's v1.10.3-v1.10.5 up the stack: declined answers (#14), literal single "~" (#15) and the Import Logs race fix (#18), with clarity-insights' port of #14 to the rebuilt AI tab. One conflict: CLAUDE.md's "Last updated" line. Kept this branch's line and added the v1.10.3-v1.10.5 history. The CHANGELOG merged cleanly. Versions stay 1.16.10. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
This was referenced Nov 2, 2026
Open
Open
…o fix-all-time-start-balance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi # Conflicts: # js/views-settings.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A bank account's starting balance (Settings → Accounts) now counts in every date range, All time included, wherever a balance is shown.
Before, All time on the Overview left it out, so net worth and the account cards changed with the range. The AI summary, Savings buckets and Forecast left it out in every range. One function was missing it:
currentBalances().Cause
currentBalances()(aggregation.js) works in three steps: a balance override, then a running balance from the CSV (never present), then the sum of the account's transactions. The last step never addedmanualBalances[id+'_initial'].periodEndBalance()returnscurrentBalances()for All time. For every other range it adds the starting balance to the transactions up to the range end itself.balanceAt()(net worth chart, account sparklines, Trends) also adds the starting balance.buildFinancialSummary(), Savings buckets ("Unassigned savings") and Forecast → Savings (starting checking and savings) callcurrentBalances()directly, so they left the starting balance out in every range._initial. v1.16.0 made the starting balance the field you fill in for a bank account.Trends was reported as not affected, and it wasn't: it uses
balanceAt(). It disagreed with the Overview's All time only because the Overview was wrong.What changed
currentBalances()adds the starting balance in its last step. This is the fix.startingBalance(accountId)(new, aggregation.js) readsmanualBalances[id+'_initial'], or 0 when unset.periodEndBalance()andbalanceAt()call it instead of their own copies of the same expression. What they return doesn't change.periodEndBalance(): besides the helper, only its All-time comment changed.manualBalances[id]still wins wherever it did: a card's amount owed, and a bank "current balance" saved before v1.16.0. Settings → Accounts shows that one with a button to drop it. With an override, the starting balance is ignored, as before, in all three helpers. The 7-day rule inperiodEndBalance()is unchanged: a range ending within 7 days of today shows the override as it is._initialnow counts it on All time too, as the other ranges, the chart and Trends already did. I chose one rule for every account kind over a card exception. Settings can't set a card's_initialsince v1.16.0; it can only come from older data or a JSON import.index.htmlfooter, README (badge and footer), Settings → General, CLAUDE.md §1 and "Last updated". CLAUDE.md §8 (startingBalance(),currentBalances()), §13 (summary balances) and §18 (the one balance rule).Where it shows, with a starting balance set:
_initialAI summary and the eval (§13, §21):
manualBalances: {}and All time. Its summary is byte-identical before and after, and the same whatever balances you have set. The publisheddocs/EVAL.mdresults still hold, so I didn't re-run it.This is the correctness fix: Claude now gets the balances the Overview shows. Before, it was told $15,499.81 for someone who had entered a $1,000 starting balance on checking.
Left as is (found while checking, not part of this fix):
periodEndBalance()has no match inbalanceAt(). With an override, a range that ends within the last 7 days, and transactions between that end and today, the net worth and the chart's last point can differ. The samples can't show it, because their data ends on Oct 20.t.balance) ignores the starting balance, andbalanceAt()ignores running balances. It's dormant: no format fillst.balance.Not verified
finlens-state.jsonor JSON import carrying an_initialon a card.Automated checks: earlier run, not re-run · b79d82a
Moved unchanged from this PR's "Test results" comment on 2026-11-04; not re-run, so not in the new table format. Originally a description section titled "How it was tested".
Headless Chromium (Playwright) at 1280×900 against
samples/(257 transactions), with the pinned CDN libraries served from npm, on this branch's final commitb79d82a, chained on #32. Each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>, from one harness shared by every branch in the stack: the base suites, plus every test added by this PR or by a PR below it (cumulative regression).b79d82atest-clarity.jstest-insights.jstest-finances.jstest-plan.jsboot.jsrace.jsrenderImportLog(the race #18 fixes on master; not in this stack)test-clear-edits.js(from #24)test-rebuild-folder.js(from #25)test-partial-import.js(from #26)test-json-import.js(from #27)test-new-browser-copy.js(from #28)test-json-export.js(from #29)test-plan-links.js(from #30)test-rule-flags.js(from #31, as updated by #32)test-drawer-flags.js(from #32)test-start-balance.js(new in this PR)test-insights.js's "General: version line" check reads the version from theindex.htmlfooter, andtest-plan.js's "Budget: Save adds it" accepts a new budget with or without anid, requiring thebud_+ 10 base-36 format once it has one (v1.16.7: Fix transaction links to budgets, buckets and debts pointing at the wrong item after a delete #30 adds ids). Nothing else in the base suites changed.test-start-balance.jshere is this PR's version, against the baseline captured onddc8a5f(v1.16.0). From v1.16.11: Fix the AI summary sending today's balances for a past date range #34 up, the stack runs v1.16.11: Fix the AI summary sending today's balances for a past date range #34's update of it, against the same baseline.Measured before the chain
By the agent that wrote the fix, on
6231659(built onddc8a5f, v1.16.0; then numbered v1.16.3). Its start-balance baseline was captured onddc8a5f; the same baseline is used on this branch's commit.Headless Chromium (Playwright) against
samples/, with the CDN libraries served from npm by the harness. Every script was run on the final commit withNODE_PATH=$(npm root -g) node <script> <repo> <outdir>.test-clarity.jstest-finances.jstest-plan.jstest-insights.jstest-start-balance.js(new)boot.jsrace.jsrenderImportLog/importLogsBody(fixed by #18). The base gave 6 of the same. None come from this change.test-start-balance.js:Expectations are computed in the test. It parses the three sample CSVs in Node and works out each balance from the rows, in cents, not with the app's helpers.
The starting balance is entered the way a user does: in Settings → Accounts, by typing it and leaving the field. The test checks it saves as
<id>_initial.7 scenarios:
11 ranges: every preset (This week through Last year, and All time), a custom range (Jul 1 – Aug 15, 2026) and a custom range with no end.
For each scenario and range:
For each scenario:
Against the code before the fix: the baseline was captured on the base commit (
ddc8a5f) with--capture.The eval: the summary from
AIEval.loadSamples()is byte-identical to the base, and the same whatever balances are set.Reproducing the bug: on the base, the same test gives 169/193. All 24 failures are in the four starting-balance scenarios:
Every other range passes on the base.
Existing suite edited: in
test-insights.js, the "General: version line" check expectedFinLens v1.16.0. It now expectsv1.16.10because of the version bump. Nothing else changed in any existing suite.How to reproduce the bug
Run this on the base branch,
fix-drawer-flag-overrides(#32).fix-drawer-flag-overridesinstead offix-all-time-start-balance. You end with the samples loaded and starting balances of1000on Bank Checking and250.50on Bank Savings.What goes wrong:
buildFinancialSummary()in the Console saysBank Checking ($13,321.43)…Net Worth: $15,499.81in every range.Manual QA steps
Setup
git checkout fix-all-time-start-balance, then openindex.htmlin Edge.RESETand click Erase and start over. (This PR doesn't change saving, so no scratch folder is needed.)samples/.1000, press Tab. In Bank Savings's field type250.50, press Tab. Each shows a "Saved the starting balance…" message.The numbers below assume the unedited samples and these two starting balances.
1. Overview net worth on All time includes the starting balance (the main fix)
Expected:
Before this fix: All time showed $15,499.81 while the chart ended at $16,750.31; the cards were $13,321.43 and $2,795.71.
2. Same figure in other ranges (regression)
Expected:
3. AI summary carries the starting balance
buildFinancialSummary()and press Enter.Expected:
Accounts: Bank Checking ($14,321.43), Bank Credit Card (credit_card_sample) (-$617.33), Bank Savings ($3,046.21).Total Cash: $17,367.64, Total Debt: $617.33, Net Worth: $16,750.31.Before this fix:
Bank Checking ($13,321.43)…Net Worth: $15,499.81, in every range.4. Savings buckets and Forecast
Trip, set Saved so far ($) to0, click Create bucket.Expected:
14321and Savings3046.Before this fix: $2,795.71, and Forecast started from 13321 and 2796.
5. No starting balance: nothing changes
buildFinancialSummary()in the Console.Expected:
Bank Checking ($13,321.43)andNet Worth: $15,499.81.6. Credit card balance owed still wins (regression)
500.Expected:
7. Survives a reload
1000/250.50starting balances back and remove the card's500.Expected:
Please check before merging
_initial(old data or a JSON import only) now counts it on All time too. Is it OK to treat cards like every other account here?https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code