fix(pulse): Finances tab reads 0 income/expenses off LifeOS's own shipped templates - #1779
Open
takanorinishida wants to merge 1 commit into
Open
Conversation
…pped templates
Two independent bugs in /api/life/finances, both hit by installs that
follow the shipped USER/TELOS/FINANCES templates as-is (not specific
to this deployment's data):
- parseCurrencyTable() always read the amount from column 1. LifeOS's
own EXPENSES.md ships as `| Category | Vendor | Amount | Frequency |
Notes |` — column 1 is Vendor (never numeric), column 2 is Amount.
Every install using the shipped layout silently got 0 for every
expense row. Now picks the amount column by header name ("amount",
"annual", "monthly", "total", "cost", "value"), falling back to
column 1 when no header matches so tables that already worked are
unaffected. When a Frequency/Cadence/Period column is present, its
value now annualizes a per-period amount via the existing
cadenceToMonthly() instead of taking the cell at face value.
- INCOME.md ships as bulleted prose with no pipe-table at all (the
code comment claiming it "leads with 'Annual Income Estimate'"
doesn't match the shipped file), so parseCurrencyTable(incomeRaw)
always returned [] and every install's income read as $0/¥0 —
which then propagates into the Sankey, the 12-month trend, and the
post-tax net. Per-source income bullets use inconsistent ad hoc keys
("Gross per period", "Current MRR", "Per-engagement amount", ...),
too heterogeneous to sum reliably, so this doesn't attempt that.
Instead it reads the one number both the shipped template and
hand-written files anchor on: the "## Expected Monthly Total"
section's headline bullet, only as a fallback when the table is
empty.
Both changes only add coverage for inputs that previously parsed to
0/[] — nothing that already extracted a nonzero number changes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVzLJHrJPj5Phmh1vaLUBV
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.
Two independent bugs in
/api/life/finances, both hit by installs that follow the shippedUSER/TELOS/FINANCEStemplates as-is (not specific to any one deployment's data):parseCurrencyTable()always read the amount from column 1. LifeOS's ownEXPENSES.mdships as| Category | Vendor | Amount | Frequency | Notes |— column 1 is Vendor (never numeric), column 2 is Amount. Every install using the shipped layout silently got 0 for every expense row.INCOME.mdships as bulleted prose with no pipe-table at all (the code comment claiming it "leads with 'Annual Income Estimate'" doesn't match the shipped file), soparseCurrencyTable(incomeRaw)always returned[]and every install's income read as $0/¥0 — which then propagates into the Sankey, the 12-month trend, and the post-tax net.Fix
parseCurrencyTable()now picks the amount column by header name ("amount", "annual", "monthly", "total", "cost", "value"), falling back to column 1 when no header matches so tables that already worked are unaffected. When a Frequency/Cadence/Period column is present, its value now annualizes a per-period amount via the existingcadenceToMonthly()instead of taking the cell at face value.parseCurrencyBullet()reads the one number both the shipped template and hand-written files anchor on — the "## Expected Monthly Total" section's headline bullet — only as a fallback when the table is empty.Non-destructive
Both changes only add coverage for inputs that previously parsed to 0/
[]— nothing that already extracted a nonzero number changes.Verification
Ran both parsers against the shipped
USER/TELOS/FINANCES/{INCOME,EXPENSES}.mdtemplates (still correctly yield nothing — placeholder$X,XXXtext has no digits) and against a filled-in real install: income moved from ¥0 to the correct ¥4,800,000/year, expenses correctly read ¥1,524,000/year off the Amount column instead of the Vendor column.🤖 Generated with Claude Code