← Back to Pull requests

Chart an account's value over time in its detail view #389

Closed
unknown closed this pull request without merging on Nov 21, 2026 19:45 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 19:04 UTC
Author

What

The account detail modal on /finances now opens on a chart of that account's value over time: its balance, what it owes, or what it is worth. It shows the latest value, the change over the selected range, and 1M/3M/6M/1Y/All buttons. A caption under the line says where the series came from.

Why it is built this way

No provider gives Linc a balance history, and nothing here stored one per account (FinancialSummaryHistory held only totals). So each series has exactly one source, never a blend:

| Account | Series |
| --- | --- |
| Connected checking, savings, credit card | Rebuilt from posted transactions, working back day by day from the reported balance. A full history right away. |
| Investment, retirement, loan, mortgage, hand-entered | Values Linc records from now on. Each daily history row stores every account's Finances-page value with when its provider reported it. |

  • The rebuild uses the provider's own amount (source_amount, positive when money leaves) in whole cents. It leaves pending transactions out, as the reported balance does, and starts at the earliest posted transaction, because before that the balance is unknown, not zero. It falls back to recorded values rather than guessing when a transaction is in another currency or lacks a date or amount.

  • Recorded points are dated by the provider's report (lastSyncedAt), not when Linc read it. An account the institution hasn't refreshed adds no new day, and an unconfirmed account adds none. This is the same rule the account's "Updated" line follows. A day's row is rewritten when any account moves, even with totals unchanged (a transfer between two cash accounts), but not when the stored JSON differs only in key order.

  • An investment account's past is deliberately not estimated from today's holdings and old prices. A line built that way would look like the account's history without being it. That account's chart says how much has been recorded until it has two points.
  • Full write-up: docs/ACCOUNT_VALUE_HISTORY.md (and a short CLAUDE.md section).

    Changes

  • prisma: nullable accountValues JSONB on financial_summary_history, plus migration 20261121120000_add_history_account_values.

  • src/services/account-value-history.ts: new. It builds the series (transaction rebuild or recorded values) and the per-account values to store.

  • src/services/financial-history-service.ts / summary-cache-service.ts: the daily history write stores accountValues.

  • src/auth/finances-routes.ts: new GET /api/finances/accounts/:id/history.

  • finances-overview-service.ts: exports accountId and a new findFinancesAccount, shared by the details and history routes.

  • frontend/src/components/finances/AccountValueChart.tsx: new. It loads on its own, so it never waits on holdings and transactions, and is mounted at the top of AccountDetailModal. Y-axis labels stay exact to the dollar ($21.75K, not every tick reading $22K).
  • Reviewer notes

  • Deploy order: run npm run migrate:deploy before this backend goes out. Without the column, the history write fails (caught and logged, non-fatal) and the chart shows "unavailable".

  • Recorded history starts at deploy. Rows written before this have no per-account values, so investment and loan charts fill in about a point a day from then.

  • A re-linked account that gets a new provider id starts its recorded history again under the new id.
  • Testing

  • New: account-value-history.test.ts (14), account-value-history-route.test.ts (4) and AccountValueChart.test.tsx (17). financial-history-service.test.ts gains 4 tests for the per-account write, and AccountDetailModal.test.tsx gains 1 for the mounted chart.

  • Backend type-check and frontend tsc are clean, and eslint has no errors.

  • The full backend unit run has 3 failing suites (market-news, plaid-security, feedback, 21 tests). They fail identically on main.

  • Visual check: I viewed the real modal in next dev with sample data for an investment account, a checking account, a credit card and a single recorded value, at desktop and phone width (no horizontal overflow).

  • Not checked against real linked data: the local dev database (Docker, port 5433) wasn't running.
  • 🤖 Generated with Claude Code

    Diff: 542 lines (+406 / -136) across 6 files Reviewer: ethanteng Review duration: 41m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 542 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.377
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #389"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.0% (MEDIUM) · Higher = larger blast radius
    48.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.0% · Safe to merge
    19.0%