hover tooltips on Übersicht table with breakdown details
This commit is contained in:
18
calc.js
18
calc.js
@@ -44,8 +44,12 @@ function run_simulation(p) {
|
||||
const renter_nw_arr = [];
|
||||
const cum_buy_arr = [];
|
||||
const cum_rent_arr = [];
|
||||
const detail_arr = [];
|
||||
const labels = [];
|
||||
|
||||
// yearly accumulators (reset each year)
|
||||
let yr_interest = 0, yr_principal = 0, yr_upkeep = 0;
|
||||
|
||||
let breakeven_month = null;
|
||||
|
||||
const invest_r_m = p.invest_return / 100 / 12;
|
||||
@@ -65,7 +69,10 @@ function run_simulation(p) {
|
||||
// German context: no mortgage interest tax deduction for private buyers
|
||||
const total_buy_m = monthly_payment + prop_tax_m + maint_m + insurance_m;
|
||||
|
||||
cum_buy_cost += total_buy_m;
|
||||
yr_interest += interest_m;
|
||||
yr_principal += principal_m;
|
||||
yr_upkeep += prop_tax_m + maint_m + insurance_m;
|
||||
cum_buy_cost += total_buy_m;
|
||||
|
||||
buyer_portfolio *= (1 + invest_r_m);
|
||||
const selling_costs = home_value * (p.closing_sell_pct / 100);
|
||||
@@ -103,6 +110,14 @@ function run_simulation(p) {
|
||||
renter_nw_arr.push(Math.round(portfolio - tax_on_gains));
|
||||
cum_buy_arr.push(Math.round(cum_buy_cost));
|
||||
cum_rent_arr.push(Math.round(cum_rent_cost));
|
||||
detail_arr.push({
|
||||
house_value: Math.round(home_value),
|
||||
buyer_portfolio: Math.round(buyer_portfolio),
|
||||
yr_interest: Math.round(yr_interest),
|
||||
yr_principal: Math.round(yr_principal),
|
||||
yr_upkeep: Math.round(yr_upkeep),
|
||||
});
|
||||
yr_interest = 0; yr_principal = 0; yr_upkeep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +131,7 @@ function run_simulation(p) {
|
||||
renter_nw_arr,
|
||||
cum_buy_arr,
|
||||
cum_rent_arr,
|
||||
detail_arr,
|
||||
monthly_payment: Math.round(monthly_payment),
|
||||
final_buyer_nw,
|
||||
final_renter_nw,
|
||||
|
||||
Reference in New Issue
Block a user