En esta sección podéis compartir vuestras experiencias como desarrolladores de SaltOS.
Dear;
I found a miscalculation of taxes to file \"gastos.js\"
Original line:
var base=round((100*total)/(100+iva-irpf),2);
Changed to:
var base=round(total-(total*(iva-irpf)/100),2);
Hi Mario.
I checked your recommendation and I detected that the old code is better that your new code. I wrote a test case demonstrating how your proposed formula (with the \"new\" label) fails and how the original (with the \"old\" label) runs as expected.
***** TEST 1 *****
- total=10.95
- iva=21%
- irpf=18%
Old formula
- base=10.63
- iva2=2.23
- irpf2=1.91
- total2=10.95
- result=OK
New formula
- base=10.62
- iva2=2.23
- irpf2=1.91
- total2=10.94
- result=KO
***** TEST 2 *****
- total=10.95
- iva=21%
- irpf=0%
Old formula
- base=9.05
- iva2=1.9
- irpf2=0
- total2=10.95
- result=OK
New formula
- base=8.65
- iva2=1.82
- irpf2=0
- total2=10.47
- result=KO
***** TEST 3 *****
- total=10.95
- iva=0%
- irpf=18%
Old formula
- base=13.35
- iva2=0
- irpf2=2.4
- total2=10.95
- result=OK
New formula
- base=12.92
- iva2=0
- irpf2=2.33
- total2=10.59
- result=KO
***** TEST 4 *****
- total=10.95
- iva=0%
- irpf=0%
Old formula
- base=10.95
- iva2=0
- irpf2=0
- total2=10.95
- result=OK
New formula
- base=10.95
- iva2=0
- irpf2=0
- total2=10.95
- result=OK
This test case is in PHP. If you want to see the source code, please, send me an email to josep.sanz@saltos.net and I will send you the source code that will allow you to see the details of the test case.