Skip to content

feat(portfolio): add monthly cash withdrawal & fix table column alignment - #3

Merged
Metee01 merged 2 commits into
mainfrom
feature/monthly-drawdown-calc
Aug 12, 2026
Merged

feat(portfolio): add monthly cash withdrawal & fix table column alignment#3
Metee01 merged 2 commits into
mainfrom
feature/monthly-drawdown-calc

Conversation

@Metee01

@Metee01 Metee01 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces monthly cash withdrawal simulation to the portfolio projection engine and fixes a column alignment bug in the detail table.


Changes

✨ Feature: Monthly Cash Withdrawal (monthlyWithdrawal)

Allows users to define a regular monthly cash withdrawal from the portfolio. The withdrawal is deducted from the portfolio balance after each month's compound growth, ensuring accurate long-term simulations.

  • ProjectionParams — new monthlyWithdrawal?: number field (default: 0)
  • ProjectionRow — new withdrawal: number field per row
  • ProjectionSummary — new totalWithdrawals and totalRealWithdrawals cumulative metrics
  • Engine (calculateProjection) — withdrawal deducted after each compound step: actualWithdrawal = min(balance, plannedWithdrawal)
  • Portfolio Form — new "Aylık Nakit Çekim" input field with tooltip
  • i18n — TR/EN translations added for form label, help text, and table column header
  • CSV ExportMonthly Withdrawal column and totals added to export
  • Tests — Test 9 added: 10,000 TL principal, 200 TL/month withdrawal, 0% return → expected final balance 7,600 TL ✅

🐛 Fix: Projection Table Column Alignment

  • Removed duplicate usdValueCol header that caused an 11-header / 10-cell mismatch

  • Corrected header order to strictly align with body column sequence:

    Period | DCA | Invested | Nominal Value | Nominal P&L | Real Value | Real P&L | Safe Withdrawal | Ref. FX Value | FX Rate


Verification

Check Result
npm run test ✅ All 9 engine tests + store tests passed
npm run build ✅ No type errors
npm run lint ✅ 0 errors

Introduce inflation-protected safe withdrawal calculations and surface them across the app. Adds calculateSafeWithdrawal() to inflation-adjust, integrates per-month safeWithdrawal/realSafeWithdrawal into calculateProjection (rows + summary totals), updates types, CSV export, table and summary card UI, tests, and i18n strings. Safe withdrawal is zero when returns <= inflation; amounts are rounded to 2 decimals for consistency.
- Remove duplicate usdValueCol header in ProjectionTable
- Reorder headers to strictly match tbody column sequence
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
money-trace Ready Ready Preview Aug 12, 2026 5:51pm

@Metee01
Metee01 merged commit abc84f1 into main Aug 12, 2026
3 checks passed
@Metee01
Metee01 deleted the feature/monthly-drawdown-calc branch August 13, 2026 10:31
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