Skip to content

Add cash-flow forecast report#46

Open
andrewzolotukhin wants to merge 5 commits into
mainfrom
feat/cash-flow-forecast
Open

Add cash-flow forecast report#46
andrewzolotukhin wants to merge 5 commits into
mainfrom
feat/cash-flow-forecast

Conversation

@andrewzolotukhin

@andrewzolotukhin andrewzolotukhin commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Original request

Implement the planned cash-flow forecast feature, then persist forecasts daily and add a UI force-regenerate control.

What changed

  • Added cash_flow_forecasts persistence keyed by user, local forecast date, forecast version, and input hash.
  • Refactored GET /api/stats/cash-flow-forecast to read the persisted daily forecast, return deterministic pending data when missing/stale, and enqueue background generation instead of blocking on OpenAI.
  • Added forecast generation jobs plus a public tokenized progress endpoint for API clients.
  • Added an hourly daily scheduler that creates today’s forecast for active users when missing.
  • Added POST /api/stats/cash-flow-forecast/jobs for forced regeneration.
  • Updated the forecast UI with a Generated timestamp, pending/failed/unavailable insight states, and a Regenerate button that starts a background job and polls the stored forecast until it refreshes.
  • Kept deterministic 30/90-day projections available even when AI is missing, pending, or failed.

Validation

  • npm run lint
  • npm run typecheck
  • npm test (71 files, 379 tests; rerun outside sandbox because runtime server tests bind 127.0.0.1)

GitHub checks

  • Lint and test: success
  • Deploy PR environment: success
  • Playwright e2e: success

Preview QA

Preview URL: https://xpenser-pr-046.cleverbrush.com

Passed browser QA on the deployed preview:

  • Logged in with the PR test user and opened /stats/forecast.
  • Confirmed persisted forecast renders with Generated timestamp and AI insight.
  • Clicked Regenerate; forecast completed, Generated timestamp advanced, AI insight refreshed, and the button re-enabled.
  • Confirmed 90-day toggle still updates forecast totals.
  • Browser console had no errors.

Notes

The preview proxy only forwards the existing scan WebSocket path today, so the forecast UI uses normal authenticated polling of the persisted forecast after starting a job. The API progress endpoint still exists for clients/environments that can connect to the WebSocket subscription path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant