Desarrolladores de SaltOS

Questions: 19 (last: 20/05/2016)
Responses: 33 (last: 21/05/2016)

En esta sección podéis compartir vuestras experiencias como desarrolladores de SaltOS.

Repaired - miscalculation in tax

Nick: Mario Soares | Date: 15/06/2014 | Time: 19:58 | Responses: 1 (last: 04/07/2014)
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);

Re: Repaired - miscalculation in tax

Nick: Josep Sanz | Url: http://www.saltos.net | Date: 04/07/2014 | Time: 12:21
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.

XML lines
60,895
PHP lines
18,637
JS lines
11,620
XSLT lines
2,498
CSV lines
1,919
CSS lines
577