simplekolecalc/kole.html

62 lines
3.0 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<style>
input[type='number']{text-align:right;}
input[readonly='readonly']{background-color:#eee;}
</style>
</head>
<body>
2023-03-29 14:55:48 +02:00
<h1>Rechner zwischen Brutto-Netto-Kole</h1>
<table>
<tr><td>Eingangsgröße:</td><td><input accesskey="b" type="radio" name="b" value="e" id="bb" class="bb" checked="checked"/><label for="bb"><u>B</u>rutto</label><input accesskey="n" type="radio" name="b" value="b" id="bn" class="bb"/><label for="bn"><u>N</u>etto</label><input accesskey="k" type="radio" name="b" value="k" id="bk" class="bb"/><label for="bk"><u>K</u>oLe</label></td></tr>
<tr><td>Br<u>u</u>tto</td><td><input accesskey="u" type="number" step="0.01" id="e" value="100.00"/>&thinsp;</td></tr>
<tr><td>Umsatzsteuersatz</td><td><input type="number" step="0.01" id="u" value="19.00"/>&thinsp;%</td></tr>
<tr><td>Umsatzsteuer</td><td><input readonly="readonly" type="number" step="0.01" id="us" value="0.00"/>&thinsp;</td></tr>
<tr><td>N<u>e</u>tto</td><td><input accesskey="e" type="number" step="0.01" id="n" value="0.00"/>&thinsp;</td></tr>
<tr><td>Entropieumlagesatz</td><td><input type="number" step="0.01" id="z" value="23.00"/>&thinsp;%</td></tr>
<tr><td>Entropieumlage</td><td><input readonly="readonly" type="number" step="0.01" id="eu" value="23.00"/>&thinsp;</td></tr>
<tr><td>K<u>o</u>Le</td><td><input accesskey="o" type="number" step="0.01" id="k" value="0.00"/>&thinsp;</td></tr>
<tr><td>&nbsp;</td><td><input value="Berechnen" id="b" type="button"/></td></tr>
</table>
<script>
var e=document.getElementById('e');
var u=document.getElementById('u');
var us=document.getElementById('us');
var n=document.getElementById('n');
var z=document.getElementById('z');
var eu=document.getElementById('eu');
var k=document.getElementById('k');
var bb=document.getElementById('bb');
var bn=document.getElementById('bn');
var bk=document.getElementById('bk');
var s = document.getElementById('b');
function getFormFloat(f){
return parseFloat(f.value);
}
function roundCents(f){
return Math.round( f * 100 ) / 100;
}
s.addEventListener('click', function(){
if(bk.checked){
e.value = roundCents( getFormFloat(k) * ( 1 + getFormFloat(u) / 100 ) / ( 1 - getFormFloat(z) / 100 ) );
n.value = roundCents( getFormFloat(k) / ( 1 - getFormFloat(z) / 100 ) );
}else if(bb.checked){
k.value = roundCents( getFormFloat(e) / ( 1 + getFormFloat(u) / 100 ) * ( 1 - getFormFloat(z) / 100 ) );
n.value = roundCents( getFormFloat(e) / ( 1 + getFormFloat(u) / 100 ) );
}else if(bn.checked){
e.value = roundCents( getFormFloat(n) * ( 1 + getFormFloat(u) / 100 ) );
k.value = roundCents( getFormFloat(n) * ( 1 - getFormFloat(z) / 100 ) );
}
2023-03-29 14:55:48 +02:00
us.value = roundCents(e.value * getFormFloat(u) / 100 );
eu.value = roundCents(n.value * getFormFloat(z) / 100 );
});
e.addEventListener('change', function(){bb.checked = true;});
n.addEventListener('change', function(){bn.checked = true;});
s.click();
</script>
</body>
</html>