diff --git a/app/Ninja/Datatables/ProductDatatable.php b/app/Ninja/Datatables/ProductDatatable.php index d5a3aba104d6..2325d78f52ac 100644 --- a/app/Ninja/Datatables/ProductDatatable.php +++ b/app/Ninja/Datatables/ProductDatatable.php @@ -30,7 +30,7 @@ class ProductDatatable extends EntityDatatable [ 'cost', function ($model) { - return Utils::formatMoney($model->cost); + return Utils::roundSignificant($model->cost); }, ], [ diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index 197b327792b2..3e5a336dc2c9 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -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()) {