Dohodnina optimizator
HTML
<h1>Dohodnina Optimizator</h1>
<div class="inputs">
<label>Število otrok <input type="number" id="numChildren" value="3" min="1" max="10"></label>
</div>
<div class="inputs">
<h2>Partner 1</h2>
<input type="number" id="p1Income" placeholder="Bruto dohodek">
<input type="number" id="p1Contrib" placeholder="Prispevki">
<label><input type="checkbox" id="p1Volunteer"> Nepoklicni prostovoljec</label>
</div>
<div class="inputs">
<h2>Partner 2</h2>
<input type="number" id="p2Income" placeholder="Bruto dohodek">
<input type="number" id="p2Contrib" placeholder="Prispevki">
<label><input type="checkbox" value="checked" id="p2Volunteer"> Nepoklicni prostovoljec</label>
</div>
<h2>Heatmap vseh kombinacij</h2>
<div id="heatmap" class="grid" style="grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));"></div>
<div id="tooltip" class="tooltip"></div>
<div id="minMax" style="margin-top:10px;"></div>
CSS
body { font-family: sans-serif; margin: 20px; }
input { width: 100%; padding: 6px; margin-bottom: 6px; }
label { display: flex; align-items: center; gap: 4px; }
.grid { display: grid; gap: 1px; }
.tooltip { position: fixed; display: none; background: rgba(0,0,0,0.8); color: white; padding: 6px 8px; border-radius: 8px; font-size: 12px; pointer-events: none; z-index: 1000; }
.inputs {max-width: 200px;}
JavaScript
const GENERAL_ALLOWANCE = 5260;
const VOLUNTEER_ALLOWANCE = 1570;
const baseChildAllowances = [2838.3, 3085.52, 5146.39, 7207.26, 9268.12];
function getChildAllowance(index) {
if (index < baseChildAllowances.length) return baseChildAllowances[index];
return baseChildAllowances[baseChildAllowances.length-1] + (index - baseChildAllowances.length + 1) * 2060.87;
}
function calculateTax(base) {
if(base <=0) return 0;
if(base <=9210.26) return base*0.16;
if(base <=27089) return 1473.64 + (base-9210.26)*0.26;
if(base <=54178) return 6122.11 + (base-27089)*0.33;
if(base <=78016.32) return 15061.48 + (base-54178)*0.39;
return 24358.43 + (base-78016.32)*0.5;
}
function generateData() {
const numChildren = Number(document.getElementById('numChildren').value);
const p1Income = Number(document.getElementById('p1Income').value);
const p1Contrib = Number(document.getElementById('p1Contrib').value);
const p2Income = Number(document.getElementById('p2Income').value);
const p2Contrib = Number(document.getElementById('p2Contrib').value);
const p1Volunteer = document.getElementById('p1Volunteer').checked;
const p2Volunteer = document.getElementById('p2Volunteer').checked;
const results = [];
function recurse(index, currentMonths) {
if(index === numChildren) {
const monthsP1 = currentMonths;
const monthsP2 = monthsP1.map(m => 12 - m);
const allowanceP1 = GENERAL_ALLOWANCE + monthsP1.reduce((s,m,i)=>s+(m/12)*getChildAllowance(i),0) + (p1Volunteer?VOLUNTEER_ALLOWANCE:0);
const allowanceP2 = GENERAL_ALLOWANCE + monthsP2.reduce((s,m,i)=>s+(m/12)*getChildAllowance(i),0) + (p2Volunteer?VOLUNTEER_ALLOWANCE:0);
const base1 = p1Income - p1Contrib - allowanceP1;
const base2 = p2Income - p2Contrib - allowanceP2;
const tax1 = calculateTax(base1);
const tax2 = calculateTax(base2);
results.push({label:`P1:${monthsP1.join('-')}\nP2:${monthsP2.join('-')}`, totalTax:...