startkapital as shared input, buy invests remainder after Eigenkapital

This commit is contained in:
Johannes
2026-03-20 02:09:30 +01:00
parent 1bf69a6043
commit 14ae4810f2
2 changed files with 14 additions and 11 deletions

10
calc.js
View File

@@ -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));