Fix: Cash-Startwert zeigt Bestand NACH den Investitionen (kein Doppelzaehlen)
Deploy App / deploy (push) Successful in 56s
Deploy App / deploy (push) Successful in 56s
Investitionen einer Phase (Zusatz-/Neuinvestitionen aus Cash) werden am Phasenanfang abgezogen; der Cash-Startwert bildet das nun ab. Behebt zugleich eine Doppelzaehlung im Startvermoegen (der investierte Betrag stand zuvor sowohl im Cash-Start als auch im Vermoegen). Endwerte unveraendert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -158,10 +158,14 @@ describe("V5 Golden Tests", () => {
|
||||
el("OTHER_ASSET", "HOUSEHOLD", { p1: { startValue: 0, expectedReturn: 0, annualContribution: 0 }, p2: { additionalInvestment: 10000, expectedReturn: 0 } }),
|
||||
],
|
||||
});
|
||||
const p2 = computePlan(p).phases[1];
|
||||
const r = computePlan(p);
|
||||
const p2 = r.phases[1];
|
||||
expect(p2.capitalInflow).toBe(10000); // Verkaufserloes aus dem Uebergang
|
||||
expect(p2.capitalInvest).toBe(10000); // Zusatzinvestition
|
||||
expect(p2.cashStart).toBe(0); // Startwert bereits nach Abzug der Investition
|
||||
expect(p2.cashEnd).toBe(0);
|
||||
// Startvermoegen Phase 2: Cash(0) + Vermoegen B(10'000) = 10'000 (kein Doppelzaehlen).
|
||||
expect(p2.startWealthNominal).toBe(10000);
|
||||
});
|
||||
|
||||
it("Cash-Anfangswert fliesst in die erste Phase ein", () => {
|
||||
|
||||
@@ -363,8 +363,10 @@ export function computePlan(plan: PlanInput): PlanComputed {
|
||||
}
|
||||
|
||||
// --- Jahr-fuer-Jahr: indexierte Flows, Cash-Ausgleich, Verzinsung, Ruin ---
|
||||
const cashStart = cashCarryIn;
|
||||
// Investitionen dieser Phase werden am Phasenanfang abgezogen -> der Cash-Startwert
|
||||
// zeigt den Bestand NACH den Investitionen (kein Doppelzaehlen mit dem Vermoegen).
|
||||
let cash = cashCarryIn - (isFirstPhase ? 0 : investmentsFromCash);
|
||||
const cashStart = cash;
|
||||
let cashNegative = cash < 0;
|
||||
let incomeStart = 0;
|
||||
let incomeEnd = 0;
|
||||
|
||||
Reference in New Issue
Block a user