/* FinPulse — Calculators (SIP / Lumpsum / SWP). Exports CalcScreen to window. */
const INR = (n) => '₹' + Math.round(n).toLocaleString('en-IN');
function CalcSlider({ label, value, min, max, step, onChange, fmtv }) {
const pct = ((value - min) / (max - min)) * 100;
return (
);
}
function DonutResult({ invested, gains }) {
const total = invested + gains;
const r = 52, c = 2 * Math.PI * r;
const gFrac = total > 0 ? gains / total : 0;
return (
Invested{INR(invested)}
Est. returns{INR(gains)}
Total value{INR(total)}
);
}
function CalcScreen() {
const [tab, setTab] = useState('sip');
const [monthly, setMonthly] = useState(15000);
const [lump, setLump] = useState(500000);
const [rate, setRate] = useState(12);
const [years, setYears] = useState(10);
const [withdraw, setWithdraw] = useState(20000);
// SIP future value
const months = years * 12;
const i = rate / 100 / 12;
let invested, total, series = [];
if (tab === 'sip') {
total = monthly * ((Math.pow(1 + i, months) - 1) / (i || 1)) * (1 + i);
invested = monthly * months;
for (let y = 1; y <= years; y++) { const m = y * 12; series.push(monthly * ((Math.pow(1 + i, m) - 1) / (i || 1)) * (1 + i)); }
} else if (tab === 'lump') {
total = lump * Math.pow(1 + rate / 100, years);
invested = lump;
for (let y = 1; y <= years; y++) series.push(lump * Math.pow(1 + rate / 100, y));
} else { // SWP
invested = lump;
let bal = lump;
for (let y = 1; y <= years; y++) {
for (let m = 0; m < 12; m++) { bal = bal * (1 + i) - withdraw; }
series.push(Math.max(bal, 0));
}
total = Math.max(bal, 0);
}
const gains = Math.max(total - invested, 0);
return (
Calculators
Plan SIPs, lumpsum growth & systematic withdrawals
{[['sip', 'SIP'], ['lump', 'Lumpsum'], ['swp', 'SWP']].map(([k, l]) => (
))}
{/* inputs */}
{tab === 'sip' &&
}
{(tab === 'lump' || tab === 'swp') &&
}
{tab === 'swp' &&
}
v + '%'} />
v + (v === 1 ? ' yr' : ' yrs')} />
{/* projection chart */}
{tab === 'swp' ? 'Corpus over time' : 'Projected growth'}
{tab === 'swp' ? 'Balance after monthly withdrawals' : `Value after ${years} years`}
1 ? series : [0, ...series]} color="var(--accent)" height={200}
labels={['Yr 1', '', `Yr ${Math.ceil(years / 2)}`, '', `Yr ${years}`]} />
Invested{INR(invested)}
{tab === 'swp' ? 'Total withdrawn' : 'Est. returns'}{tab === 'swp' ? INR(withdraw * months) : INR(gains)}
{tab === 'swp' ? 'Balance left' : 'Total value'}{INR(total)}
);
}
Object.assign(window, { CalcScreen });