mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Clean up JS rounding code
This commit is contained in:
parent
fed2e57891
commit
ee917ba95a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -612,8 +612,8 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
|||||||
custom_value1 = processVariables(item.custom_value1);
|
custom_value1 = processVariables(item.custom_value1);
|
||||||
custom_value2 = processVariables(item.custom_value2);
|
custom_value2 = processVariables(item.custom_value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lineTotal = roundSignificant(NINJA.parseFloat(item.cost)) * roundSignificant(NINJA.parseFloat(item.qty));
|
var lineTotal = roundSignificant(NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty));
|
||||||
if (account.include_item_taxes_inline == '1') {
|
if (account.include_item_taxes_inline == '1') {
|
||||||
var taxAmount1 = 0;
|
var taxAmount1 = 0;
|
||||||
var taxAmount2 = 0;
|
var taxAmount2 = 0;
|
||||||
|
@ -1060,20 +1060,20 @@ function getPrecision(number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function roundSignificant(number) {
|
function roundSignificant(number, toString) {
|
||||||
var precision = getPrecision(number);
|
var precision = getPrecision(number);
|
||||||
var value = roundToPrecision(number, precision);
|
var val = roundToPrecision(number, precision) || 0;
|
||||||
return isNaN(value) ? 0 : value;
|
return toString ? val.toFixed(precision) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function roundToTwo(number, toString) {
|
function roundToTwo(number, toString) {
|
||||||
var val = roundToPrecision(number, 2);
|
var val = roundToPrecision(number, 2) || 0;
|
||||||
return toString ? val.toFixed(2) : (val || 0);
|
return toString ? val.toFixed(2) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function roundToFour(number, toString) {
|
function roundToFour(number, toString) {
|
||||||
var val = roundToPrecision(number, 4);
|
var val = roundToPrecision(number, 4) || 0;
|
||||||
return toString ? val.toFixed(4) : (val || 0);
|
return toString ? val.toFixed(4) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/18358056/497368
|
// https://stackoverflow.com/a/18358056/497368
|
||||||
|
Loading…
x
Reference in New Issue
Block a user