Desarrolladores de SaltOS

Preguntes: 19 (darrera: 20/05/2016)
Respostes: 33 (darrera: 21/05/2016)

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

Repaired - miscalculation in tax

Nick: Mario Soares | Data: 15/06/2014 | Hora: 19:58 | Respostes: 1 (darrera: 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 | Data: 04/07/2014 | Hora: 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.

Línies de XML
60,895
Línies de PHP
18,637
Línies de JS
11,620
Línies de XSLT
2,498
Línies de CSV
1,919
Línies de CSS
577