Rework core model: financial elements as plan-wide entities across phases; derived phase types (Erwerb/Pension/Misch) with retirement-capped durations and per-plan retirement age; AHV (gap years + couple ceiling), PK payout/annuity, 3a, real estate, other assets/debts; horizontal timeline with retirement markers; phase x element matrix with detail panel; savings/consumption quota + available-capital key figures with red status
Deploy App / deploy (push) Successful in 1m57s

This commit is contained in:
2026-07-13 07:55:58 +02:00
parent b3a3b565ac
commit b775ab77cb
27 changed files with 2407 additions and 2166 deletions
+19 -70
View File
@@ -1,19 +1,16 @@
// Domain-Typen fuer die Berechnungslogik (lib/calculations.ts) und die API-Payloads.
// Bewusst von den generierten Prisma-Typen entkoppelt, damit die Berechnungslogik
// unabhaengig von der konkreten DB-Repraesentation testbar bleibt.
// Domain-Typen fuer Berechnungslogik und API-Payloads. Entkoppelt von den generierten
// Prisma-Typen, damit die Berechnung unabhaengig testbar bleibt.
import type { ElementCategory, OwnerRole, PhaseData, TransitionData } from "@/lib/elements";
export type HouseholdType = "SINGLE" | "COUPLE";
export type PersonRole = "PERSON_A" | "PERSON_B";
export type IncomeMode = "PER_PERSON" | "HOUSEHOLD";
export type OwnerTag = "PERSON_A" | "PERSON_B" | "HOUSEHOLD";
export type OneTimeEventType = "INCOME" | "EXPENSE";
export type TransitionDecision = "CARRY_OVER" | "SELL";
export type PositionType = "SECURITY" | "REAL_ESTATE";
export interface PersonInput {
id: string;
role: PersonRole;
age: number;
// Bereits aufgeloestes Pensionsalter (Plan-Override oder Profil-Default).
retirementAge: number;
}
@@ -24,78 +21,30 @@ export interface HouseholdInput {
persons: PersonInput[];
}
export interface IncomeEntryInput {
id: string;
personId: string | null;
label: string | null;
amount: number;
}
export interface ExpenseEntryInput {
id: string;
label: string | null;
amount: number;
}
export interface SecurityInput {
id: string;
name: string;
startValue: number;
expectedReturn: number;
annualContribution: number;
ownerTag: OwnerTag;
saleTaxRate: number;
// Baseline-Wert bei automatischer Uebernahme aus der Vorphase (0 bei manuell angelegten
// Wertschriften). Siehe PhaseInput.incomingCapital fuer den Kontext.
carriedBaseValue: number;
}
export interface RealEstateInput {
id: string;
name: string;
purchasePrice: number;
mortgage: number;
amortization: number;
}
export interface OneTimeEventInput {
id: string;
type: OneTimeEventType;
amount: number;
description: string | null;
}
export interface RetirementInfoInput {
id: string;
personId: string;
ahvAmount: number;
pkPensionAmount: number;
lumpSumAmount: number;
lumpSumTaxRate: number;
}
export interface PhaseInput {
id: string;
sequenceNumber: number;
name: string;
durationYears: number;
inflationRate: number | null;
incomeMode: IncomeMode;
// Aus Verkaeufen im Uebergang aus der Vorphase verfuegbares Startkapital (automatisch
// gesetzt beim Speichern des Uebergangs der Vorphase).
incomingCapital: number;
incomeEntries: IncomeEntryInput[];
expenseEntries: ExpenseEntryInput[];
securities: SecurityInput[];
realEstates: RealEstateInput[];
oneTimeEvents: OneTimeEventInput[];
retirementInfos: RetirementInfoInput[];
}
export interface ElementInput {
id: string;
category: ElementCategory;
name: string;
ownerRole: OwnerRole | null;
orderIndex: number;
// Werte je Phase (Key = phaseId) bzw. je Uebergang (Key = fromPhaseId).
phaseValues: Record<string, PhaseData>;
transitionValues: Record<string, TransitionData>;
}
export interface PlanInput {
id: string;
name: string;
parentPlanId: string | null;
branchFromPhaseId: string | null;
retirementAgeA: number | null;
retirementAgeB: number | null;
phases: PhaseInput[];
elements: ElementInput[];
}