mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Clean up rounding code
This commit is contained in:
parent
2f6e8933f6
commit
31b445f725
@ -30,7 +30,7 @@ class ProductDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'cost',
|
'cost',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
return Utils::formatMoney($model->cost);
|
return Utils::roundSignificant($model->cost);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -866,13 +866,7 @@ function ItemModel(data) {
|
|||||||
|
|
||||||
self.loadData = function(data) {
|
self.loadData = function(data) {
|
||||||
ko.mapping.fromJS(data, {}, this);
|
ko.mapping.fromJS(data, {}, this);
|
||||||
var precision = getPrecision(this.cost());
|
this.cost(roundSignificant(this.cost(), true));
|
||||||
var cost = parseFloat(this.cost());
|
|
||||||
if (cost) {
|
|
||||||
this.cost(cost.toFixed(Math.max(2, precision)));
|
|
||||||
} else {
|
|
||||||
this.cost('');
|
|
||||||
}
|
|
||||||
this.qty(roundSignificant(this.qty()));
|
this.qty(roundSignificant(this.qty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,9 +1019,7 @@ ko.bindingHandlers.productTypeahead = {
|
|||||||
}
|
}
|
||||||
if (parseFloat(datum.cost)) {
|
if (parseFloat(datum.cost)) {
|
||||||
if (! model.cost() || ! model.task_public_id()) {
|
if (! model.cost() || ! model.task_public_id()) {
|
||||||
var cost = roundSignificant(datum.cost);
|
model.cost(roundSignificant(datum.cost, true));
|
||||||
var precision = getPrecision(cost);
|
|
||||||
model.cost(cost.toFixed(precision));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!model.qty()) {
|
if (!model.qty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user