Early Retirement Feasibility Calculator
Your Profile & Goals
Savings & Investments
Retirement Expenses & Inflation
Feasibility Analysis
Your early retirement feasibility analysis will appear here.
Based on these projections, your funds may last approximately ${data.yearsFundLasts} years. This is less than your ${data.yearsInRetirement}-year retirement goal (until age ${data.lifeExpectancy}).
`; const shortfallYears = data.yearsInRetirement - data.yearsFundLasts; feasibilityMessage += `There's a potential shortfall of approximately ${shortfallYears} year(s).
`; } resultsDiv.innerHTML = `Retirement Projections:
Years until desired retirement (age ${data.desiredRetirementAge}): ${data.yearsToRetirement} years
Required retirement duration (until age ${data.lifeExpectancy}): ${data.yearsInRetirement} years
Projected value of current savings at retirement: $${data.fvCurrentSavings.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Projected value of future annual savings at retirement: $${data.fvAnnualSavings.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Total Projected Nest Egg at Retirement (age ${data.desiredRetirementAge}): $${data.totalNestEggAtRetirement.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Estimated First-Year Annual Expenses at Retirement (age ${data.desiredRetirementAge}, future dollars): $${data.firstYearRetirementExpenses.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
For reference, a 4% rule suggests a target nest egg of: $${data.fourPercentRuleTarget.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Feasibility:
${feasibilityMessage} `; } catch (error) { resultsDiv.innerHTML = `An error occurred during calculation: ${error.message}. Please check your inputs.
`; console.error(error); } } // --- PDF Generation --- function erfc_generatePdf() { const data = erfc_calculateAnalysis(); if (!data) { alert("Cannot generate PDF due to input errors. Please check the analysis tab."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); let yPos = 20; const primaryColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim(); const accentColor = getComputedStyle(document.documentElement).getPropertyValue('--accent-color').trim(); const dangerColor = getComputedStyle(document.documentElement).getPropertyValue('--danger-color').trim(); const textColor = getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim(); const toCurrency = (num) => `$${num.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; doc.setFontSize(20); doc.setTextColor(primaryColor); doc.text("Early Retirement Feasibility Analysis", doc.internal.pageSize.getWidth() / 2, yPos, { align: 'center' }); yPos += 15; function addSectionTitle(title) { if (yPos > 260) { doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.setTextColor(primaryColor); doc.text(title, 14, yPos); yPos += 8; doc.setFontSize(10); doc.setTextColor(textColor); } function addDataRow(label, value) { if (yPos > 275) { doc.addPage(); yPos = 20; } doc.text(`${label}:`, 14, yPos); doc.text(String(value), 100, yPos); yPos += 7; } addSectionTitle("Your Profile & Goals"); addDataRow("Current Age", `${data.currentAge} years`); addDataRow("Desired Retirement Age", `${data.desiredRetirementAge} years`); addDataRow("Life Expectancy", `${data.lifeExpectancy} years`); addDataRow("Years to Retirement", `${data.yearsToRetirement} years`); addDataRow("Required Retirement Duration", `${data.yearsInRetirement} years`); addSectionTitle("Savings & Investments Inputs"); addDataRow("Current Savings/Investments", toCurrency(data.currentSavingsBalance)); addDataRow("Annual Savings Amount", toCurrency(data.annualSavingsAmount)); addDataRow("Pre-Retirement Return Rate", `${data.preRetirementReturnRate.toFixed(2)}%`); addDataRow("Post-Retirement Return Rate", `${data.postRetirementReturnRate.toFixed(2)}%`); addSectionTitle("Retirement Expenses & Inflation Inputs"); addDataRow("Current Annual Retirement Expenses (Today's $)", toCurrency(data.currentAnnualRetirementExpenses)); addDataRow("Expected Annual Inflation Rate", `${data.inflationRate.toFixed(2)}%`); addSectionTitle("Projected Financials at Retirement (Age " + data.desiredRetirementAge + ")"); addDataRow("FV of Current Savings", toCurrency(data.fvCurrentSavings)); addDataRow("FV of Annual Savings", toCurrency(data.fvAnnualSavings)); addDataRow("Total Projected Nest Egg", toCurrency(data.totalNestEggAtRetirement)); addDataRow("Est. First-Year Retirement Expenses (Future $)", toCurrency(data.firstYearRetirementExpenses)); addDataRow("Target Nest Egg (4% Rule)", toCurrency(data.fourPercentRuleTarget)); addSectionTitle("Retirement Feasibility"); if (data.yearsFundLasts >= data.yearsInRetirement) { doc.setTextColor(accentColor); addDataRow("Projected Fund Longevity", `Approx. ${data.yearsFundLasts} years (Meets or Exceeds Goal)`); } else { doc.setTextColor(dangerColor); addDataRow("Projected Fund Longevity", `Approx. ${data.yearsFundLasts} years (Potential Shortfall of ${data.yearsInRetirement - data.yearsFundLasts} yrs)`); } doc.setTextColor(textColor); doc.save('early_retirement_feasibility.pdf'); } // Initialize document.addEventListener('DOMContentLoaded', () => { erfc_showTab(0); // Default values are set in the HTML. });