mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:08:46 +02:00
Pensions: compute current age from birthdate instead of hardcoded 30
FCL projection target defaults to the next 5-year withdrawal window (CURRENT_AGE + 5) rather than a fixed 35. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,17 @@ interface TooltipEntry {
|
|||||||
|
|
||||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const CURRENT_AGE = 30;
|
const BIRTH_DATE = new Date(1988, 7, 29); // 29 de agosto de 1988
|
||||||
|
|
||||||
|
function computeCurrentAge(): number {
|
||||||
|
const now = new Date();
|
||||||
|
const hadBirthdayThisYear =
|
||||||
|
now.getMonth() > BIRTH_DATE.getMonth() ||
|
||||||
|
(now.getMonth() === BIRTH_DATE.getMonth() && now.getDate() >= BIRTH_DATE.getDate());
|
||||||
|
return now.getFullYear() - BIRTH_DATE.getFullYear() - (hadBirthdayThisYear ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const CURRENT_AGE = computeCurrentAge();
|
||||||
|
|
||||||
const FUND_KEYS: FundKey[] = ['FCL', 'ROP', 'VOL'];
|
const FUND_KEYS: FundKey[] = ['FCL', 'ROP', 'VOL'];
|
||||||
|
|
||||||
@@ -99,7 +109,7 @@ const FUNDS_DEFAULT: Record<FundKey, FundDef> = {
|
|||||||
annualRate: 7.5,
|
annualRate: 7.5,
|
||||||
isDividend: false,
|
isDividend: false,
|
||||||
withdrawalRule: 'Retirable cada 5 años o al cambio de empleo',
|
withdrawalRule: 'Retirable cada 5 años o al cambio de empleo',
|
||||||
defaultTargetAge: 35,
|
defaultTargetAge: CURRENT_AGE + 5,
|
||||||
},
|
},
|
||||||
ROP: {
|
ROP: {
|
||||||
key: 'ROP',
|
key: 'ROP',
|
||||||
@@ -255,7 +265,7 @@ const EMPTY_SNAPSHOTS: PensionSnapshot[] = [];
|
|||||||
export default function Pensions() {
|
export default function Pensions() {
|
||||||
const [visibleFunds, setVisibleFunds] = useState<Set<FundKey>>(new Set(FUND_KEYS));
|
const [visibleFunds, setVisibleFunds] = useState<Set<FundKey>>(new Set(FUND_KEYS));
|
||||||
const [projections, setProjections] = useState<Record<FundKey, ProjectionState>>({
|
const [projections, setProjections] = useState<Record<FundKey, ProjectionState>>({
|
||||||
FCL: { contribution: 150_000, rate: 7.5, targetAge: 35 },
|
FCL: { contribution: 150_000, rate: 7.5, targetAge: CURRENT_AGE + 5 },
|
||||||
ROP: { contribution: 120_000, rate: 6.0, targetAge: 65 },
|
ROP: { contribution: 120_000, rate: 6.0, targetAge: 65 },
|
||||||
VOL: { contribution: 400_000, rate: 8.0, targetAge: 57 },
|
VOL: { contribution: 400_000, rate: 8.0, targetAge: 57 },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user