feat: cash-flow forecast engine — 30/60/90 day projections (#70)#376
Open
i010542 wants to merge 1 commit intorohitdash08:mainfrom
Open
feat: cash-flow forecast engine — 30/60/90 day projections (#70)#376i010542 wants to merge 1 commit intorohitdash08:mainfrom
i010542 wants to merge 1 commit intorohitdash08:mainfrom
Conversation
…itdash08#70) - Add pure-TS forecast engine (cashflow.ts) with DAILY/WEEKLY/MONTHLY/YEARLY support - Handle past-due unpaid bills: ONCE maps to forecast start, recurring fast-forwards - Add CashflowForecast page with horizon selector, summary cards, bar chart, items table - Use react-query for data fetching with refresh button - Error state preserves header and reload controls - Add 17 unit tests covering all cadences, past-due, inactive, income, edge cases - Register /cashflow route and add nav link
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.
Problem Summary
No forecasting capability existed in FinMind, leaving users unable to anticipate future cash shortfalls or plan ahead based on recurring obligations.
Solution
A pure-TypeScript forecast engine that projects 30, 60, or 90 days of cash flow from recurring expenses and bills — no backend changes required.
Architecture
src/api/cashflow.ts— Pure forecast engine (no React, no side effects):generateForecast(recurringExpenses, bills, horizon, fromDate?)→ForecastPoint[]aggregateByWeek(points)→ weekly bucketed view for 60/90 day chartscomputeSummary(points)→ totals, best/worst daysrc/pages/CashflowForecast.tsx— React page using react-query:BarChart— daily for 30d, weekly aggregated for 60/90dForecast Logic
start_dateactive: falseend_dateexpense_type === 'INCOME'next_due_datepaid_atsetnext_due_date< todaynext_due_date< todayMONTHLY uses
date-fns/addMonths(calendar months, not ×30 days). YEARLY usesaddYears. Both anchor on the originalstart_dateto avoid drift.Acceptance Criteria
ForecastPoint[]withdate/outflow/inflow/netFlow/cumulativeNet/items)Test Evidence
17 new unit tests cover:
Files Changed
src/api/cashflow.tssrc/pages/CashflowForecast.tsxsrc/__tests__/cashflowEngine.test.tssrc/App.tsx/cashflowprotected routesrc/components/layout/Navbar.tsxResolves: #70