Repository navigation
Conversation
… within 7 days (v1.16.20) periodEndBalance() returned a balance override (a card's amount owed, or a bank "current balance" saved before v1.16.0) as it was whenever the range ended 7 days ago or less, and subtracted the transactions after the range end only for older ranges. A range ending yesterday showed today's balance, and the Overview's net worth disagreed with its own chart's last point (balanceAt() never had the exception). Since v1.16.11 the AI summary sends periodEndBalance() on a past range, so it sent those numbers too. No commit, changelog entry or comment gives a reason for the 7-day rule; it came with the code first committed in May 2026. An override records no date, so it can only be taken as today's balance. - aggregation.js: periodEndBalance() gives the override less the transactions after the range end for every range, as balanceAt() does. - All time and every range reaching the account's last transaction are unchanged. With no override, every number is unchanged. - The AI Eval's sandbox sets no manual balances and uses All time, so its summary is byte-identical and the published results still hold. - CHANGELOG; version in index.html, README and Settings -> General; CLAUDE.md §1, §18 and Last updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…13.0) into fix-balance-override-recent-range 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 balance override is a card's balance owed, or a bank "current balance" saved before v1.16.0. At the end of a date range, FinLens shows the override less the transactions after the range end. Up to now, a range that ended within 7 days of today got the override as it was. So a range ending yesterday showed today's balance.
Now every range gets the override less the transactions after its end. That's the rule the net worth chart, the sparklines and Trends (
balanceAt()) already use.Cause
periodEndBalance()(js/aggregation.js):if (daysDiff<=7) return Number(State.manualBalances[accountId]);. Older ranges subtracted the transactions after the range end.git log -S'daysDiff<=7'finds only02c9891("Latest changes", May 1, 2026), the first commit of code written before git. No CHANGELOG entry, doc or comment explains it. v1.3.2 describes the feature as the "current manual balance adjusted by transactions after the period end", with no exception. CLAUDE.md §18 (added by v1.16.10: Fix starting balance ignored by "All time", the AI summary, Buckets and Forecast #33) records it as "keeps one exception", without a reason.setAccountMoney()stores only the number, and Settings → Accounts labels it "Balance owed today". So the only reading FinLens can make is "today's balance, after every imported transaction". The 7-day rule contradicts that whenever there are transactions between the range end and today.periodEndBalance(); its chart's last point usesbalanceAt(), which never had the exception.periodEndBalance()on a past range since v1.16.11: Fix the AI summary sending today's balances for a past date range #34, so it sent those numbers too.origin/master(v1.10.5) has the sameperiodEndBalance(). There it feeds the Overview's Total Cash, Total Debt and Net Worth cards. Master's AI summary usescurrentBalances(), so it isn't affected by this one.What changed
periodEndBalance()(js/aggregation.js): the two lines of the 7-day shortcut are gone. With an override, every range gets the override less the transactions after its end. Comments updated.Unchanged:
currentBalances()).balanceAt(),currentBalances(), the chart, sparklines and Trends.AI summary, past range (samples; a checking override of $5,000 and a card override of $700.25; today Oct 20, 2026; range Oct 1 – Oct 17, 2026):
Before:
The Overview showed $7,095.46; its chart ended at $7,122.24. Checking showed $5,000.00, though $65.00 left it on Oct 18.
After:
The Overview and its chart both show $7,122.24.
Docs: CHANGELOG 1.16.20; version in
index.html, README (badge and footer) and Settings → General; CLAUDE.md §1, §18 and Last updated.AI Eval
manualBalances: {}and uses All time. It never reaches the changed lines: All time returnscurrentBalances()before them, and they only run for an account with an override.test-override-balance.jsbuilds the sandbox summary on the parent and on this branch, under four clocks, with a user range of Oct 1 – Oct 19 and a card override set (so a leak would show). All eight are the same string (sha256df5557eab27fcfeb51e2953f92653ca69afcd651030f81d847056050cd2ed98d), and it is the summary in the publisheddocs/eval-results.jsononce the v1.12.0 account renames are applied.test-ai-summary-period.jschecks the same against its own baseline.parseSummary()changed.Not verified
balanceAt()(the chart, sparklines, Trends) and older ranges already did this. This PR makes recent ranges follow the same rule, so for a card they now match the chart but move the other way from today's value. In the example above, the card shows $738.47 owed on Oct 17 instead of $700.25; from the rows, it would be $662.03. That's a separate bug, not fixed here.samples/, at desktop width.Automated checks: earlier run, not re-run · 1b299d5
Moved unchanged from this PR's "Test results" comment on 2026-11-04; not re-run, so not in the new table format. Originally a description section titled "How it was tested".
Light checks, by Luis's call to save usage: on this branch's final commit
1b299d5(chained on #42) onlyboot.js,race.jsand this PR's own tests ran. Headless Chromium at 1280×900 againstsamples/, with the pinned CDN libraries served from npm; each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>.1b299d5boot.jsrace.jstest-override-balance.js(new in this PR)Full set, once, on the top of the stack (#23,
819e809: every PR below it merged in): every base suite and every fix test from #24 to #50, plus #10's and #23's, each in its final variant. All pass:test-clarity.js55/55,test-insights.js137/137,test-finances.js126/126,test-plan.js127/127,boot.js257 transactions and 0 errors,race.js0 errors; #24–#38's tests (clear-edits 48/48, rebuild-folder 57/57, partial-import 47/47, json-import 28/28, new-browser-copy 10/10, json-export 31/31, plan-links 60/60, rule-flags 67/67, drawer-flags 36/36, start-balance 193/193, ai-summary-period 78/78, account-names 40/40, account-order 32/32, drawer-focus 167/167, cleanup 21/21); #39–#50's tests (drawer-fields 45/45, read-as 52/52, json-import-edits 29/29, overlapping-exports 46/46, override-balance 160/160, card-override 277/277, ai-summary-trend 91/91, transfer-user-type 39/39, untransfer-category 27/27, recategorize 55/55, retype-transfer 135/135, minor-fixes 34/34);test-dbtab.js73/73,test-save-status.js64/64,test-master-port.js16/16. Three scripts needed a test-only change on that run, listed in #23 and in the PRs they belong to; the app code wasn't changed.Measured before the chain
The numbers below are the PR author's, on the commit before it was chained (built on the old #38 tip
ecfcab2, v1.16.15, or on the fix below it there; version numbers renumbered to the chain's).Headless Chromium against
samples/, CDNs served from npm, no request to Anthropic.New:
test-override-balance.js. Four fixed clocks (Oct 20, Oct 25, Nov 2 and Sep 10, 2026) × 15 ranges × 4 balance scenarios (none; card override; card + old bank override; card override + starting balances). Expectations are worked out in Node from the CSV rows. It checks:periodEndBalance()against those expectations;ecfcab2): 124/159. Branch: 159/159. The parent fails only the checks the bug touches.run-tip.sh 15(the base suites plus every fix test of v1.16.1: Fix "Clear transaction edits" wiping every transaction when the browser database is empty #24–v1.16.15: Cleanup — remove unused views-database.js, fix the in-app changelog, update stale wording #38), one suite at a time:ecfcab2ed74702renderImportLog(v1.10.5: fix Import Logs throwing when the view is left before it loads #18 isn't in the stack)renderImportLogThe one failure was timing. "6 Moved account: before" reloads right after a fire-and-forget IndexedDB write of
txOverrides. It found the edit not yet saved once, under load from other agents' tests, and passed 47/47 on a rerun. It doesn't touch balances.Suite edit:
test-start-balance.jswrites the balance rule out inbalCents(), and its lineif (mode === 'range' && (Date.now() - when.getTime()) / DAY <= 7) return o;encoded the 7-day rule. I removed that line and updated the comment; the old copy istest-start-balance.v11.js. The suite uses the real clock. From Oct 20, 2026 on, no range in it ends within 7 days of today with rows after its end, so its expected values and pass count are the same either way. Without the edit, it would assert the old rule on some days.How to reproduce the bug
Run this on the base branch,
fix-overlapping-exports-duplicates. Master has the bug too.fix-overlapping-exports-duplicatesinstead offix-balance-override-recent-range. You need the scratch folder with the extra card row dated today, and the card's Current balance ($) set to700.25.What goes wrong: the card shows $700.25 owed and net worth reads $15,416.89. The chart's last dot for the same day reads $15,391.89, so the Overview disagrees with its own chart.
Manual QA steps
Setup
git checkout fix-balance-override-recent-range.C:\temp\finlens-override, and copy the three files fromsamples/into it.index.htmlfrom the repo.700.25and press Tab.Below, "yesterday" means the calendar day before today.
1. A range ending yesterday matches the chart
Expected:
Before this fix: card $700.25 owed, net worth $15,416.89, while the chart's last dot read $15,391.89.
Note: #44 (
fix-card-override-direction) reverses the direction for cards. There this same range shows $675.25 owed. On this branch, $725.25 is correct.2. The 7-day edge no longer jumps
Expected:
Before this fix: 7 days before today gave $700.25 (net worth $15,416.89); 8 days before gave $725.25.
3. The AI summary sends the same balance
buildFinancialSummary()and press Enter.Expected:
Before this fix: $700.25 and $15,416.89.
4. Regression: ranges that reach today don't change
Expected:
5. Regression: no override
Expected:
6. Regression: a range far in the past
700.25back in Current balance ($) and press Tab.Expected:
Please check before merging
https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code