Open-source personal finance manager. Self-hosted, privacy-first.
feat(reports): show when the cash-flow balance runs out (#1030)
Rhuan Barretof1d49a2f3939
diff --git a/backend/app/schemas/report.py b/backend/app/schemas/report.pyindex 0d9604bf..534ba213 100644--- a/backend/app/schemas/report.py+++ b/backend/app/schemas/report.py@@ -39,6 +39,13 @@ class ReportMeta(BaseModel):forecast_start_date: str | None = Nonebaseline_active: bool = Falsebaseline_lookback_days: int | None = None+ # Cash flow only. ``runway_date`` is the first day (YYYY-MM-DD) the+ # projected balance goes below zero, or None when it stays at or above+ # zero through the horizon. ``lowest_balance`` is the minimum projected+ # balance from today to the end of the horizon, on ``lowest_balance_date``.+ runway_date: str | None = None+ lowest_balance: float | None = None+ lowest_balance_date: str | None = Noneclass CategoryTrendItem(BaseModel):diff --git a/backend/app/services/report_service.py b/backend/app/services/report_service.pyindex 9e18b78d..80db7906 100644--- a/backend/app/services/report_service.py+++ b/backend/app/services/report_service.py@@ -1614,7 +1614,14 @@ async def get_cash_flow_report(# Forward walk: balance(d+1) = balance(d) + net_flow(d+1). Pending rows# already due are part of the projected starting position, not a second# dated flow in the future.+ #+ # The walk also tracks the runway: the first day the projected balance+ # drops below zero, and the lowest point of the horizon. Both are taken+ # from the daily walk so a dip inside a week or month still counts when+ # the chart is aggregated to a coarser interval.running = current_balance + pending_current_delta+ lowest_balance, lowest_balance_date = running, today+ runway_date: date | None = today if running < 0 else Nonecursor_d = todaywhile cursor_d < end:cursor_d = cursor_d + timedelta(days=1)@@ -1623,6 +1630,10 @@ async def get_cash_flow_report(daily_balance[cursor_d] = runningdaily_inflow[cursor_d] = bucket["inflow"]daily_outflow[cursor_d] = bucket["outflow"]+ if running < lowest_balance:+ lowest_balance, lowest_balance_date = running, cursor_d+ if runway_date is None and running < 0:+ runway_date = cursor_d# 5. Aggregate to interval.points = _date_points(chart_start, end, interval)@@ -1721,6 +1732,9 @@ async def get_cash_flow_report(forecast_start_date=_format_date_label(today, interval),baseline_active=baseline,baseline_lookback_days=baseline_lookback_days if baseline else None,+ runway_date=runway_date.isoformat() if runway_date else None,+ lowest_balance=round(lowest_balance, 2),+ lowest_balance_date=lowest_balance_date.isoformat(),)composition: list[ReportCompositionItem] = []diff --git a/backend/tests/test_report_service.py b/backend/tests/test_report_service.pyindex 45c073bf..e7ad5a99 100644--- a/backend/tests/test_report_service.py+++ b/backend/tests/test_report_service.py@@ -2258,6 +2258,91 @@ async def test_cash_flow_paycheck_timing_dip(assert end_pt.value > 0+async def test_cash_flow_runway_is_first_negative_day_even_when_aggregated(+ session: AsyncSession, test_user, test_workspace: User+):+ """Rent on day 5 overdraws the account until salary lands on day 15.+ The runway is the rent day and the lowest point is its balance, also on+ a monthly chart where the month-end balance is positive again."""+ account = await _make_manual_account(session, test_user.id, "CF Runway Dip")+ await _add_txn(+ session, test_user.id, account.id, 1000, "credit",+ date.today(), source="opening_balance",+ )+ next_month_first = _next_first_of_month(date.today())+ rent_day = next_month_first.replace(day=5)+ await _make_recurring(+ session, test_user.id, account.id,+ amount=1500, txn_type="debit", frequency="monthly",+ day_of_month=5, next_occurrence=rent_day, description="Rent",+ )+ await _make_recurring(+ session, test_user.id, account.id,+ amount=3000, txn_type="credit", frequency="monthly",+ day_of_month=15, next_occurrence=next_month_first.replace(day=15),+ description="Salary",+ )++ report = await get_cash_flow_report(+ session, test_workspace.id, test_user.id, months=2, interval="monthly",+ )++ assert all(p.value >= 0 for p in report.trend)+ assert report.meta.runway_date == rent_day.isoformat()+ assert report.meta.lowest_balance == -500.0+ assert report.meta.lowest_balance_date == rent_day.isoformat()+++async def test_cash_flow_runway_absent_when_balance_stays_positive(+ session: AsyncSession, test_user, test_workspace: User+):+ """A $200 monthly bill against $1000 never overdraws in 3 months: no+ runway date, and the lowest point is after the third bill."""+ account = await _make_manual_account(session, test_user.id, "CF Runway Safe")+ await _add_txn(+ session, test_user.id, account.id, 1000, "credit",+ date.today(), source="opening_balance",+ )+ nxt = _next_first_of_month(date.today())+ await _make_recurring(+ session, test_user.id, account.id,+ amount=200, txn_type="debit", frequency="monthly",+ day_of_month=1, next_occurrence=nxt,+ )++ report = await get_cash_flow_report(+ session, test_workspace.id, test_user.id, months=3, interval="daily",+ )++ assert report.meta.runway_date is None+ assert report.meta.lowest_balance == 400.0+ third_bill = _next_first_of_month(_next_first_of_month(nxt))+ assert report.meta.lowest_balance_date == third_bill.isoformat()+++async def test_cash_flow_runway_is_today_when_already_negative(+ session: AsyncSession, test_user, test_workspace: User+):+ """An account that is overdrawn today has already run out: the runway+ is today, and with no flows the lowest point is today's balance."""+ account = await _make_manual_account(session, test_user.id, "CF Runway Overdrawn")+ await _add_txn(+ session, test_user.id, account.id, 250, "debit",+ date.today(), source="opening_balance",+ )++ report = await get_cash_flow_report(+ session, test_workspace.id, test_user.id, months=1, interval="daily",+ )++ assert report.meta.runway_date == date.today().isoformat()+ assert report.meta.lowest_balance == -250.0+ assert report.meta.lowest_balance_date == date.today().isoformat()++@pytest.mark.asyncioasync def test_cash_flow_large_one_off_purchase(session: AsyncSession, test_user, test_workspace: Userdiff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.jsonindex 6abe2685..1fd4fbce 100644--- a/frontend/src/locales/de.json+++ b/frontend/src/locales/de.json@@ -1941,6 +1941,9 @@"inflowOutflow": "Einnahmen vs. Ausgaben","startingBalance": "Anfangssaldo","endingBalance": "Prognostizierter Saldo",+ "runwayNegativeOn": "Der Saldo wird am {{date}} negativ",+ "runwayAlreadyNegative": "Bereits im Minus",+ "lowestBalance": "Niedrigster Stand","projectedIncome": "Prognostizierte Einnahmen","projectedExpenses": "Prognostizierte Ausgaben","incomeExpenses": "Einnahmen vs. Ausgaben",diff --git a/frontend/src/locales/el.json b/frontend/src/locales/el.jsonindex 936ee8b4..a96927b6 100644--- a/frontend/src/locales/el.json+++ b/frontend/src/locales/el.json@@ -1996,6 +1996,9 @@"inflowOutflow": "Εισροές έναντι Εκροών","startingBalance": "Αρχικό υπόλοιπο","endingBalance": "Προβλεπόμενο υπόλοιπο",+ "runwayNegativeOn": "Το υπόλοιπο γίνεται αρνητικό στις {{date}}",+ "runwayAlreadyNegative": "Ήδη αρνητικό",+ "lowestBalance": "Χαμηλότερο υπόλοιπο","projectedIncome": "Προβλεπόμενα έσοδα","projectedExpenses": "Προβλεπόμενα έξοδα","incomeExpenses": "Έσοδα έναντι Εξόδων",diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.jsonindex b57396c9..4667137f 100644--- a/frontend/src/locales/en.json+++ b/frontend/src/locales/en.json@@ -1940,6 +1940,9 @@"inflowOutflow": "Inflow vs Outflow","startingBalance": "Starting Balance","endingBalance": "Projected Balance",+ "runwayNegativeOn": "Balance goes negative on {{date}}",+ "runwayAlreadyNegative": "Already negative",+ "lowestBalance": "Lowest balance","projectedIncome": "Projected Income","projectedExpenses": "Projected Expenses","incomeExpenses": "Income vs Expenses",diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.jsonindex 161f1767..aca3297f 100644--- a/frontend/src/locales/es.json+++ b/frontend/src/locales/es.json@@ -1944,6 +1944,9 @@"inflowOutflow": "Entrada vs. salida","startingBalance": "Saldo inicial","endingBalance": "Saldo proyectado",+ "runwayNegativeOn": "El saldo queda en negativo el {{date}}",+ "runwayAlreadyNegative": "Ya está en negativo",+ "lowestBalance": "Saldo mínimo","projectedIncome": "Ingresos proyectados","projectedExpenses": "Gastos proyectados","incomeExpenses": "Ingresos vs. gastos",diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.jsonindex 101700a8..059ee64c 100644--- a/frontend/src/locales/fr.json+++ b/frontend/src/locales/fr.json@@ -1944,6 +1944,9 @@"inflowOutflow": "Entrées vs sorties","startingBalance": "Solde de départ","endingBalance": "Solde projeté",+ "runwayNegativeOn": "Le solde devient négatif le {{date}}",+ "runwayAlreadyNegative": "Déjà négatif",+ "lowestBalance": "Solde le plus bas","projectedIncome": "Revenus projetés","projectedExpenses": "Dépenses projetées","incomeExpenses": "Revenus vs dépenses",diff --git a/frontend/src/locales/hi.json b/frontend/src/locales/hi.jsonindex 5a94b42c..957568b9 100644--- a/frontend/src/locales/hi.json+++ b/frontend/src/locales/hi.json@@ -1940,6 +1940,9 @@"inflowOutflow": "आवक बनाम जावक","startingBalance": "आरंभिक शेष राशि","endingBalance": "अनुमानित शेष राशि",+ "runwayNegativeOn": "{{date}} को शेष राशि ऋणात्मक हो जाती है",+ "runwayAlreadyNegative": "पहले से ऋणात्मक",+ "lowestBalance": "न्यूनतम शेष","projectedIncome": "अनुमानित आय","projectedExpenses": "अनुमानित खर्च","incomeExpenses": "आय बनाम खर्च",diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.jsonindex e5a0b672..c8fcb804 100644--- a/frontend/src/locales/it.json+++ b/frontend/src/locales/it.json@@ -1944,6 +1944,9 @@"inflowOutflow": "Entrate vs Uscite","startingBalance": "Saldo iniziale","endingBalance": "Saldo previsto",+ "runwayNegativeOn": "Il saldo diventa negativo il {{date}}",+ "runwayAlreadyNegative": "Già in negativo",+ "lowestBalance": "Saldo minimo","projectedIncome": "Entrate previste","projectedExpenses": "Spese previste","incomeExpenses": "Entrate vs Spese",diff --git a/frontend/src/locales/ja.json b/frontend/src/locales/ja.jsonindex b80a2b8a..5a005343 100644--- a/frontend/src/locales/ja.json+++ b/frontend/src/locales/ja.json@@ -1940,6 +1940,9 @@"inflowOutflow": "流入と流出","startingBalance": "期首残高","endingBalance": "予測残高",+ "runwayNegativeOn": "{{date}}に残高がマイナスになります",+ "runwayAlreadyNegative": "すでにマイナス",+ "lowestBalance": "最低残高","projectedIncome": "予測収入","projectedExpenses": "予測支出","incomeExpenses": "収入と支出",diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.jsonindex f50efad7..54b7403c 100644--- a/frontend/src/locales/nl.json+++ b/frontend/src/locales/nl.json@@ -1942,6 +1942,9 @@"inflowOutflow": "Instroom versus uitstroom","startingBalance": "Beginsaldo","endingBalance": "Geprojecteerd saldo",+ "runwayNegativeOn": "Het saldo wordt negatief op {{date}}",+ "runwayAlreadyNegative": "Al negatief",+ "lowestBalance": "Laagste saldo","projectedIncome": "Geprojecteerd inkomen","projectedExpenses": "Geprojecteerde uitgaven","incomeExpenses": "Inkomsten versus uitgaven",diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.jsonindex 40481e1c..806f93b0 100644--- a/frontend/src/locales/pl.json+++ b/frontend/src/locales/pl.json@@ -2029,6 +2029,9 @@"inflowOutflow": "Wpływy a wypływy","startingBalance": "Saldo początkowe","endingBalance": "Saldo prognozowane",+ "runwayNegativeOn": "Saldo spadnie poniżej zera {{date}}",+ "runwayAlreadyNegative": "Już na minusie",+ "lowestBalance": "Najniższe saldo","projectedIncome": "Prognozowane przychody","projectedExpenses": "Prognozowane wydatki","incomeExpenses": "Przychody a wydatki",diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.jsonindex f0740892..87a338d6 100644--- a/frontend/src/locales/pt-BR.json+++ b/frontend/src/locales/pt-BR.json@@ -1944,6 +1944,9 @@"inflowOutflow": "Entradas vs Saídas","startingBalance": "Saldo Atual","endingBalance": "Saldo Projetado",+ "runwayNegativeOn": "O saldo fica negativo em {{date}}",+ "runwayAlreadyNegative": "Já está negativo",+ "lowestBalance": "Menor saldo","projectedIncome": "Receita Projetada","projectedExpenses": "Despesa Projetada","incomeExpenses": "Receitas vs Despesas",diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.jsonindex 31e7132a..3c4d7a8d 100644--- a/frontend/src/locales/pt-PT.json+++ b/frontend/src/locales/pt-PT.json@@ -1944,6 +1944,9 @@"inflowOutflow": "Entradas vs Saídas","startingBalance": "Saldo Atual","endingBalance": "Saldo Projetado",+ "runwayNegativeOn": "O saldo fica negativo a {{date}}",+ "runwayAlreadyNegative": "Já está negativo",+ "lowestBalance": "Saldo mínimo","projectedIncome": "Receita Projetada","projectedExpenses": "Despesa Projetada","incomeExpenses": "Receitas vs Despesas",diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.jsonindex 9be292cb..2498465b 100644--- a/frontend/src/locales/ru.json+++ b/frontend/src/locales/ru.json@@ -1957,6 +1957,9 @@"inflowOutflow": "Поступления vs Списания","startingBalance": "Начальный баланс","endingBalance": "Прогнозируемый баланс",+ "runwayNegativeOn": "Баланс станет отрицательным {{date}}",+ "runwayAlreadyNegative": "Уже отрицательный",+ "lowestBalance": "Минимальный баланс","projectedIncome": "Прогнозируемый доход","projectedExpenses": "Прогнозируемые расходы","incomeExpenses": "Доходы vs Расходы",diff --git a/frontend/src/locales/sk.json b/frontend/src/locales/sk.jsonindex 73ece074..279b06b1 100644--- a/frontend/src/locales/sk.json+++ b/frontend/src/locales/sk.json@@ -2056,6 +2056,9 @@"inflowOutflow": "Prítok vs odtok","startingBalance": "Počiatočný zostatok","endingBalance": "Predpokladaný zostatok",+ "runwayNegativeOn": "Zostatok bude záporný {{date}}",+ "runwayAlreadyNegative": "Už v mínuse",+ "lowestBalance": "Najnižší zostatok","projectedIncome": "Predpokladaný príjem","projectedExpenses": "Predpokladané výdavky","incomeExpenses": "Príjmy vs výdavky",diff --git a/frontend/src/locales/uk.json b/frontend/src/locales/uk.jsonindex 964103a8..75aa883b 100644--- a/frontend/src/locales/uk.json+++ b/frontend/src/locales/uk.json@@ -1957,6 +1957,9 @@"inflowOutflow": "Надходження vs Списання","startingBalance": "Початковий баланс","endingBalance": "Прогнозований баланс",+ "runwayNegativeOn": "Баланс стане від'ємним {{date}}",+ "runwayAlreadyNegative": "Уже від’ємний",+ "lowestBalance": "Мінімальний баланс","projectedIncome": "Прогнозований дохід","projectedExpenses": "Прогнозовані витрати","incomeExpenses": "Доходи vs Витрати",diff --git a/frontend/src/pages/reports.test.tsx b/frontend/src/pages/reports.test.tsxindex 9ece384f..a7d2ab94 100644--- a/frontend/src/pages/reports.test.tsx+++ b/frontend/src/pages/reports.test.tsx@@ -1,5 +1,5 @@import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'-import { screen, waitFor } from '@testing-library/react'+import { cleanup, screen, waitFor } from '@testing-library/react'import ReportsPage from '@/pages/reports'import { renderWithProviders, t } from '@/test/utils'@@ -11,9 +11,13 @@ const api = vi.hoisted(() => ({incomeExpenses: vi.fn(),cashFlow: vi.fn(),},+ // The page reads the workspace timezone to tell a balance that is already+ // negative from one that crosses later. Unresolved here, which lands on the+ // browser's own day.+ timezones: { list: vi.fn().mockResolvedValue({ timezones: [], default: null }) },}))-vi.mock('@/lib/api', () => ({ reports: api.reports }))+vi.mock('@/lib/api', () => ({ reports: api.reports, timezones: api.timezones }))vi.mock('@/hooks/use-display-locale', () => ({useDisplayLocale: () => 'en-US',@@ -238,3 +242,95 @@ describe('Reports page — query failure', () => {expect(screen.getByRole('button', { name: t('reports.range6m') })).toHaveClass('bg-primary')})})++describe('Reports page, cash-flow runway', () => {+ async function openCashFlow(meta: Partial<ReportResponse['meta']>) {+ const report = emptyReport('cash_flow')+ api.reports.cashFlow.mockResolvedValue({ ...report, meta: { ...report.meta, ...meta } })+ const { user } = renderWithProviders(<ReportsPage />)+ await waitFor(() => expect(api.reports.netWorth).toHaveBeenCalled())+ await user.click(screen.getByRole('button', { name: t('reports.cashFlow') }))+ return screen.findByTestId('cash-flow-runway')+ }++ it('names the day the balance goes negative and its lowest point', async () => {+ const callout = await openCashFlow({+ runway_date: '2099-10-05',+ lowest_balance: -500,+ lowest_balance_date: '2099-12-20',+ })++ expect(callout).toHaveTextContent(t('reports.runwayNegativeOn', { date: 'Oct 5, 2099' }))+ expect(callout).toHaveTextContent('-$500.00')+ // Only the crossing date is shown: a second date next to the amount reads+ // as part of the same sentence rather than as the bottom of the dip.+ expect(callout).not.toHaveTextContent('Dec 20')+ })++ it('reads today in the workspace timezone, not the browser one', async () => {+ // 23:30 UTC on the 13th is already the 14th fourteen hours ahead, so the+ // same crossing date is "already negative" there and still ahead in UTC.+ vi.useFakeTimers({ shouldAdvanceTime: true })+ vi.setSystemTime(new Date('2026-10-13T23:30:00Z'))+ try {+ api.timezones.list.mockResolvedValue({ timezones: [], default: 'Pacific/Kiritimati' })+ const ahead = await openCashFlow({+ runway_date: '2026-10-14',+ lowest_balance: -10,+ lowest_balance_date: '2026-10-14',+ })+ await waitFor(() => expect(ahead).toHaveTextContent(t('reports.runwayAlreadyNegative')))++ cleanup()+ api.timezones.list.mockResolvedValue({ timezones: [], default: 'UTC' })+ const behind = await openCashFlow({+ runway_date: '2026-10-14',+ lowest_balance: -10,+ lowest_balance_date: '2026-10-14',+ })+ await waitFor(() =>+ expect(behind).toHaveTextContent(t('reports.runwayNegativeOn', { date: 'Oct 14' })),+ )+ } finally {+ vi.useRealTimers()+ api.timezones.list.mockResolvedValue({ timezones: [], default: null })+ }+ })++ it('says the balance is already negative rather than naming today', async () => {+ const callout = await openCashFlow({+ runway_date: '2020-01-02',+ lowest_balance: -500,+ lowest_balance_date: '2020-01-31',+ })++ expect(callout).toHaveTextContent(t('reports.runwayAlreadyNegative'))+ expect(callout).not.toHaveTextContent(t('reports.runwayNegativeOn', { date: 'Jan 2' }))+ })++ it.each([+ [400, '$400.00'],+ [0, '$0.00'],+ ])('reports a lowest balance of %d as never going below zero', async (lowest, amount) => {+ const callout = await openCashFlow({+ runway_date: null,+ lowest_balance: lowest,+ lowest_balance_date: '2026-12-01',+ })++ expect(callout).toHaveTextContent(t('reports.lowestBalance'))+ expect(callout).toHaveTextContent(amount)+ expect(callout).toHaveTextContent('Dec 1')+ })++ it('is not shown on the other tabs', async () => {+ api.reports.netWorth.mockResolvedValue({+ ...emptyReport('net_worth'),+ meta: { ...emptyReport('net_worth').meta, lowest_balance: 1, lowest_balance_date: '2026-10-01' },+ })+ renderWithProviders(<ReportsPage />)+ await screen.findAllByText('$1,000.00')++ expect(screen.queryByTestId('cash-flow-runway')).not.toBeInTheDocument()+ })+})diff --git a/frontend/src/pages/reports.tsx b/frontend/src/pages/reports.tsxindex 35ff1753..61fe2b18 100644--- a/frontend/src/pages/reports.tsx+++ b/frontend/src/pages/reports.tsx@@ -31,7 +31,8 @@ import { useAuth } from '@/contexts/auth-context'import { useCollectionFilter } from '@/contexts/collection-filter-context'import type { ReportResponse, CategoryTrendItem } from '@/types'import { formatCurrency } from '@/lib/format'-import { localDateString } from '@/lib/date-utils'+import { localDateString, todayInTimezone } from '@/lib/date-utils'+import { useEffectiveTimezone } from '@/hooks/use-timezone'// A small qualitative palette of well-separated hues for the composition// detail ring. Capped to a handful of slices, distinct colours make each@@ -176,6 +177,7 @@ const REPORT_TABS: ReportTab[] = []export default function ReportsPage() {+ const timeZone = useEffectiveTimezone()const { t } = useTranslation()const { mask, privacyMode, MASK } = usePrivacyMode()const { user } = useAuth()@@ -301,6 +303,29 @@ export default function ReportsPage() {} as Record<string, string | number | null>})+ // Cash-flow runway: the first projected day below zero and the lowest+ // point of the horizon, both computed day by day on the backend.+ const runwayDate = meta?.type === 'cash_flow' ? meta.runway_date ?? null : null+ const lowestBalance = meta?.type === 'cash_flow' ? meta.lowest_balance ?? null : null+ const lowestBalanceDate = meta?.type === 'cash_flow' ? meta.lowest_balance_date ?? null : null+ // The backend reports today as the runway date when the balance is already+ // below zero, which is a different thing to say than "it will go negative".+ // It reckons that day in the workspace's own timezone, so this has to as+ // well: a browser already past midnight would otherwise call tomorrow's+ // crossing a balance that is negative today.+ const alreadyNegative = runwayDate !== null && runwayDate <= todayInTimezone(timeZone)+ // Day and month are enough inside the current year; a longer horizon reaches+ // into the next one, where the year stops being obvious.+ const formatDay = (iso: string) => {+ const day = new Date(iso + 'T00:00:00')+ const sameYear = day.getFullYear() === new Date().getFullYear()+ return day.toLocaleDateString(locale, {+ day: 'numeric',+ month: 'short',+ ...(sameYear ? {} : { year: 'numeric' }),+ })+ }+const allBreakdowns = summary?.breakdowns ?? []const breakdownData = allBreakdowns.filter((b) => b.value > 0)@@ -718,6 +743,38 @@ export default function ReportsPage() {</p></div>))}+ {/* Cash flow only: the lowest point of the projection. It keeps+ one permanent slot and lets the label and the colour carry+ the state, instead of a banner that comes and goes. */}+ {lowestBalance !== null && lowestBalanceDate && (+ <div className="min-w-0" data-testid="cash-flow-runway">+ <div className="flex items-center gap-1.5 mb-0.5">+ <div+ className={`w-2.5 h-2.5 rounded-full shrink-0 ${runwayDate ? 'bg-rose-500' : 'bg-muted-foreground/40'}`}+ />+ <p className="text-xs font-medium text-muted-foreground">+ {!runwayDate+ ? t('reports.lowestBalance')+ : alreadyNegative+ ? t('reports.runwayAlreadyNegative')+ : t('reports.runwayNegativeOn', { date: formatDay(runwayDate) })}+ </p>+ </div>+ <p+ className={`text-lg font-bold tabular-nums ${runwayDate ? 'text-rose-600 dark:text-rose-400' : 'text-foreground'}`}+ >+ {mask(formatCurrency(lowestBalance, userCurrency, locale))}+ {/* The day the balance bottoms out, but only when the+ label is not already naming the day it crosses zero.+ Two dates side by side read as one fact, not two. */}+ {!runwayDate || alreadyNegative ? (+ <span className="ml-1.5 text-xs font-medium text-muted-foreground">+ {formatDay(lowestBalanceDate)}+ </span>+ ) : null}+ </p>+ </div>+ )}</div></div>)}@@ -881,6 +938,9 @@ export default function ReportsPage() {strokeDasharray="4 4"strokeOpacity={0.5}/>+ {lowestBalance !== null && lowestBalance < 0 && (+ <ReferenceLine y={0} stroke="#F43F5E" strokeOpacity={0.6} />+ )}{forecastStart && (<ReferenceLinex={forecastStart}diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex de94db27..860a84ea 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -1010,6 +1010,9 @@ export interface ReportMeta {forecast_start_date?: string | nullbaseline_active?: booleanbaseline_lookback_days?: number | null+ runway_date?: string | null+ lowest_balance?: number | null+ lowest_balance_date?: string | null}export interface ReportCompositionItem {