← Back to Pull requests

Let the user mark an upcoming cash flow item as already happened #387

Closed
unknown closed this pull request without merging on Nov 18, 2026 20:54 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 20:33 UTC
Author

Why

A paycheck that is pending at the bank kept showing under "Coming up in the next month" on its expected date. The cash position starts from Plaid's reported current balance, which leaves pending transactions out for checking and savings, and the ledger skips pending transactions too. So a pending item was in neither the balance nor the history, and the forecast still expected it.

What changed

  • Mark as already happened: every item in the coming-up list (regular income and bills, recurring transfers, card payments, planned events) has an Already happened link. A marked item:

  • - moves to the first forecast day, in cash and, for a card payment, off the card. From its own date on nothing changes, so it is counted once;
    - is listed above the rest under Already happened, with Undo;
    - shows in the start line: "Starts from $2,402 in Personal Checking, plus $3,031 you marked as already happened."
  • Once the data shows it posted, the reported balance has it and the mark only keeps it from being counted twice:

  • - A regular item or recurring transfer that posts ends its own cycle, so its mark names nothing.
    - Otherwise the item counts as posted when its account has a posted transaction moving about the same amount the same way (within 10%, or $1), dated from three days before the mark onward. A regular item or transfer must also come from the same payee.
    - A card payment checks the card and the cash account separately, and a planned transfer checks each leg.
  • Savings are unchanged: a mark is about when cash moves, never what is earned or spent. The card model and credit cards panel are unchanged too.

  • Ask Linc: "cash now, as last reported" stays the reported balance. When marks add to it, the pack also publishes what they add and the sum, since the model may not add facts.
  • How items are named

    A mark names what produces the item and the day it was expected: a stream id and its cycle's due date, a card's account id and payment day, or a planned event's id and occurrence date. Each upcoming item now carries this as ref. To support it:

  • scheduleStream now returns each occurrence's dueDate, so a late paycheck the forecast expects on its first day keeps its mark.

  • A card's payments on one day are now one item in the coming-up list.
  • For reviewers

  • Migration: new table cash_flow_happened_marks, in 20261118120000_add_cash_flow_happened_marks. It matches what prisma migrate diff generates from the schema, and it must be applied to production before this ships.

  • API: POST /api/cash-flow/happened takes {source, sourceId, date} and returns 201 when saved, 200 when already marked, 404 when the item isn't listed, and 409 at the cap. DELETE /api/cash-flow/happened/:id undoes a mark. The server labels each mark from the user's own data (happenedTarget).

  • Limits: 100 marks per user, checked under a per-user advisory lock (namespace 872014274). Marks for days more than 45 days past are removed on the next save.

  • Known limit: for a weekly item marked four or more days before it is due, the posted check could take the previous week's posting for it. Pending deposits show a day or two early, so this was left simple.

  • Docs: "Items that already happened" in docs/CASH_FLOW_FORECAST.md, and a line in CLAUDE.md.
  • Testing

  • New: 27 engine tests (cash-flow-happened.test.ts), 7 route tests, 1 Ask Linc fact test and 4 page tests.

  • All 385 backend cash flow unit tests and all 1,066 frontend tests pass. Backend and frontend type checks and lint are clean.

  • 25 backend unit tests (feedback, market news, Plaid security) fail locally without a Postgres at localhost:5433, and fail the same on main.

  • Not checked in a browser.
  • 🤖 Generated with Claude Code

    Diff: 478 lines (+358 / -120) across 5 files Reviewer: ethanteng Review duration: 21m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 478 lines diff across 5 files
    0.46
    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.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #387"
    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: 45.8% (MEDIUM) · Higher = larger blast radius
    45.8%
    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: 18.1% · Safe to merge
    18.1%