add Startkapital input for renter initial savings

This commit is contained in:
Johannes
2026-03-20 02:05:41 +01:00
parent 9b9fd6a76a
commit 1bf69a6043
3 changed files with 11 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ function run_simulation(p) {
// --- state ---
let balance = loan;
let home_value = p.home_price;
let portfolio = upfront_buy; // renter invests this lump sum
let portfolio = upfront_buy + (p.start_capital || 0); // renter invests this lump sum + any extra savings
let monthly_rent = p.monthly_rent;
let cum_buy_cost = upfront_buy; // running cash spent on buying

View File

@@ -171,6 +171,14 @@
<section class="card inputs-rent">
<h2 class="col-header rent-header">Mieten</h2>
<div class="input-group">
<label for="start_capital">Startkapital <span class="hint">(zusätzl. Ersparnisse)</span></label>
<div class="num-unit euro-input">
<span class="unit prefix"></span>
<input type="number" id="start_capital" min="0" max="10000000" step="1000" value="0" />
</div>
</div>
<div class="input-group">
<label for="monthly_rent">Kaltmiete (monatlich)</label>
<div class="num-unit euro-input">

3
ui.js
View File

@@ -24,6 +24,7 @@ const get_params = () => ({
monthly_rent: +document.getElementById('monthly_rent').value,
rent_increase: +document.getElementById('rent_increase').value,
renters_ins: +document.getElementById('renters_ins').value,
start_capital: +document.getElementById('start_capital').value,
});
// ===== Charts =====
@@ -227,7 +228,7 @@ const SLIDER_IDS = [
SLIDER_IDS.forEach(wire_slider);
// wire plain number inputs (no slider)
['home_price', 'insurance', 'monthly_rent', 'renters_ins'].forEach((id) => {
['home_price', 'insurance', 'monthly_rent', 'renters_ins', 'start_capital'].forEach((id) => {
document.getElementById(id).addEventListener('input', recalc);
});