@retiregolden/planner-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +181 -0
- package/package.json +77 -0
- package/src/App.tsx +246 -0
- package/src/RouteErrorBoundary.tsx +45 -0
- package/src/assets/hero.png +0 -0
- package/src/assets/react.svg +1 -0
- package/src/assets/vite.svg +1 -0
- package/src/data/fedInvestClient.ts +113 -0
- package/src/data/localStore.ts +42 -0
- package/src/data/planOrigin.ts +24 -0
- package/src/data/planStore.ts +165 -0
- package/src/data/v2Backup.ts +101 -0
- package/src/import/ImportPage.tsx +347 -0
- package/src/import/ReviewChecklistView.tsx +38 -0
- package/src/import/brokerCsv.ts +395 -0
- package/src/import/csv.ts +133 -0
- package/src/import/genericCsv.ts +224 -0
- package/src/import/projectionLab.ts +350 -0
- package/src/import/reviewChecklist.ts +33 -0
- package/src/import/tenForty.ts +275 -0
- package/src/index.css +630 -0
- package/src/index.ts +16 -0
- package/src/learn/ArticleBody.tsx +78 -0
- package/src/learn/ArticlePage.tsx +57 -0
- package/src/learn/GlossaryPage.tsx +33 -0
- package/src/learn/LearnAboutScreen.tsx +41 -0
- package/src/learn/LearnCards.tsx +41 -0
- package/src/learn/LearnLink.tsx +91 -0
- package/src/learn/LearningCenterPage.tsx +114 -0
- package/src/learn/SourcesPage.tsx +98 -0
- package/src/learn/components/ArticleFigure.tsx +34 -0
- package/src/learn/components/ArticleShell.tsx +86 -0
- package/src/learn/components/ComparisonTable.tsx +42 -0
- package/src/learn/components/FormulaBlock.tsx +34 -0
- package/src/learn/components/PurchasingPowerChart.tsx +41 -0
- package/src/learn/components/RelatedArticles.tsx +27 -0
- package/src/learn/components/ScenarioCard.tsx +24 -0
- package/src/learn/components/SourceList.tsx +23 -0
- package/src/learn/components/charts.tsx +21 -0
- package/src/learn/content/about-retiregolden.ts +100 -0
- package/src/learn/content/aca-premium-tax-credits-and-magi.ts +103 -0
- package/src/learn/content/account-types-overview.ts +106 -0
- package/src/learn/content/after-tax-estate.ts +111 -0
- package/src/learn/content/agi-magi-and-taxable-income.ts +112 -0
- package/src/learn/content/appealing-irmaa-ssa-44.ts +95 -0
- package/src/learn/content/assumption-general-inflation.ts +82 -0
- package/src/learn/content/assumption-healthcare-inflation.ts +85 -0
- package/src/learn/content/assumption-heir-tax-rate.ts +79 -0
- package/src/learn/content/assumption-investment-returns.ts +90 -0
- package/src/learn/content/assumption-longevity-planning-age.ts +78 -0
- package/src/learn/content/assumption-recent-magi.ts +83 -0
- package/src/learn/content/assumption-social-security-cola.ts +89 -0
- package/src/learn/content/assumption-social-security-trust-fund.ts +83 -0
- package/src/learn/content/assumption-state-tax-override.ts +79 -0
- package/src/learn/content/beneficiaries-and-account-titling.ts +99 -0
- package/src/learn/content/break-even-useful-lens.ts +94 -0
- package/src/learn/content/building-a-retirement-spending-budget.ts +100 -0
- package/src/learn/content/cola-and-inflation-protection.ts +102 -0
- package/src/learn/content/divorced-spousal-and-survivor-records.ts +104 -0
- package/src/learn/content/dynamic-spending-guardrails.ts +90 -0
- package/src/learn/content/earnings-test-before-fra.ts +100 -0
- package/src/learn/content/employer-match-and-contribution-order.ts +104 -0
- package/src/learn/content/examplePlanArticles.ts +525 -0
- package/src/learn/content/fees-expense-ratios-and-compounding-drag.ts +98 -0
- package/src/learn/content/fi-number-and-four-percent-rule.ts +64 -0
- package/src/learn/content/filling-a-tax-bracket-with-roth-conversions.ts +98 -0
- package/src/learn/content/funded-ratio.ts +70 -0
- package/src/learn/content/healthcare-after-65.ts +103 -0
- package/src/learn/content/healthcare-before-65.ts +104 -0
- package/src/learn/content/historical-vs-random-return-models.ts +101 -0
- package/src/learn/content/how-assumptions-change-the-answer.ts +105 -0
- package/src/learn/content/how-much-can-i-spend.ts +105 -0
- package/src/learn/content/how-social-security-is-taxed.ts +95 -0
- package/src/learn/content/how-the-optimizer-thinks.ts +102 -0
- package/src/learn/content/how-the-optimizer-values-after-tax-estate.ts +97 -0
- package/src/learn/content/how-to-model-accumulation.ts +67 -0
- package/src/learn/content/how-to-read-a-retirement-projection.ts +115 -0
- package/src/learn/content/hsas-and-qualified-medical-expenses.ts +108 -0
- package/src/learn/content/hsas-as-retirement-accounts.ts +101 -0
- package/src/learn/content/inflation-risk.ts +98 -0
- package/src/learn/content/inherited-ira-10-year-rule.ts +105 -0
- package/src/learn/content/insurance-in-your-retirement-plan.ts +103 -0
- package/src/learn/content/irmaa-two-year-lookback.ts +99 -0
- package/src/learn/content/long-term-care-costs-and-insurance.ts +103 -0
- package/src/learn/content/long-term-care-insurance-as-risk-transfer.ts +98 -0
- package/src/learn/content/longevity-risk.ts +99 -0
- package/src/learn/content/marginal-vs-effective-tax-rate.ts +98 -0
- package/src/learn/content/medicare-part-b-vs-part-d-irmaa.ts +102 -0
- package/src/learn/content/mortality-weighted-social-security.ts +113 -0
- package/src/learn/content/moving-to-retiregolden.ts +86 -0
- package/src/learn/content/niit-high-income-investment-tax.ts +98 -0
- package/src/learn/content/ordinary-income-vs-capital-gains.ts +103 -0
- package/src/learn/content/paying-conversion-taxes-taxable-vs-ira.ts +102 -0
- package/src/learn/content/pensions-and-annuities.ts +101 -0
- package/src/learn/content/permanent-life-insurance-in-a-plan.ts +106 -0
- package/src/learn/content/pia-aime-and-bend-points.ts +103 -0
- package/src/learn/content/planner-overview.ts +106 -0
- package/src/learn/content/planning-for-couples-and-survivor-years.ts +108 -0
- package/src/learn/content/privacy-what-stays-in-your-browser.ts +99 -0
- package/src/learn/content/qcds-qualified-charitable-distributions.ts +101 -0
- package/src/learn/content/reading-the-results-page.ts +96 -0
- package/src/learn/content/reading-the-social-security-analysis-page.ts +106 -0
- package/src/learn/content/real-estate-home-equity-and-debt.ts +100 -0
- package/src/learn/content/reports-csv-exports-and-sharing.ts +101 -0
- package/src/learn/content/risk-based-guardrails.ts +100 -0
- package/src/learn/content/rmds-required-minimum-distributions.ts +100 -0
- package/src/learn/content/roth-conversion-basics.ts +104 -0
- package/src/learn/content/rsus-and-espp.ts +101 -0
- package/src/learn/content/rule-of-55-and-72t.ts +107 -0
- package/src/learn/content/savings-rate-biggest-lever.ts +66 -0
- package/src/learn/content/seed-your-plan-from-your-tax-return.ts +93 -0
- package/src/learn/content/sensitivity-testing-what-changes-the-answer.ts +104 -0
- package/src/learn/content/sequence-of-returns-risk.ts +98 -0
- package/src/learn/content/social-security-bridge.ts +67 -0
- package/src/learn/content/social-security-claiming-age-basics.ts +113 -0
- package/src/learn/content/social-security-taxes-vs-benefits.ts +76 -0
- package/src/learn/content/spending-profiles-and-the-retirement-smile.ts +92 -0
- package/src/learn/content/spousal-and-survivor-benefits.ts +120 -0
- package/src/learn/content/ssdi-and-retirement-planning.ts +72 -0
- package/src/learn/content/standard-deduction-senior-deduction-and-itemizing.ts +97 -0
- package/src/learn/content/state-income-taxes-in-retirement.ts +97 -0
- package/src/learn/content/step-up-in-basis.ts +102 -0
- package/src/learn/content/survivor-planning-for-couples.ts +110 -0
- package/src/learn/content/survivor-spending-in-couple-plans.ts +98 -0
- package/src/learn/content/tax-cliffs-and-bracket-edges.ts +105 -0
- package/src/learn/content/tax-loss-and-gain-harvesting.ts +99 -0
- package/src/learn/content/taxable-brokerage-basis-and-capital-gains.ts +99 -0
- package/src/learn/content/three-big-questions-spending-time-risk.ts +103 -0
- package/src/learn/content/tips-ladders.ts +92 -0
- package/src/learn/content/todays-dollars-vs-future-dollars.ts +107 -0
- package/src/learn/content/traditional-vs-roth-contributions.ts +113 -0
- package/src/learn/content/troubleshooting-surprising-results.ts +105 -0
- package/src/learn/content/trust-fund-haircut-scenarios.ts +101 -0
- package/src/learn/content/understanding-monte-carlo-success-rate.ts +118 -0
- package/src/learn/content/understanding-your-plan-assumptions.ts +134 -0
- package/src/learn/content/using-assumptions-and-provenance.ts +98 -0
- package/src/learn/content/using-scenarios-to-compare-choices.ts +99 -0
- package/src/learn/content/what-changes-when-you-move-states.ts +141 -0
- package/src/learn/content/what-is-fire.ts +65 -0
- package/src/learn/content/what-monte-carlo-proves.ts +98 -0
- package/src/learn/content/what-retiregolden-models.ts +103 -0
- package/src/learn/content/what-retirement-healthcare-really-costs.ts +117 -0
- package/src/learn/content/why-95-percent-is-not-a-guarantee.ts +98 -0
- package/src/learn/content/why-roth-conversions-raise-other-costs.ts +106 -0
- package/src/learn/content/why-small-tax-cliffs-can-matter.ts +109 -0
- package/src/learn/content/widows-penalty-and-survivor-brackets.ts +106 -0
- package/src/learn/content/withdrawal-order-basics.ts +105 -0
- package/src/learn/glossary.ts +191 -0
- package/src/learn/inlineMarkdown.tsx +54 -0
- package/src/learn/learn.css +537 -0
- package/src/learn/learningRegistry.ts +502 -0
- package/src/longevity/LongevityResults.tsx +85 -0
- package/src/longevity/LongevityWizard.tsx +305 -0
- package/src/longevity/constants.ts +15 -0
- package/src/longevity/factors.ts +125 -0
- package/src/longevity/model.ts +31 -0
- package/src/longevity/persistedGuard.ts +129 -0
- package/src/longevity/storage.ts +40 -0
- package/src/mc/messages.ts +118 -0
- package/src/mc/monteCarlo.worker.ts +44 -0
- package/src/mc/pool.ts +267 -0
- package/src/mc/runRequest.ts +125 -0
- package/src/optimize/messages.ts +84 -0
- package/src/optimize/optimize.worker.ts +29 -0
- package/src/optimize/runOptimize.ts +92 -0
- package/src/optimize/runSpendingSolve.ts +47 -0
- package/src/optimize/runner.ts +21 -0
- package/src/optimize/spendingMessages.ts +44 -0
- package/src/optimize/spendingRunner.ts +21 -0
- package/src/optimize/spendingSolve.worker.ts +18 -0
- package/src/planner/AssumptionsCardPage.tsx +136 -0
- package/src/planner/BucketLensCard.tsx +114 -0
- package/src/planner/ComparePlansPage.tsx +219 -0
- package/src/planner/DisclaimerPage.tsx +88 -0
- package/src/planner/HowTestedPage.tsx +159 -0
- package/src/planner/LiveStatus.tsx +15 -0
- package/src/planner/LongevityModal.tsx +55 -0
- package/src/planner/Modal.tsx +97 -0
- package/src/planner/MonteCarloPage.tsx +907 -0
- package/src/planner/OptimizePage.tsx +611 -0
- package/src/planner/PlanContext.tsx +198 -0
- package/src/planner/PlanPickerPage.tsx +124 -0
- package/src/planner/PlanWorkspace.tsx +290 -0
- package/src/planner/ProvenancePanel.tsx +45 -0
- package/src/planner/RelocationComparePage.tsx +485 -0
- package/src/planner/ReportPage.tsx +375 -0
- package/src/planner/ResultsPage.tsx +817 -0
- package/src/planner/ScenariosPage.tsx +285 -0
- package/src/planner/SocialSecuritySection.tsx +556 -0
- package/src/planner/SpendingSolverPage.tsx +512 -0
- package/src/planner/SsAnalysisPage.tsx +1134 -0
- package/src/planner/SurvivalPercentileModal.tsx +161 -0
- package/src/planner/SurvivorTransitionPage.tsx +286 -0
- package/src/planner/assumptionsExport.ts +371 -0
- package/src/planner/bucketLens.ts +89 -0
- package/src/planner/chartFrame.ts +8 -0
- package/src/planner/chartStyle.ts +11 -0
- package/src/planner/dialogViews.tsx +184 -0
- package/src/planner/dialogs.tsx +133 -0
- package/src/planner/examples/ExampleLibrary.tsx +189 -0
- package/src/planner/examples/ExamplePreviewBanner.tsx +55 -0
- package/src/planner/examples/ExamplesPage.tsx +25 -0
- package/src/planner/examples/OpenExampleButton.tsx +61 -0
- package/src/planner/examples/buildAggressiveSaver.ts +102 -0
- package/src/planner/examples/buildAnnuityEstate.ts +137 -0
- package/src/planner/examples/buildBaristaFire.ts +115 -0
- package/src/planner/examples/buildBracketFillRoth.ts +65 -0
- package/src/planner/examples/buildBridgeEarlyRetirement.ts +94 -0
- package/src/planner/examples/buildBrokerageNoHsa.ts +109 -0
- package/src/planner/examples/buildCoastFire.ts +88 -0
- package/src/planner/examples/buildContext.ts +20 -0
- package/src/planner/examples/buildEarlyCareerMatch.ts +93 -0
- package/src/planner/examples/buildEarlyRetireeAca.ts +61 -0
- package/src/planner/examples/buildExampleCouple.ts +103 -0
- package/src/planner/examples/buildFixedTargetSpending.ts +74 -0
- package/src/planner/examples/buildGlidepathAllocation.ts +131 -0
- package/src/planner/examples/buildGuardrailsFlex.ts +120 -0
- package/src/planner/examples/buildHsaPropertyDepth.ts +109 -0
- package/src/planner/examples/buildHsaStealthRetirement.ts +97 -0
- package/src/planner/examples/buildLeanFatFire.ts +109 -0
- package/src/planner/examples/buildLtcShock.ts +62 -0
- package/src/planner/examples/buildMovingStateTax.ts +53 -0
- package/src/planner/examples/buildNoAnnuityBrokerage.ts +92 -0
- package/src/planner/examples/buildRmdIrmaa.ts +55 -0
- package/src/planner/examples/buildSalaryGrowthEscalation.ts +96 -0
- package/src/planner/examples/buildStaticAllocationControl.ts +96 -0
- package/src/planner/examples/buildSurvivorYears.ts +62 -0
- package/src/planner/examples/buildUnderSavedSingle.ts +51 -0
- package/src/planner/examples/exampleCopy.ts +23 -0
- package/src/planner/examples/loadExample.ts +90 -0
- package/src/planner/examples/registry.ts +313 -0
- package/src/planner/explainPanels.tsx +233 -0
- package/src/planner/fields.tsx +381 -0
- package/src/planner/format.ts +33 -0
- package/src/planner/home/DataAndPrivacyCard.tsx +56 -0
- package/src/planner/home/GettingStartedPaths.tsx +46 -0
- package/src/planner/home/GettingStartedReopener.tsx +32 -0
- package/src/planner/home/StartHereLinks.tsx +22 -0
- package/src/planner/home/WelcomeHero.tsx +39 -0
- package/src/planner/home/YourPlans.tsx +72 -0
- package/src/planner/home/importErrorMessage.ts +22 -0
- package/src/planner/home/startHereSlugs.ts +7 -0
- package/src/planner/home/useHomeData.ts +190 -0
- package/src/planner/home/useHomeMode.ts +47 -0
- package/src/planner/householdActions.ts +22 -0
- package/src/planner/insights/InsightCardView.tsx +340 -0
- package/src/planner/insights/InsightsPage.tsx +204 -0
- package/src/planner/insights/categoryLabels.ts +11 -0
- package/src/planner/learnLinks.ts +85 -0
- package/src/planner/marketModelPicker.ts +172 -0
- package/src/planner/optimizePageChart.ts +40 -0
- package/src/planner/optimizePageClaim.ts +64 -0
- package/src/planner/planCompleteness.ts +27 -0
- package/src/planner/planContextCore.ts +26 -0
- package/src/planner/planner.css +2304 -0
- package/src/planner/provenanceLinks.ts +25 -0
- package/src/planner/sections/AccountFields.tsx +872 -0
- package/src/planner/sections/AccountsSection.tsx +89 -0
- package/src/planner/sections/AllocationPanel.tsx +261 -0
- package/src/planner/sections/AssumptionsSection.tsx +256 -0
- package/src/planner/sections/HouseholdSection.tsx +243 -0
- package/src/planner/sections/IncomeFloorSection.tsx +418 -0
- package/src/planner/sections/IncomeSection.tsx +170 -0
- package/src/planner/sections/InsuranceSection.tsx +362 -0
- package/src/planner/sections/SpendingSection.tsx +904 -0
- package/src/planner/sections/StrategySection.tsx +349 -0
- package/src/planner/sections/UpdateBalancesPanel.tsx +182 -0
- package/src/planner/sections/sectionHelpers.ts +48 -0
- package/src/planner/sections/shared.tsx +15 -0
- package/src/planner/sections.tsx +15 -0
- package/src/planner/ssAnalysis.ts +325 -0
- package/src/planner/successBand.ts +20 -0
- package/src/planner/survivorAnalysis.ts +277 -0
- package/src/planner/usStates.ts +19 -0
- package/src/planner/useMcSuccessRate.ts +77 -0
- package/src/planner/useProjection.ts +63 -0
- package/src/relocation/messages.ts +21 -0
- package/src/relocation/relocation.worker.ts +18 -0
- package/src/relocation/runRelocation.ts +17 -0
- package/src/relocation/runner.ts +22 -0
- package/src/report/brandingContext.ts +15 -0
- package/src/report/downloadReport.ts +34 -0
- package/src/report/reportHtml.ts +547 -0
- package/src/routes/LearnRoutes.tsx +46 -0
- package/src/routes/PlanRoutes.tsx +55 -0
- package/src/routes/RouteFallback.tsx +9 -0
- package/src/socialSecurity/breakEven.ts +107 -0
- package/src/socialSecurity/expectedPv.ts +164 -0
- package/src/socialSecurity/explain.ts +92 -0
- package/src/socialSecurity/ficaReturn.ts +81 -0
- package/src/socialSecurity/persistedSsGuard.ts +138 -0
- package/src/socialSecurity/ssFormUtils.ts +48 -0
- package/src/socialSecurity/ssaStatementXml.ts +156 -0
- package/src/socialSecurity/storage.ts +69 -0
- package/src/socialSecurity/survivorSwitching.ts +153 -0
- package/src/testSupport/samplePlan.ts +2 -0
- package/src/workers/run.ts +45 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print-styled plan report. A standalone route (outside the workspace shell)
|
|
3
|
+
* that lays out the whole plan — inputs, assumptions, headline results, and
|
|
4
|
+
* the year-by-year appendix — for the browser's print-to-PDF. Replaces the
|
|
5
|
+
* old jspdf/html2canvas path with native print CSS.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Link, useParams } from 'react-router-dom'
|
|
9
|
+
import {
|
|
10
|
+
Area,
|
|
11
|
+
AreaChart,
|
|
12
|
+
Bar,
|
|
13
|
+
BarChart,
|
|
14
|
+
CartesianGrid,
|
|
15
|
+
Legend,
|
|
16
|
+
Line,
|
|
17
|
+
LineChart,
|
|
18
|
+
Tooltip,
|
|
19
|
+
XAxis,
|
|
20
|
+
YAxis,
|
|
21
|
+
} from 'recharts'
|
|
22
|
+
|
|
23
|
+
import type { Account, IncomeStream, Plan } from '@retiregolden/engine/model/plan'
|
|
24
|
+
import type { YearResult } from '@retiregolden/engine/projection/types'
|
|
25
|
+
import { downloadStandaloneReport } from '../report/downloadReport'
|
|
26
|
+
import { useReportBranding } from '../report/brandingContext'
|
|
27
|
+
import { PlanProvider } from './PlanContext'
|
|
28
|
+
import { usePlan } from './planContextCore'
|
|
29
|
+
import { fmtMoney, fmtMoneyCompact, fmtPct } from './format'
|
|
30
|
+
import { useProjection } from './useProjection'
|
|
31
|
+
import { US_STATES } from './usStates'
|
|
32
|
+
|
|
33
|
+
const CATEGORIES = ['cash', 'taxable', 'equityComp', 'traditional', 'roth', 'hsa'] as const
|
|
34
|
+
const CAT_LABEL: Record<(typeof CATEGORIES)[number], string> = {
|
|
35
|
+
cash: 'Cash',
|
|
36
|
+
taxable: 'Taxable',
|
|
37
|
+
equityComp: 'Equity comp',
|
|
38
|
+
traditional: 'Traditional',
|
|
39
|
+
roth: 'Roth',
|
|
40
|
+
hsa: 'HSA',
|
|
41
|
+
}
|
|
42
|
+
const CAT_COLOR: Record<(typeof CATEGORIES)[number], string> = {
|
|
43
|
+
cash: 'var(--chart-5)',
|
|
44
|
+
taxable: 'var(--chart-2)',
|
|
45
|
+
equityComp: 'var(--chart-6)',
|
|
46
|
+
traditional: 'var(--chart-3)',
|
|
47
|
+
roth: 'var(--chart-1)',
|
|
48
|
+
hsa: 'var(--chart-4)',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ACCOUNT_LABEL: Record<Account['type'], string> = {
|
|
52
|
+
cash: 'Cash', taxable: 'Brokerage', equityComp: 'Equity comp', traditional: 'Traditional', roth: 'Roth', hsa: 'HSA',
|
|
53
|
+
pension: 'Pension', annuity: 'Annuity', property: 'Property', debt: 'Debt',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ownerName(plan: Plan, ownerPersonId: string | null): string {
|
|
57
|
+
if (ownerPersonId === null) return 'Joint'
|
|
58
|
+
return plan.household.people.find((p) => p.id === ownerPersonId)?.name ?? '—'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function stateName(code: string): string {
|
|
62
|
+
return US_STATES.find((s) => s.value === code)?.label ?? code
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function accountBalance(a: Account): number {
|
|
66
|
+
if ('balance' in a) return a.balance
|
|
67
|
+
if (a.type === 'property') return a.value
|
|
68
|
+
return 0
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function incomeLabel(plan: Plan, s: IncomeStream): string {
|
|
72
|
+
if (s.type === 'wages') return `Wages — ${ownerName(plan, s.personId)}`
|
|
73
|
+
if (s.type === 'socialSecurity') return `Social Security — ${ownerName(plan, s.personId)}`
|
|
74
|
+
return s.label
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function incomeDetail(s: IncomeStream): string {
|
|
78
|
+
switch (s.type) {
|
|
79
|
+
case 'wages':
|
|
80
|
+
return `${fmtMoney(s.annualGross)}/yr until ${s.endAge ?? 'retirement'}`
|
|
81
|
+
case 'socialSecurity':
|
|
82
|
+
return `${s.piaMonthly !== null ? `${fmtMoney(s.piaMonthly)}/mo PIA` : 'from earnings record'}, claim ${s.claimAge.years}y${s.claimAge.months ? ` ${s.claimAge.months}m` : ''}`
|
|
83
|
+
case 'recurring':
|
|
84
|
+
return `${fmtMoney(s.annualAmount)}/yr${s.inflationAdjusted ? ', inflation-adjusted' : ''}`
|
|
85
|
+
case 'oneTime':
|
|
86
|
+
return `${fmtMoney(s.amount)} in ${s.year}`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function conversionSummary(plan: Plan): string {
|
|
91
|
+
const rc = plan.strategies.rothConversion
|
|
92
|
+
if (rc.mode === 'none') return 'None'
|
|
93
|
+
if (rc.mode === 'manual') return `Manual — ${rc.conversions.length} year(s)`
|
|
94
|
+
if (rc.mode === 'optimized') return `Optimized — ${rc.conversions.length} year(s)`
|
|
95
|
+
return `Fill to ${rc.target}${rc.targetValue !== null ? ` (${rc.targetValue})` : ''}, ${rc.startYear}–${rc.endYear}`
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function withdrawalSummary(plan: Plan): string {
|
|
99
|
+
const w = plan.strategies.withdrawalOrder
|
|
100
|
+
if (w.mode === 'sequential') return 'Sequential (cash → taxable → equity comp → traditional → Roth)'
|
|
101
|
+
if (w.mode === 'proportional') return 'Proportional across accounts'
|
|
102
|
+
return `Bracket-targeted to ${w.bracketPct}%`
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const td: React.CSSProperties = { padding: '0.3rem 0.6rem', borderBottom: '1px solid var(--border)' }
|
|
106
|
+
|
|
107
|
+
function ReportBody() {
|
|
108
|
+
const { plan } = usePlan()
|
|
109
|
+
const reportBranding = useReportBranding()
|
|
110
|
+
const view = useProjection(plan)
|
|
111
|
+
const { result, summary } = view
|
|
112
|
+
const hasCarryforward = plan.household.capitalLossCarryforward > 0
|
|
113
|
+
const depleted = summary.depletionYear !== null
|
|
114
|
+
|
|
115
|
+
const chartRows = result.years.map((y) => {
|
|
116
|
+
const cats = { cash: 0, taxable: 0, equityComp: 0, traditional: 0, roth: 0, hsa: 0 }
|
|
117
|
+
for (const a of plan.accounts) {
|
|
118
|
+
if ((CATEGORIES as readonly string[]).includes(a.type)) cats[a.type as (typeof CATEGORIES)[number]] += y.balances[a.id] ?? 0
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
year: y.year,
|
|
122
|
+
...cats,
|
|
123
|
+
income: y.incomes.total,
|
|
124
|
+
spending: y.expenses.total + y.tax + y.penalties,
|
|
125
|
+
tax: y.tax,
|
|
126
|
+
magi: y.magi,
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<article className="report">
|
|
132
|
+
<header className="report-head">
|
|
133
|
+
<div>
|
|
134
|
+
<h1>{plan.name}</h1>
|
|
135
|
+
<p className="muted">Retirement plan report · prepared {new Date().toLocaleDateString()}</p>
|
|
136
|
+
</div>
|
|
137
|
+
<div className="report-actions no-print">
|
|
138
|
+
<button type="button" className="btn btn-primary btn-small" onClick={() => window.print()}>
|
|
139
|
+
Print / Save as PDF
|
|
140
|
+
</button>
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
className="btn btn-secondary btn-small"
|
|
144
|
+
onClick={() =>
|
|
145
|
+
downloadStandaloneReport({
|
|
146
|
+
plan,
|
|
147
|
+
result,
|
|
148
|
+
summary,
|
|
149
|
+
startYear: view.startYear,
|
|
150
|
+
branding: reportBranding,
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
>
|
|
154
|
+
Download HTML report
|
|
155
|
+
</button>
|
|
156
|
+
<Link to={`/plan/${plan.id}/results`} className="btn btn-secondary btn-small">
|
|
157
|
+
Back to plan
|
|
158
|
+
</Link>
|
|
159
|
+
</div>
|
|
160
|
+
</header>
|
|
161
|
+
|
|
162
|
+
<p className="report-disclaimer">
|
|
163
|
+
Educational illustration only — not tax, legal, financial, or medical advice. Figures are projections based on
|
|
164
|
+
the assumptions below and will differ from actual results. See the full disclaimer in the app.
|
|
165
|
+
</p>
|
|
166
|
+
|
|
167
|
+
{/* Headline results */}
|
|
168
|
+
<section className="report-section">
|
|
169
|
+
<h2>Headline results</h2>
|
|
170
|
+
<div className="report-kpis">
|
|
171
|
+
<ReportKpi label="Ending net worth" value={fmtMoneyCompact(result.endingNetWorth)} sub={`in ${result.endYear}`} />
|
|
172
|
+
<ReportKpi label="After-tax estate" value={fmtMoneyCompact(summary.endingAfterTaxEstate)} sub="net of heir tax on pre-tax" />
|
|
173
|
+
<ReportKpi label="Money lasts" value={depleted ? `to ${summary.depletionYear}` : 'full plan'} sub={depleted ? 'portfolio depletes' : `through ${result.endYear}`} />
|
|
174
|
+
<ReportKpi label="Lifetime tax" value={fmtMoneyCompact(summary.lifetimeTaxesAndPenalties)} sub="federal + state + penalties" />
|
|
175
|
+
</div>
|
|
176
|
+
<div className="report-kpis" style={{ marginTop: '1rem' }}>
|
|
177
|
+
<ReportKpi label="FI Target" value={fmtMoneyCompact(summary.fiNumber)} sub={`SWR: ${plan.assumptions.safeWithdrawalRatePct ?? 4}%`} />
|
|
178
|
+
<ReportKpi label="FI Reached" value={summary.fiYear !== null ? `${summary.fiYear} (Age ${summary.fiAge})` : 'Never'} sub="based on target SWR" />
|
|
179
|
+
<ReportKpi label="Avg Savings Rate" value={`${summary.averagePreRetirementSavingsRatePct.toFixed(1)}%`} sub="pre-retirement average" />
|
|
180
|
+
<ReportKpi label="Coast-FIRE Target" value={fmtMoneyCompact(summary.coastFireNumber)} sub="needed today" />
|
|
181
|
+
</div>
|
|
182
|
+
<div className="report-chart">
|
|
183
|
+
<h3>Investable balances by account type (nominal)</h3>
|
|
184
|
+
<AreaChart width={700} height={260} data={chartRows} margin={{ left: 8, right: 8, top: 8 }}>
|
|
185
|
+
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
|
186
|
+
<XAxis dataKey="year" tick={{ fill: 'var(--muted)', fontSize: 11 }} />
|
|
187
|
+
<YAxis tickFormatter={fmtMoneyCompact} tick={{ fill: 'var(--muted)', fontSize: 11 }} width={64} />
|
|
188
|
+
<Tooltip formatter={(v: unknown) => fmtMoney(Number(v))} />
|
|
189
|
+
<Legend />
|
|
190
|
+
{CATEGORIES.map((c) => (
|
|
191
|
+
<Area key={c} dataKey={c} stackId="bal" name={CAT_LABEL[c]} stroke={CAT_COLOR[c]} fill={CAT_COLOR[c]} fillOpacity={0.55} isAnimationActive={false} />
|
|
192
|
+
))}
|
|
193
|
+
</AreaChart>
|
|
194
|
+
</div>
|
|
195
|
+
<div className="report-chart">
|
|
196
|
+
<h3>Income vs. spending (nominal)</h3>
|
|
197
|
+
<BarChart width={700} height={220} data={chartRows} margin={{ left: 8, right: 8, top: 8 }}>
|
|
198
|
+
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
|
199
|
+
<XAxis dataKey="year" tick={{ fill: 'var(--muted)', fontSize: 11 }} />
|
|
200
|
+
<YAxis tickFormatter={fmtMoneyCompact} tick={{ fill: 'var(--muted)', fontSize: 11 }} width={64} />
|
|
201
|
+
<Tooltip formatter={(v: unknown) => fmtMoney(Number(v))} />
|
|
202
|
+
<Legend />
|
|
203
|
+
{/* Income is green (chart-3), spending gold: money in reads as green. */}
|
|
204
|
+
<Bar dataKey="income" name="Income" fill="var(--chart-3)" isAnimationActive={false} />
|
|
205
|
+
<Bar dataKey="spending" name="Spending + tax" fill="var(--chart-1)" isAnimationActive={false} />
|
|
206
|
+
</BarChart>
|
|
207
|
+
</div>
|
|
208
|
+
<div className="report-chart">
|
|
209
|
+
<h3>Tax and MAGI (nominal)</h3>
|
|
210
|
+
<LineChart width={700} height={200} data={chartRows} margin={{ left: 8, right: 8, top: 8 }}>
|
|
211
|
+
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
|
212
|
+
<XAxis dataKey="year" tick={{ fill: 'var(--muted)', fontSize: 11 }} />
|
|
213
|
+
<YAxis tickFormatter={fmtMoneyCompact} tick={{ fill: 'var(--muted)', fontSize: 11 }} width={64} />
|
|
214
|
+
<Tooltip formatter={(v: unknown) => fmtMoney(Number(v))} />
|
|
215
|
+
<Legend />
|
|
216
|
+
<Line dataKey="tax" name="Tax" stroke="var(--chart-4)" dot={false} strokeWidth={2} isAnimationActive={false} />
|
|
217
|
+
<Line dataKey="magi" name="MAGI" stroke="var(--chart-2)" dot={false} strokeWidth={2} isAnimationActive={false} />
|
|
218
|
+
</LineChart>
|
|
219
|
+
</div>
|
|
220
|
+
</section>
|
|
221
|
+
|
|
222
|
+
{/* Inputs */}
|
|
223
|
+
<section className="report-section">
|
|
224
|
+
<h2>Household</h2>
|
|
225
|
+
<p className="muted">
|
|
226
|
+
{plan.household.filingStatus === 'marriedFilingJointly' ? 'Married filing jointly' : 'Single'} · {stateName(plan.household.state)}
|
|
227
|
+
</p>
|
|
228
|
+
<table className="report-table">
|
|
229
|
+
<thead><tr><th>Person</th><th>Date of birth</th><th>Retirement age</th><th>Planning age</th></tr></thead>
|
|
230
|
+
<tbody>
|
|
231
|
+
{plan.household.people.map((p) => (
|
|
232
|
+
<tr key={p.id}>
|
|
233
|
+
<td style={td}>{p.name}</td>
|
|
234
|
+
<td style={td}>{p.dob}</td>
|
|
235
|
+
<td style={td}>{p.retirementAge ?? '—'}</td>
|
|
236
|
+
<td style={td}>{p.longevity.planningAge}</td>
|
|
237
|
+
</tr>
|
|
238
|
+
))}
|
|
239
|
+
</tbody>
|
|
240
|
+
</table>
|
|
241
|
+
</section>
|
|
242
|
+
|
|
243
|
+
<section className="report-section">
|
|
244
|
+
<h2>Accounts</h2>
|
|
245
|
+
<table className="report-table">
|
|
246
|
+
<thead><tr><th>Account</th><th>Type</th><th>Owner</th><th style={{ textAlign: 'right' }}>Balance</th><th style={{ textAlign: 'right' }}>Return</th></tr></thead>
|
|
247
|
+
<tbody>
|
|
248
|
+
{plan.accounts.map((a) => (
|
|
249
|
+
<tr key={a.id}>
|
|
250
|
+
<td style={td}>{a.name}</td>
|
|
251
|
+
<td style={td}>{ACCOUNT_LABEL[a.type]}</td>
|
|
252
|
+
<td style={td}>{ownerName(plan, a.ownerPersonId)}</td>
|
|
253
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(accountBalance(a))}</td>
|
|
254
|
+
<td style={{ ...td, textAlign: 'right' }}>{a.annualReturnPct !== null ? `${a.annualReturnPct}%` : 'default'}</td>
|
|
255
|
+
</tr>
|
|
256
|
+
))}
|
|
257
|
+
{plan.accounts.length === 0 ? <tr><td style={td} colSpan={5}>No accounts.</td></tr> : null}
|
|
258
|
+
</tbody>
|
|
259
|
+
</table>
|
|
260
|
+
</section>
|
|
261
|
+
|
|
262
|
+
<section className="report-section">
|
|
263
|
+
<h2>Income</h2>
|
|
264
|
+
<table className="report-table">
|
|
265
|
+
<thead><tr><th>Source</th><th>Detail</th></tr></thead>
|
|
266
|
+
<tbody>
|
|
267
|
+
{plan.incomes.map((s) => (
|
|
268
|
+
<tr key={s.id}><td style={td}>{incomeLabel(plan, s)}</td><td style={td}>{incomeDetail(s)}</td></tr>
|
|
269
|
+
))}
|
|
270
|
+
{plan.incomes.length === 0 ? <tr><td style={td} colSpan={2}>No income streams.</td></tr> : null}
|
|
271
|
+
</tbody>
|
|
272
|
+
</table>
|
|
273
|
+
</section>
|
|
274
|
+
|
|
275
|
+
<section className="report-section">
|
|
276
|
+
<h2>Spending & strategy</h2>
|
|
277
|
+
<table className="report-table">
|
|
278
|
+
<tbody>
|
|
279
|
+
<tr><td style={td}>Baseline annual spending</td><td style={{ ...td, textAlign: 'right' }}>{fmtMoney(plan.expenses.baseAnnual)} (today's $)</td></tr>
|
|
280
|
+
<tr><td style={td}>Retirement phases</td><td style={{ ...td, textAlign: 'right' }}>{plan.expenses.phases.length ? plan.expenses.phases.map((p) => `${p.multiplier}× from ${p.fromAge}`).join(', ') : 'none'}</td></tr>
|
|
281
|
+
<tr><td style={td}>One-time goals</td><td style={{ ...td, textAlign: 'right' }}>{plan.expenses.oneTimeGoals.length}</td></tr>
|
|
282
|
+
<tr><td style={td}>Pre-65 premium / person</td><td style={{ ...td, textAlign: 'right' }}>{fmtMoney(plan.expenses.healthcare.pre65MonthlyPremiumPerPerson)}/mo{plan.expenses.healthcare.applyAcaCredit ? ', ACA credit applied' : ''}</td></tr>
|
|
283
|
+
<tr><td style={td}>Withdrawal order</td><td style={{ ...td, textAlign: 'right' }}>{withdrawalSummary(plan)}</td></tr>
|
|
284
|
+
<tr><td style={td}>Roth conversions</td><td style={{ ...td, textAlign: 'right' }}>{conversionSummary(plan)}</td></tr>
|
|
285
|
+
<tr><td style={td}>QCD per year</td><td style={{ ...td, textAlign: 'right' }}>{fmtMoney(plan.strategies.qcdAnnual)}</td></tr>
|
|
286
|
+
</tbody>
|
|
287
|
+
</table>
|
|
288
|
+
</section>
|
|
289
|
+
|
|
290
|
+
<section className="report-section">
|
|
291
|
+
<h2>Assumptions</h2>
|
|
292
|
+
<table className="report-table">
|
|
293
|
+
<tbody>
|
|
294
|
+
<tr><td style={td}>General inflation</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.inflationPct / 100, 1)}</td></tr>
|
|
295
|
+
<tr><td style={td}>Healthcare extra inflation</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.healthcareExtraInflationPct / 100, 1)}</td></tr>
|
|
296
|
+
<tr><td style={td}>Default return</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.defaultReturnPct / 100, 1)}</td></tr>
|
|
297
|
+
<tr><td style={td}>Safe withdrawal rate</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct((plan.assumptions.safeWithdrawalRatePct ?? 4) / 100, 1)}</td></tr>
|
|
298
|
+
<tr><td style={td}>State effective tax</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.stateEffectiveTaxPct / 100, 1)}</td></tr>
|
|
299
|
+
<tr><td style={td}>Local income tax</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.localIncomeTaxPct / 100, 1)}</td></tr>
|
|
300
|
+
<tr><td style={td}>Heir tax rate (pre-tax estate)</td><td style={{ ...td, textAlign: 'right' }}>{fmtPct(plan.assumptions.heirTaxRatePct / 100, 0)}</td></tr>
|
|
301
|
+
<tr><td style={td}>Social Security COLA</td><td style={{ ...td, textAlign: 'right' }}>{plan.assumptions.ssCola.mode === 'matchInflation' ? 'matches inflation' : `${plan.assumptions.ssCola.annualPct}% fixed`}</td></tr>
|
|
302
|
+
<tr><td style={td}>SS trust-fund cut</td><td style={{ ...td, textAlign: 'right' }}>{plan.assumptions.ssHaircut ? `${plan.assumptions.ssHaircut.cutPct}% from ${plan.assumptions.ssHaircut.fromYear}` : 'none (scheduled benefits)'}</td></tr>
|
|
303
|
+
</tbody>
|
|
304
|
+
</table>
|
|
305
|
+
<p className="muted small">
|
|
306
|
+
Federal tax brackets, contribution limits, RMD tables, Medicare/IRMAA, and FPL come from dated parameter
|
|
307
|
+
packs; values beyond the latest published year are indexed forward at the assumed inflation rate.
|
|
308
|
+
</p>
|
|
309
|
+
</section>
|
|
310
|
+
|
|
311
|
+
{result.warnings.length > 0 ? (
|
|
312
|
+
<section className="report-section">
|
|
313
|
+
<h2>Modeling notes</h2>
|
|
314
|
+
<ul>
|
|
315
|
+
{result.warnings.map((w) => <li key={w}>{w}</li>)}
|
|
316
|
+
</ul>
|
|
317
|
+
</section>
|
|
318
|
+
) : null}
|
|
319
|
+
|
|
320
|
+
{/* Appendix */}
|
|
321
|
+
<section className="report-section report-appendix">
|
|
322
|
+
<h2>Year-by-year appendix (nominal $)</h2>
|
|
323
|
+
<table className="report-table report-appendix-table">
|
|
324
|
+
<thead>
|
|
325
|
+
<tr>
|
|
326
|
+
<th>Year</th><th>Age</th><th style={{ textAlign: 'right' }}>Income</th><th style={{ textAlign: 'right' }}>Expenses</th>
|
|
327
|
+
<th style={{ textAlign: 'right' }}>Contrib.</th><th style={{ textAlign: 'right' }}>Match</th>
|
|
328
|
+
<th style={{ textAlign: 'right' }}>RMD</th><th style={{ textAlign: 'right' }}>Conv.</th><th style={{ textAlign: 'right' }}>Tax</th>
|
|
329
|
+
{hasCarryforward ? <th style={{ textAlign: 'right' }}>Loss CF</th> : null}
|
|
330
|
+
<th style={{ textAlign: 'right' }}>Investable</th><th style={{ textAlign: 'right' }}>Net worth</th>
|
|
331
|
+
</tr>
|
|
332
|
+
</thead>
|
|
333
|
+
<tbody>
|
|
334
|
+
{result.years.map((y: YearResult) => (
|
|
335
|
+
<tr key={y.year}>
|
|
336
|
+
<td style={td}>{y.year}</td>
|
|
337
|
+
<td style={td}>{y.people.map((p) => (p.alive ? p.ageAttained : '—')).join('/')}</td>
|
|
338
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.incomes.total)}</td>
|
|
339
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.expenses.total)}</td>
|
|
340
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.contributions)}</td>
|
|
341
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.employerMatch)}</td>
|
|
342
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.rmd)}</td>
|
|
343
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.rothConversion)}</td>
|
|
344
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.tax + y.penalties)}</td>
|
|
345
|
+
{hasCarryforward ? <td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.capitalLossCarryforwardRemaining)}</td> : null}
|
|
346
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.investableTotal)}</td>
|
|
347
|
+
<td style={{ ...td, textAlign: 'right' }}>{fmtMoney(y.netWorth)}</td>
|
|
348
|
+
</tr>
|
|
349
|
+
))}
|
|
350
|
+
</tbody>
|
|
351
|
+
</table>
|
|
352
|
+
</section>
|
|
353
|
+
</article>
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function ReportKpi({ label, value, sub }: { label: string; value: string; sub: string }) {
|
|
358
|
+
return (
|
|
359
|
+
<div className="report-kpi">
|
|
360
|
+
<span className="kpi-label">{label}</span>
|
|
361
|
+
<span className="kpi-value">{value}</span>
|
|
362
|
+
<span className="kpi-sub">{sub}</span>
|
|
363
|
+
</div>
|
|
364
|
+
)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function ReportPage() {
|
|
368
|
+
const { planId } = useParams()
|
|
369
|
+
if (!planId) return null
|
|
370
|
+
return (
|
|
371
|
+
<PlanProvider planId={planId}>
|
|
372
|
+
<ReportBody />
|
|
373
|
+
</PlanProvider>
|
|
374
|
+
)
|
|
375
|
+
}
|