change options to brutto/netto/kole

reverse choice from solution to given
a bit ux
html entities as gitea warns about utf8 characters
This commit is contained in:
vv01f 2023-03-28 11:21:14 +02:00
parent 200e9b5a11
commit 7c31eb5458

View File

@ -8,30 +8,48 @@
<body> <body>
<p>Bei Eingaben werden Komma und Punkt als Dezimaltrennzeichen betrachtet.</p> <p>Bei Eingaben werden Komma und Punkt als Dezimaltrennzeichen betrachtet.</p>
<table> <table>
<tr><td>Berechne:</td><td><input type="radio" name="b" value="k" id="bk" class="bb" checked="checked" /><label for="bk">KoLe</label><input type="radio" name="b" value="e" id="be" class="bb" /><label for="be">Einnahmen</label></td></tr> <tr><td>Ausgangsbetrag:</td><td><input type="radio" name="b" value="e" id="bb" class="bb" checked="checked"/><label for="bb">Brutto</label><input type="radio" name="b" value="b" id="bn" class="bb"/><label for="bn">Netto</label><input type="radio" name="b" value="k" id="bk" class="bb"/><label for="bk">KoLe</label></td></tr>
<tr><td>Einnahme</td><td><input type="number" step="0.01" id="e" value="1"/> €</td></tr> <tr><td>Brutto</td><td><input type="number" step="0.01" id="e" value="100.00"/>&thinsp;</td></tr>
<tr><td>Umsatzsteuer</td><td><input type="number" step="0.01" id="u" value="19"/>%</td></tr> <tr><td>Umsatzsteuer</td><td><input type="number" step="0.01" id="u" value="19.00"/>&thinsp;%</td></tr>
<tr><td>Entropieumlage</td><td><input type="number" step="0.01" id="z" value="23"/>%</td></tr> <tr><td>Netto</td><td><input type="number" step="0.01" id="n" value="0.00"/>&thinsp;</td></tr>
<tr><td>KoLe</td><td><input type="number" step="0.01" id="k" value=""/> €</td></tr> <tr><td>Entropieumlage</td><td><input type="number" step="0.01" id="z" value="23.00"/>&thinsp;%</td></tr>
<tr><td>KoLe</td><td><input 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> <tr><td>&nbsp;</td><td><input value="Berechnen" id="b" type="button"/></td></tr>
</table> </table>
<script> <script>
var e=document.getElementById('e'); var e=document.getElementById('e');
var u=document.getElementById('u'); var u=document.getElementById('u');
var n=document.getElementById('n');
var z=document.getElementById('z'); var z=document.getElementById('z');
var k=document.getElementById('k'); var k=document.getElementById('k');
var bb=document.getElementById('bb');
var bn=document.getElementById('bn');
var bk=document.getElementById('bk'); var bk=document.getElementById('bk');
var be=document.getElementById('be'); var s = document.getElementById('b');
var b = document.getElementById("b");
b.addEventListener("click", function(){ function getFormFloat(f){
return parseFloat(f.value.replace(/,/g, '.').replace(/ /g, ''));
}
function roundCents(f){
return Math.round( f * 100 ) / 100;
}
s.addEventListener('click', function(){
if(bk.checked){ if(bk.checked){
k.value = Math.round( parseFloat(e.value.replace(/,/g, '.')) / ( 1 + parseFloat(u.value.replace(/,/g, '.')) / 100 ) * ( 1 - parseFloat(z.value.replace(/,/g, '.')) / 100 ) * 100 ) / 100; e.value = roundCents( getFormFloat(k) * ( 1 + getFormFloat(u) / 100 ) / ( 1 - getFormFloat(z) / 100 ) );
}else// if(be.checked) n.value = roundCents( getFormFloat(k) / ( 1 - getFormFloat(z) / 100 ) );
{ }else if(bb.checked){
e.value = Math.round( parseFloat(k.value.replace(/,/g, '.')) * ( 1 + parseFloat(u.value.replace(/,/g, '.')) / 100 ) / ( 1 - parseFloat(z.value.replace(/,/g, '.')) / 100 ) * 100 ) / 100; 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 ) );
} }
}); });
e.addEventListener('change', function(){bb.checked = true;});
n.addEventListener('change', function(){bn.checked = true;});
k.addEventListener('change', function(){bk.checked = true;});
s.click();
</script> </script>
</body> </body>
</html> </html>