Press-and-hold spinner buttons repeat by 1000; floor compound interest growth (securities and real estate) and pension lump sum to nearest 1000 throughout
Deploy App / deploy (push) Successful in 43s
Deploy App / deploy (push) Successful in 43s
This commit is contained in:
+12
-8
@@ -1,4 +1,5 @@
|
||||
import { AHV_COUPLE_CAP_FACTOR, AHV_MAX_PENSION_PER_YEAR } from "@/lib/constants";
|
||||
import { floorToThousand } from "@/lib/format";
|
||||
import type { HouseholdInput, PhaseInput, PlanInput } from "@/lib/types";
|
||||
|
||||
export interface SecurityComputed {
|
||||
@@ -70,16 +71,19 @@ export interface PlanComputed {
|
||||
totalSavingsWarnings: number;
|
||||
}
|
||||
|
||||
// Alle Zwischen- und Endwerte werden auf ein Vielfaches von 1'000 abgerundet (siehe
|
||||
// lib/format.ts): nur so bleiben Betraege, die spaeter bei einem Verkauf oder Uebergang
|
||||
// auf Wertschriften verteilt werden muessen, ueberhaupt vollstaendig verteilbar.
|
||||
export function computeSecurityYearlyValues(
|
||||
startValue: number,
|
||||
expectedReturn: number,
|
||||
annualContribution: number,
|
||||
durationYears: number
|
||||
): number[] {
|
||||
const values = [startValue];
|
||||
const values = [floorToThousand(startValue)];
|
||||
for (let year = 1; year <= durationYears; year++) {
|
||||
const previous = values[year - 1];
|
||||
values.push(previous * (1 + expectedReturn / 100) + annualContribution);
|
||||
values.push(floorToThousand(previous * (1 + expectedReturn / 100) + annualContribution));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
@@ -91,11 +95,11 @@ export function computeRealEstateYearly(
|
||||
amortization: number,
|
||||
durationYears: number
|
||||
): { marketValues: number[]; mortgages: number[] } {
|
||||
const marketValues = [marketValue];
|
||||
const mortgages = [mortgage];
|
||||
const marketValues = [floorToThousand(marketValue)];
|
||||
const mortgages = [floorToThousand(mortgage)];
|
||||
for (let year = 1; year <= durationYears; year++) {
|
||||
marketValues.push(marketValues[year - 1] * (1 + valueGrowth / 100));
|
||||
mortgages.push(Math.max(0, mortgages[year - 1] - amortization));
|
||||
marketValues.push(floorToThousand(marketValues[year - 1] * (1 + valueGrowth / 100)));
|
||||
mortgages.push(floorToThousand(Math.max(0, mortgages[year - 1] - amortization)));
|
||||
}
|
||||
return { marketValues, mortgages };
|
||||
}
|
||||
@@ -111,7 +115,7 @@ function computeRetirement(
|
||||
ahvAmount: info.ahvAmount,
|
||||
pkPensionAmount: info.pkPensionAmount,
|
||||
lumpSumAmount: info.lumpSumAmount,
|
||||
lumpSumNet: info.lumpSumAmount * (1 - info.lumpSumTaxRate / 100),
|
||||
lumpSumNet: floorToThousand(info.lumpSumAmount * (1 - info.lumpSumTaxRate / 100)),
|
||||
}));
|
||||
|
||||
const ahvSum = perPerson.reduce((sum, p) => sum + p.ahvAmount, 0);
|
||||
@@ -182,7 +186,7 @@ function computePhase(
|
||||
// Vereinfachung gemaess TDD 3.3: Gewinn = Verkaufspreis - urspruenglich erfasster Startwert
|
||||
const gain = Math.max(0, re.salePrice! - re.marketValue);
|
||||
taxAmount = gain * (re.saleTaxRate / 100);
|
||||
saleNetProceeds = re.salePrice! - taxAmount;
|
||||
saleNetProceeds = floorToThousand(re.salePrice! - taxAmount);
|
||||
}
|
||||
return {
|
||||
id: re.id,
|
||||
|
||||
Reference in New Issue
Block a user