Repository navigation
Conversation
…ered what you owe (v1.16.21)
Settings asks for a card's balance as the amount owed, a positive number
("Balance owed today", "Current balance"). The card's rows are negative for a
charge and positive for a payment. balanceAt() and periodEndBalance() took
every override back to an earlier date as a bank balance: the override minus
the transactions after that date. For a card that added a later charge to
what was owed before it. With the samples and $617.33 entered (what the
card's rows add up to), Jul 1 - Aug 15, 2026 showed $900.74 owed; the rows
give $333.92. master has it too, on ranges ending more than 7 days ago.
v1.16.20 extended the same rule to recent ranges.
- aggregation.js: overrideBalanceAt() takes an override back the way it
points: a bank balance minus the later rows (as before), a card's amount
owed plus them. A card balance typed as a negative number still counts as
owed (debtOf()) and is taken back as before. balanceAt() and
periodEndBalance() use it.
- Today's numbers are unchanged: All time, every range reaching the card's
last transaction, the Debt tracker, Payments, Forecast, Credit cards. Bank
accounts and accounts without an override are 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, §8, §18 and Last updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…3.0) into fix-card-override-direction 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
Settings asks for a credit card's balance as the amount you owe, a positive number. The card's rows point the other way: a charge is negative, a payment positive. To find the amount owed at an earlier date, FinLens subtracted the later rows, as it does for a bank balance. For a card that is backwards: a later charge was added to what you owed before it, and a later payment taken off.
Cause
The sign convention, end to end:
setAccountMoney()stores the number as typed inmanualBalances[cardId].parseMoneyInput()accepts a minus sign, so a negative number can be stored too.currentBalances()returns the override as stored (positive owed). Without an override it returns the sum of the card's rows, which is negative while you owe.debtOf()(Overview cards, net worth, Trends, Payments, Settings → Credit cards),Math.absindebtBalance()(Debt tracker), the Forecast and the AI summary's Total Debt. So both signs show as owed. The AI summary's Accounts line prints the raw value: positive with an override, negative without.The bug:
balanceAt()andperiodEndBalance()(aggregation.js) took every override back as a bank balance:override − rows after the date. For a card stored as positive owed, that moves the wrong way.Where it showed: the Overview's card and net worth on a past range, the net worth chart's earlier points, its "since " change, the card's sparkline in Trends, and the AI summary's Accounts and Total Cash lines on a past range (since v1.16.11).
With v1.16.20 (ed74702): that fix took ranges ending within the last 7 days back the same way. For a card they then agreed with the chart, but moved away from the right value. With $700.25 entered, today on Oct 20 and a range of Oct 1 – Oct 19: v1.16.19 showed $700.25 owed, v1.16.20 $727.78. The right amount is $672.72.
master has it.
origin/master(v1.10.5) has nobalanceAt(), but itsperiodEndBalance()returnsoverride − rows after the period endfor any range ending more than 7 days ago. Its Overview uses that for every account and shows a card asMath.abs(bal). Its Settings stores the card's "Current Balance" the same way. I read the code; I didn't run master.What changed
js/aggregation.jsoverrideBalanceAt(accountId, date): the override at the end ofdate. Acredit_cardaccount with an override ≥ 0 givesoverride + rows after date. Anything else givesoverride − rows after date, as before.balanceAt()andperiodEndBalance()call it. The no-override path (starting balance plus rows) is unchanged. A card has no starting-balance field in Settings, so that path only adds its rows in their own sign.index.html,README.md, Settings → General; CLAUDE.md §1, §8 (overrideBalanceAt(),balanceAt()), §18 (the direction per kind, the sign of a card's balance) and Last updated.Unchanged:
Changes on All time too: the chart's earlier points and the change pill, because they use past amounts owed. With $617.33 entered, "since Sep 30" goes from $2,010.75 to $2,339.71. The chart's last point still equals the net worth.
AI Eval
_withSampleState()setsmanualBalances: {}and All time, so no override exists andcurrentBalances()gives every balance.test-card-override.jsbuilds the sandbox summary under four clocks (Oct 20, Oct 25, Nov 2, Sep 10), with the user's own state set to a card override, starting balances, a linked debt and a past range. It is byte-identical to ed74702's under every clock, sha256df5557eab27fcfeb51e2953f92653ca69afcd651030f81d847056050cd2ed98d. That's the hash recorded for v1.16.20.test-override-balance.jsalso checks it against the publisheddocs/eval-results.json(after the v1.12.0 account renames): byte for byte.test-insights.jschecks that the All-time request bodies are unchanged: passes.Not verified
debtOf()). That was already so, for both rules. Not changed here.fmt()prints it as "-$0.00" (Overview card, AI summary). ed74702 does the same for a bank override. Cosmetic, not changed here; the new test compares the cents exactly and sets aside the sign of zero in text.card_initial, only from older data or a JSON import) keeps the rows' sign. Covered bytest-start-balance.js(cardStart), not by the new test.Automated checks: earlier run, not re-run · 0b6a175
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
0b6a175(chained on #43) 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>.0b6a175boot.jsrace.jstest-card-override.js(new in this PR)test-override-balance.js(#43's, card expectations corrected in this PR)test-start-balance.js(#33's, as updated by #34, #43, #44 and #45)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.Chain edit to
test-card-override.js: on the top of the stack, its "identical to the parent" check (no card override) compared whole AI summaries with its baseline, so v1.16.22: Fix the AI summary's monthly trend running past a past date range #45's trend change on past ranges failed it (265/277). It now compares with the trend section and Subscriptions heading set aside, as the test's other summary checks already did. Rerun on the top: 277/277.No phone checks (desktop only).
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 (Playwright), samples only, with the test harness (its scripts aren't in the repo). CDNs blocked; the pinned libraries are served from npm. Fixed clocks where noted.
route()aborts every host but localhost, so nothing reached Anthropic.New:
test-card-override.js. 8 scenarios × 15 ranges × 4 clocks. Expectations come from the sample CSV rows parsed in Node, never from the app's helpers. The baseline is captured on ed74702.periodEndBalance(), the Overview's cards and net worth, every point of the net worth chart (1M, 3M, All), the change pill, and the AI summary's balance lines on past ranges (dated) and current ones.balanceAt()at the end of every day (177 days × 3 accounts), Payments, and for the linked debt: the Debt tracker row, total and utilization, Settings → Credit cards and the summary's Debts line.override − later rows(the bug, reproduced).test-card-override.js(new)test-override-balance.js(card expectations corrected, below)test-override-balance.v19.js(as received)test-start-balance.js(card expectations corrected, below; run byrun-tip.sh)test-start-balance.v19.js(as received)test-ai-summary-period.js(run byrun-tip.sh)test-ai-summary-period.v11.jsrun-tip.sh 15 <repo> <out> 1, the same on ed74702 and on b3b5c33 except where noted:Suite changes (in my harness copy; the originals are kept as
.v19.js):test-override-balance.js:balC()gives a card override ≥ 0 aso + rows after. The parent's rule (old) keepso − rows after.changedAccts()adds the card on any range with card rows after its end.changedAccts19()keeps the v1.16.20 set for the parent's net-worth-vs-chart check.test-start-balance.js:balCents()gives a card override ≥ 0 aso + rows after.startCard.test-ai-summary-period.js: 76/78 on both. The two failing checks expect the trend-section change from the trend fix (v1.16.22: Fix the AI summary's monthly trend running past a past date range #45, v1.16.22) above it in the stack (test-ai-summary-trend.js), which isn't in this base. The v1.16.11 original (test-ai-summary-period.v11.js) passes 78/78 on both.race.js: 7 errors on ed74702, 6 on this branch. All arerenderImportLog(the v1.10.5: fix Import Logs throwing when the view is left before it loads #18 fix isn't in this stack); none comes from this change.How to reproduce the bug
Run this on the base branch,
fix-balance-override-recent-range. Master has the bug too (read from the code, not run there).fix-balance-override-recent-rangeinstead offix-card-override-direction. The card's Current balance ($) is617.33, exactly what its rows add up to.What goes wrong: with
617.33entered, the card shows $900.74 owed and net worth $8,785.05. With no balance entered, the same range shows $333.92 owed and $9,351.87, which is what the rows give. The two should match.Manual QA steps
Setup
git checkout fix-card-override-direction.index.htmlfrom the repo. Nothing here touches a data folder, so the unmodifiedsamples/files are fine.checking_sample.csv,savings_sample.csvandcredit_card_sample.csvinsamples/and click Import 3 files.617.33and press Tab. That is exactly what the card's rows add up to, so every past amount owed can be checked against the no-override numbers.1. A past range shows the right amount owed
Expected:
Before this fix: $900.74 owed, net worth $8,785.05.
2. The same range with no balance entered gives the same numbers
617.33back in Current balance ($) afterwards.Expected:
3. All time: today's numbers stay, the chart's history moves
Expected:
Before this fix: the pill read $2,010.75 and the first dot −$127.11. Net worth and card were the same.
4. Trends sparkline for the card
Expected:
Before this fix: "from $1,227 to $617".
5. A negative balance keeps the old direction
-617.33in Current balance ($) and press Tab.Expected:
6. Regression: screens that read today's balance
617.33back in Current balance ($).20, Minimum payment ($)35, and click Save debt.Expected:
7. AI summary on a past range
buildFinancialSummary().Expected:
Before this fix: $900.74 and $8,785.05.
8. Version
Expected:
Please check before merging
https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code