http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7528

Marc Véron <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |In Discussion
                 CC|                            |[email protected]

--- Comment #1 from Marc Véron <[email protected]> ---
This one has to do with floating point precision in JavaScript.

In
koha-tmpl/intranet-tmpl/prog/en/js/acq.js
function calcNeworderTotal()
we have at line number 667:
var ecost = new Number(Math.floor(rrp * (100 - discount ))/100);

If discount rrp is 35.55 and discount is 0.00, we get a calculation 35.55*100

In JavaScript, this evaluates to 3554.9999999999995

which then is rounded down to the next deeper integer (floor) = 3554, divided
by 100 = 35.54

Same can happen with other values.

As a quick workaround I replaced the line with:

var ecost = rrp;
if (100-discount != 100) { //Prevent rounding issues if no discount
    ecost = new Number(Math.floor(rrp * (100 - discount ))/100);
}

Now, the field gets always the correct value if there is no discount.

Note: With some discount there still could be some tiny rounding errors by 1
cent.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to