mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Fix for negative rounding
This commit is contained in:
parent
5eaa938809
commit
17ecf8ecde
@ -139,7 +139,7 @@ class CheckData extends Command
|
||||
|
||||
private function checkInvoices()
|
||||
{
|
||||
if (! env('PHANTOMJS_BIN_PATH')) {
|
||||
if (! env('PHANTOMJS_BIN_PATH') || ! Utils::isNinjaProd()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1043,16 +1043,30 @@ function toggleDatePicker(field) {
|
||||
$('#'+field).datepicker('show');
|
||||
}
|
||||
|
||||
function roundToTwo(num, toString) {
|
||||
var val = +(Math.round(num + "e+2") + "e-2");
|
||||
function roundToTwo(number, toString) {
|
||||
var val = roundToPrecision(number, 2);
|
||||
return toString ? val.toFixed(2) : (val || 0);
|
||||
}
|
||||
|
||||
function roundToFour(num, toString) {
|
||||
var val = +(Math.round(num + "e+4") + "e-4");
|
||||
function roundToFour(number, toString) {
|
||||
var val = roundToPrecision(number, 4);
|
||||
return toString ? val.toFixed(4) : (val || 0);
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/18358056/497368
|
||||
function roundToPrecision(number, precision) {
|
||||
// prevent negative numbers from rounding to 0
|
||||
var isNegative = number < 0;
|
||||
if (isNegative) {
|
||||
number = number * -1;
|
||||
}
|
||||
number = +(Math.round(number + "e+"+ precision) + "e-" + precision);
|
||||
if (isNegative) {
|
||||
number = number * -1;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
function truncate(str, length) {
|
||||
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user