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',
|
||||
function ($model) {
|
||||
return Utils::formatMoney($model->cost);
|
||||
return Utils::roundSignificant($model->cost);
|
||||
},
|
||||
],
|
||||
[
|
||||
|
@ -866,13 +866,7 @@ function ItemModel(data) {
|
||||
|
||||
self.loadData = function(data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
var precision = getPrecision(this.cost());
|
||||
var cost = parseFloat(this.cost());
|
||||
if (cost) {
|
||||
this.cost(cost.toFixed(Math.max(2, precision)));
|
||||
} else {
|
||||
this.cost('');
|
||||
}
|
||||
this.cost(roundSignificant(this.cost(), true));
|
||||
this.qty(roundSignificant(this.qty()));
|
||||
}
|
||||
|
||||
@ -1025,9 +1019,7 @@ ko.bindingHandlers.productTypeahead = {
|
||||
}
|
||||
if (parseFloat(datum.cost)) {
|
||||
if (! model.cost() || ! model.task_public_id()) {
|
||||
var cost = roundSignificant(datum.cost);
|
||||
var precision = getPrecision(cost);
|
||||
model.cost(cost.toFixed(precision));
|
||||
model.cost(roundSignificant(datum.cost, true));
|
||||
}
|
||||
}
|
||||
if (!model.qty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user