From 14ae4810f20bfa15890e2321fcadbe8a4a63071d Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 20 Mar 2026 02:09:30 +0100 Subject: [PATCH] startkapital as shared input, buy invests remainder after Eigenkapital --- calc.js | 10 +++++++--- index.html | 15 +++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/calc.js b/calc.js index 5b469af..013e084 100644 --- a/calc.js +++ b/calc.js @@ -26,11 +26,14 @@ function run_simulation(p) { // upfront costs for buyer const down_payment = p.home_price * (p.down_pct / 100); const upfront_buy = down_payment + p.home_price * (p.closing_buy_pct / 100); + const start_capital = p.start_capital || 0; // --- state --- let balance = loan; let home_value = p.home_price; - let portfolio = upfront_buy + (p.start_capital || 0); // renter invests this lump sum + any extra savings + // renter invests all startkapital; buyer spends upfront_buy and invests the remainder + let portfolio = start_capital; + let buyer_portfolio = Math.max(0, start_capital - upfront_buy); let monthly_rent = p.monthly_rent; let cum_buy_cost = upfront_buy; // running cash spent on buying @@ -64,8 +67,9 @@ function run_simulation(p) { cum_buy_cost += total_buy_m; + buyer_portfolio *= (1 + invest_r_m); const selling_costs = home_value * (p.closing_sell_pct / 100); - const buyer_nw = home_value - selling_costs - balance; + const buyer_nw = home_value - selling_costs - balance + buyer_portfolio; // --- rent side --- const renters_ins_m = p.renters_ins / 12; @@ -94,7 +98,7 @@ function run_simulation(p) { labels.push(`Jahr ${yr}`); buyer_nw_arr.push(Math.round(buyer_nw)); // apply Abgeltungssteuer on portfolio gains at cashout - const portfolio_gains = portfolio - upfront_buy; + const portfolio_gains = portfolio - start_capital; const tax_on_gains = Math.max(0, portfolio_gains) * (p.tax_rate / 100); renter_nw_arr.push(Math.round(portfolio - tax_on_gains)); cum_buy_arr.push(Math.round(cum_buy_cost)); diff --git a/index.html b/index.html index 38cd209..75eaa7b 100644 --- a/index.html +++ b/index.html @@ -22,6 +22,13 @@
+
+ +
+ + +
+
@@ -171,14 +178,6 @@

Mieten

-
- -
- - -
-
-