diff --git a/src/components/PlanView.tsx b/src/components/PlanView.tsx index 37c5324..3ca9e8f 100644 --- a/src/components/PlanView.tsx +++ b/src/components/PlanView.tsx @@ -180,13 +180,26 @@ export function PlanView({ }; } + // Am Uebergang nichts (mehr) zu tun: verkauft/getilgt ODER PK/3a nach der Pensionierung + // (Besitzer ist zu Beginn der Von-Phase bereits pensioniert -> bereits bezogen/verrentet). + function transitionInactive(el: ElementInput, fromPhase: PhaseComputed): boolean { + const ce = computedElement(fromPhase.id, el.id); + if (ce && ce.status !== "ACTIVE") return true; + if (el.category === "PENSION_FUND" || el.category === "PILLAR_3A") { + if (el.ownerRole && el.ownerRole !== "HOUSEHOLD") { + const owner = fromPhase.persons.find((p) => p.role === el.ownerRole); + if (owner && !owner.working) return true; + } + } + return false; + } + // Anzahl offener (noch nicht getroffener) Uebergangs-Entscheide an einer Grenze. function transitionOpenCount(fromPhase: PhaseComputed, toPhase: PhaseComputed): number { let n = 0; for (const el of plan.elements) { if (!TRANSITION_CATEGORIES.includes(el.category)) continue; - const ce = computedElement(fromPhase.id, el.id); - if (ce && ce.status !== "ACTIVE") continue; + if (transitionInactive(el, fromPhase)) continue; const td = el.transitionValues[fromPhase.id] ?? {}; const retire = toPhase ? isRetirementTransition(el, fromPhase, toPhase) : false; if (!isTransitionAnswered(el.category, retire, td)) n++; @@ -196,8 +209,7 @@ export function PlanView({ // Ist der Uebergangs-Entscheid dieses Elements noch offen? function transitionUnanswered(el: ElementInput, fromPhase: PhaseComputed, toPhase: PhaseComputed): boolean { - const ce = computedElement(fromPhase.id, el.id); - if (ce && ce.status !== "ACTIVE") return false; + if (transitionInactive(el, fromPhase)) return false; const retire = isRetirementTransition(el, fromPhase, toPhase); return !isTransitionAnswered(el.category, retire, el.transitionValues[fromPhase.id] ?? {}); } @@ -359,8 +371,7 @@ export function PlanView({ ); } - const ceT = computedElement(col.fromPhase.id, el.id); - const locked = !!ceT && ceT.status !== "ACTIVE"; // verkauft/getilgt + const locked = TRANSITION_CATEGORIES.includes(el.category) && transitionInactive(el, col.fromPhase); const canTransition = TRANSITION_CATEGORIES.includes(el.category) && !locked; const open = canTransition && transitionUnanswered(el, col.fromPhase, col.toPhase); return (