From 743fc5e02c16d08fa5ecb4341f8666527aa20146 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 12:56:11 -0500 Subject: [PATCH 1/7] Add unit model test InventoryPurchaseItem - Add unit model test inv-purchase InventoryPurchaseItem --- tests/unit/models/inv-purchase-test.js | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/unit/models/inv-purchase-test.js diff --git a/tests/unit/models/inv-purchase-test.js b/tests/unit/models/inv-purchase-test.js new file mode 100644 index 0000000000..954cff0bc6 --- /dev/null +++ b/tests/unit/models/inv-purchase-test.js @@ -0,0 +1,46 @@ +import { moduleForModel, test } from 'ember-qunit'; + +import { testValidPropertyValues, testInvalidPropertyValues } from '../../helpers/validate-properties'; + +moduleForModel('inv-purchase', 'Unit | Model | inv-purchase', { + needs: [ + 'ember-validations@validator:local/numericality', + 'ember-validations@validator:local/presence' + ] +}); + +test('costPerUnit', function(assert) { + let inventoryPurchaseItem = this.subject({ + purchaseCost: 12.50, + originalQuantity: 5 + }); + + assert.strictEqual(inventoryPurchaseItem.get('costPerUnit'), 2.5); +}); + +test('costPerUnit invalid input', function(assert) { + let inventoryPurchaseItem = this.subject({ + purchaseCost: 0, + originalQuantity: 5 + }); + + assert.strictEqual(inventoryPurchaseItem.get('costPerUnit'), 0); +}); + +test('costPerUnit 0 input', function(assert) { + let inventoryPurchaseItem = this.subject({ + purchaseCost: 12.50, + originalQuantity: 0 + }); + + assert.strictEqual(inventoryPurchaseItem.get('costPerUnit'), 0); +}); + +testValidPropertyValues('purchaseCost', [123, 123.0, '123']); +testInvalidPropertyValues('purchaseCost', ['test', undefined]); + +testValidPropertyValues('originalQuantity', [0, 123, '0']); +testInvalidPropertyValues('originalQuantity', [-1, '-1', undefined]); + +testValidPropertyValues('vendor', ['test']); +testInvalidPropertyValues('vendor', [undefined]); From 7e9ee068ebdd682ac7aec2722ef37d9bcf8c3cda Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 13:46:10 -0500 Subject: [PATCH 2/7] Fix incorrect rounding add math util - Fix incorrect calculation `InventoryPurchaseItem.costPerUnit` to round property to the nearest 100th - Add test for demostrating issue in `inv-purchase-test.js` "costPerUnit properly round" - Add math util with function `round100` - Add tests for `round100` function --- app/models/inv-purchase.js | 3 ++- app/utils/math.js | 9 +++++++++ tests/unit/models/inv-purchase-test.js | 9 +++++++++ tests/unit/utils/math-test.js | 12 ++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/utils/math.js create mode 100644 tests/unit/utils/math-test.js diff --git a/app/models/inv-purchase.js b/app/models/inv-purchase.js index 10bd51a7f9..6222afe999 100644 --- a/app/models/inv-purchase.js +++ b/app/models/inv-purchase.js @@ -2,6 +2,7 @@ import AbstractModel from 'hospitalrun/models/abstract'; import DS from 'ember-data'; import Ember from 'ember'; import LocationName from 'hospitalrun/mixins/location-name'; +import { round100 } from 'hospitalrun/utils/math'; function defaultQuantityGroups() { return []; @@ -23,7 +24,7 @@ let InventoryPurchaseItem = AbstractModel.extend(LocationName, { if (Ember.isEmpty(purchaseCost) || Ember.isEmpty(quantity) || purchaseCost === 0 || quantity === 0) { return 0; } - return Number((purchaseCost / quantity).toFixed(2)); + return round100(purchaseCost / quantity); }.property('purchaseCost', 'originalQuantity'), originalQuantity: DS.attr('number'), currentQuantity: DS.attr('number'), diff --git a/app/utils/math.js b/app/utils/math.js new file mode 100644 index 0000000000..44612e0d09 --- /dev/null +++ b/app/utils/math.js @@ -0,0 +1,9 @@ +/** + * Rounds number to the nearest 100th + * @param {Number} number + * @returns Number + */ +export function round100(number) { + let tempNumber = 100 * number; + return Math.round(tempNumber) / 100; +} diff --git a/tests/unit/models/inv-purchase-test.js b/tests/unit/models/inv-purchase-test.js index 954cff0bc6..330aee78c5 100644 --- a/tests/unit/models/inv-purchase-test.js +++ b/tests/unit/models/inv-purchase-test.js @@ -18,6 +18,15 @@ test('costPerUnit', function(assert) { assert.strictEqual(inventoryPurchaseItem.get('costPerUnit'), 2.5); }); +test('costPerUnit properly round', function(assert) { + let inventoryPurchaseItem = this.subject({ + purchaseCost: 71.11, + originalQuantity: 2 + }); + + assert.strictEqual(inventoryPurchaseItem.get('costPerUnit'), 35.56); +}); + test('costPerUnit invalid input', function(assert) { let inventoryPurchaseItem = this.subject({ purchaseCost: 0, diff --git a/tests/unit/utils/math-test.js b/tests/unit/utils/math-test.js new file mode 100644 index 0000000000..635ec6521b --- /dev/null +++ b/tests/unit/utils/math-test.js @@ -0,0 +1,12 @@ +import { round100 } from 'hospitalrun/utils/math'; +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('util:math', 'Unit | Utils | math'); + +test('round100', function(assert) { + assert.strictEqual(round100(1), 1, 'Should leave number untouched'); + assert.strictEqual(round100(10.5), 10.5, 'Should leave 1 decimal untouched'); + assert.strictEqual(round100(10.55), 10.55, 'Should leave 2 decimal untouched'); + assert.strictEqual(round100(10.358), 10.36, 'Should round 10.358, 10.36'); + assert.strictEqual(round100(35.555), 35.56, 'Should round 8.455 to 8.46'); +}); From a6a064ee0b7e54ce6254c88fbb164fa25727415e Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 18:06:41 -0500 Subject: [PATCH 3/7] Fix rounding in mixin number-format and unit test - Fix rounding in `_numberFormat` for number-format mixin - Add mixin unit tests for number-format mixin --- app/mixins/number-format.js | 7 +++- tests/mixins/number-format-test.js | 59 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/mixins/number-format-test.js diff --git a/app/mixins/number-format.js b/app/mixins/number-format.js index 581d968ee0..de26c25887 100644 --- a/app/mixins/number-format.js +++ b/app/mixins/number-format.js @@ -49,7 +49,7 @@ export default Ember.Mixin.create({ if (Math.round(value) === value) { returnValue = Number(value).toString(); } else { - returnValue = Number(value).toFixed(2); + returnValue = this._round100(value).toFixed(2); } if (returnAsNumber) { return Number(returnValue); @@ -61,6 +61,11 @@ export default Ember.Mixin.create({ _validNumber(number) { return (!Ember.isEmpty(number) && !isNaN(number) && number > 0); + }, + + _round100(number) { + let tempNumber = 100 * number; + return Math.round(tempNumber) / 100; } }); diff --git a/tests/mixins/number-format-test.js b/tests/mixins/number-format-test.js new file mode 100644 index 0000000000..2ec518500e --- /dev/null +++ b/tests/mixins/number-format-test.js @@ -0,0 +1,59 @@ +import NumberFormat from 'hospitalrun/mixins/number-format'; +import { moduleFor, test } from 'ember-qunit'; +import Ember from 'ember'; + +moduleFor('mixin:number-format', 'Unit | Mixin | number-format'); + +test('_calculateTotal', function(assert) { + let records = [5, 5, 6].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); + + assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 16, 'Should add property array'); +}); + +test('_calculateTotal property name', function(assert) { + let records = [5, 2, 3].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._calculateTotal(records, 'id'), 10, 'Should add passed in array'); +}); + +test('_calculateTotal invalid number', function(assert) { + let records = [5, 'test', 3].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); + + assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 8, 'Should treat invalid number as 0'); +}); + +test('_numberFormat', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._numberFormat(), undefined, 'Should return undefined for no argument'); + assert.strictEqual(numberFormat._numberFormat('test'), undefined, 'Should return undefined for no number'); + assert.strictEqual(numberFormat._numberFormat(12), '12', 'Should return basic int as string'); + assert.strictEqual(numberFormat._numberFormat(12, true), 12, 'Should return basic int as number'); + assert.strictEqual(numberFormat._numberFormat(12.2, true), 12.2, 'Should round tenths properly'); + assert.strictEqual(numberFormat._numberFormat(12.2), '12.20', 'Should pad decial to two places'); + assert.strictEqual(numberFormat._numberFormat(35.555, true), 35.56, 'Should round 35.555 to 35.56'); + assert.strictEqual(numberFormat._numberFormat(35.555), '35.56', 'Should return 35.555 as string "35.56"'); +}); + +test('_getValidNumber', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._getValidNumber(), 0, 'Should return 0 for no argument'); + assert.strictEqual(numberFormat._getValidNumber('test'), 0, 'Should return 0 for invalid number'); + assert.strictEqual(numberFormat._getValidNumber(NaN), 0, 'Should return 0 for NaN'); + assert.strictEqual(numberFormat._getValidNumber('12.2'), 12.2, 'Should convert string to number'); + assert.strictEqual(numberFormat._getValidNumber(1), 1, 'Should return basic int'); +}); + +test('_validNumber', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._validNumber(1), true, 'Should return true for basic int'); + assert.strictEqual(numberFormat._validNumber(1.5), true, 'Should return true for float'); + assert.strictEqual(numberFormat._validNumber('1'), true, 'Should return true for numeric string'); + assert.strictEqual(numberFormat._validNumber(-1), false, 'Should return false for negative'); + assert.strictEqual(numberFormat._validNumber('test'), false, 'Should return false for non numeric string'); +}); From 62af93a16c1780254fe2c963b51c833d19a65f25 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 18:12:30 -0500 Subject: [PATCH 4/7] Fix incorrect directory for number-format-test --- tests/mixins/number-format-test.js | 10 +++++ tests/unit/mixins/number-format-test.js | 59 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/unit/mixins/number-format-test.js diff --git a/tests/mixins/number-format-test.js b/tests/mixins/number-format-test.js index 2ec518500e..759bc5b68b 100644 --- a/tests/mixins/number-format-test.js +++ b/tests/mixins/number-format-test.js @@ -57,3 +57,13 @@ test('_validNumber', function(assert) { assert.strictEqual(numberFormat._validNumber(-1), false, 'Should return false for negative'); assert.strictEqual(numberFormat._validNumber('test'), false, 'Should return false for non numeric string'); }); + +test('_round100', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._round100(1), 1, 'Should leave number untouched'); + assert.strictEqual(numberFormat._round100(10.5), 10.5, 'Should leave 1 decimal untouched'); + assert.strictEqual(numberFormat._round100(10.55), 10.55, 'Should leave 2 decimal untouched'); + assert.strictEqual(numberFormat._round100(10.358), 10.36, 'Should round 10.358, 10.36'); + assert.strictEqual(numberFormat._round100(35.555), 35.56, 'Should round 8.455 to 8.46'); +}); diff --git a/tests/unit/mixins/number-format-test.js b/tests/unit/mixins/number-format-test.js new file mode 100644 index 0000000000..2ec518500e --- /dev/null +++ b/tests/unit/mixins/number-format-test.js @@ -0,0 +1,59 @@ +import NumberFormat from 'hospitalrun/mixins/number-format'; +import { moduleFor, test } from 'ember-qunit'; +import Ember from 'ember'; + +moduleFor('mixin:number-format', 'Unit | Mixin | number-format'); + +test('_calculateTotal', function(assert) { + let records = [5, 5, 6].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); + + assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 16, 'Should add property array'); +}); + +test('_calculateTotal property name', function(assert) { + let records = [5, 2, 3].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._calculateTotal(records, 'id'), 10, 'Should add passed in array'); +}); + +test('_calculateTotal invalid number', function(assert) { + let records = [5, 'test', 3].map((id) => Ember.Object.create({ id })); + let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); + + assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 8, 'Should treat invalid number as 0'); +}); + +test('_numberFormat', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._numberFormat(), undefined, 'Should return undefined for no argument'); + assert.strictEqual(numberFormat._numberFormat('test'), undefined, 'Should return undefined for no number'); + assert.strictEqual(numberFormat._numberFormat(12), '12', 'Should return basic int as string'); + assert.strictEqual(numberFormat._numberFormat(12, true), 12, 'Should return basic int as number'); + assert.strictEqual(numberFormat._numberFormat(12.2, true), 12.2, 'Should round tenths properly'); + assert.strictEqual(numberFormat._numberFormat(12.2), '12.20', 'Should pad decial to two places'); + assert.strictEqual(numberFormat._numberFormat(35.555, true), 35.56, 'Should round 35.555 to 35.56'); + assert.strictEqual(numberFormat._numberFormat(35.555), '35.56', 'Should return 35.555 as string "35.56"'); +}); + +test('_getValidNumber', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._getValidNumber(), 0, 'Should return 0 for no argument'); + assert.strictEqual(numberFormat._getValidNumber('test'), 0, 'Should return 0 for invalid number'); + assert.strictEqual(numberFormat._getValidNumber(NaN), 0, 'Should return 0 for NaN'); + assert.strictEqual(numberFormat._getValidNumber('12.2'), 12.2, 'Should convert string to number'); + assert.strictEqual(numberFormat._getValidNumber(1), 1, 'Should return basic int'); +}); + +test('_validNumber', function(assert) { + let numberFormat = Ember.Object.extend(NumberFormat).create(); + + assert.strictEqual(numberFormat._validNumber(1), true, 'Should return true for basic int'); + assert.strictEqual(numberFormat._validNumber(1.5), true, 'Should return true for float'); + assert.strictEqual(numberFormat._validNumber('1'), true, 'Should return true for numeric string'); + assert.strictEqual(numberFormat._validNumber(-1), false, 'Should return false for negative'); + assert.strictEqual(numberFormat._validNumber('test'), false, 'Should return false for non numeric string'); +}); From c4cd4d287efa06028122001ceb6d31c9a266fce0 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 18:18:12 -0500 Subject: [PATCH 5/7] Use NumberFormat for InventoryPurchaseItem - Use `NumberFormat` mixin for `InventoryPurchaseItem` and use in `costPerUnit` method - Remove math util as no longer needed --- app/models/inv-purchase.js | 6 +++--- app/utils/math.js | 9 --------- tests/unit/utils/math-test.js | 12 ------------ 3 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 app/utils/math.js delete mode 100644 tests/unit/utils/math-test.js diff --git a/app/models/inv-purchase.js b/app/models/inv-purchase.js index 6222afe999..aa909d465a 100644 --- a/app/models/inv-purchase.js +++ b/app/models/inv-purchase.js @@ -2,7 +2,7 @@ import AbstractModel from 'hospitalrun/models/abstract'; import DS from 'ember-data'; import Ember from 'ember'; import LocationName from 'hospitalrun/mixins/location-name'; -import { round100 } from 'hospitalrun/utils/math'; +import NumberFormat from 'hospitalrun/mixins/number-format'; function defaultQuantityGroups() { return []; @@ -14,7 +14,7 @@ function defaultQuantityGroups() { * items to be shown as inventory items since the pouchdb adapter does a * retrieve for keys starting with 'inventory' to fetch inventory items. */ -let InventoryPurchaseItem = AbstractModel.extend(LocationName, { +let InventoryPurchaseItem = AbstractModel.extend(LocationName, NumberFormat, { purchaseCost: DS.attr('number'), lotNumber: DS.attr('string'), dateReceived: DS.attr('date'), @@ -24,7 +24,7 @@ let InventoryPurchaseItem = AbstractModel.extend(LocationName, { if (Ember.isEmpty(purchaseCost) || Ember.isEmpty(quantity) || purchaseCost === 0 || quantity === 0) { return 0; } - return round100(purchaseCost / quantity); + return this._round100(purchaseCost / quantity); }.property('purchaseCost', 'originalQuantity'), originalQuantity: DS.attr('number'), currentQuantity: DS.attr('number'), diff --git a/app/utils/math.js b/app/utils/math.js deleted file mode 100644 index 44612e0d09..0000000000 --- a/app/utils/math.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Rounds number to the nearest 100th - * @param {Number} number - * @returns Number - */ -export function round100(number) { - let tempNumber = 100 * number; - return Math.round(tempNumber) / 100; -} diff --git a/tests/unit/utils/math-test.js b/tests/unit/utils/math-test.js deleted file mode 100644 index 635ec6521b..0000000000 --- a/tests/unit/utils/math-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { round100 } from 'hospitalrun/utils/math'; -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('util:math', 'Unit | Utils | math'); - -test('round100', function(assert) { - assert.strictEqual(round100(1), 1, 'Should leave number untouched'); - assert.strictEqual(round100(10.5), 10.5, 'Should leave 1 decimal untouched'); - assert.strictEqual(round100(10.55), 10.55, 'Should leave 2 decimal untouched'); - assert.strictEqual(round100(10.358), 10.36, 'Should round 10.358, 10.36'); - assert.strictEqual(round100(35.555), 35.56, 'Should round 8.455 to 8.46'); -}); From af9ad45b31859a450a11ce5cf0293d7139a515c4 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 18:26:09 -0500 Subject: [PATCH 6/7] Remove duplicate number-format-test --- tests/mixins/number-format-test.js | 69 ------------------------------ 1 file changed, 69 deletions(-) delete mode 100644 tests/mixins/number-format-test.js diff --git a/tests/mixins/number-format-test.js b/tests/mixins/number-format-test.js deleted file mode 100644 index 759bc5b68b..0000000000 --- a/tests/mixins/number-format-test.js +++ /dev/null @@ -1,69 +0,0 @@ -import NumberFormat from 'hospitalrun/mixins/number-format'; -import { moduleFor, test } from 'ember-qunit'; -import Ember from 'ember'; - -moduleFor('mixin:number-format', 'Unit | Mixin | number-format'); - -test('_calculateTotal', function(assert) { - let records = [5, 5, 6].map((id) => Ember.Object.create({ id })); - let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); - - assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 16, 'Should add property array'); -}); - -test('_calculateTotal property name', function(assert) { - let records = [5, 2, 3].map((id) => Ember.Object.create({ id })); - let numberFormat = Ember.Object.extend(NumberFormat).create(); - - assert.strictEqual(numberFormat._calculateTotal(records, 'id'), 10, 'Should add passed in array'); -}); - -test('_calculateTotal invalid number', function(assert) { - let records = [5, 'test', 3].map((id) => Ember.Object.create({ id })); - let numberFormat = Ember.Object.extend(NumberFormat).create({ records }); - - assert.strictEqual(numberFormat._calculateTotal('records', 'id'), 8, 'Should treat invalid number as 0'); -}); - -test('_numberFormat', function(assert) { - let numberFormat = Ember.Object.extend(NumberFormat).create(); - - assert.strictEqual(numberFormat._numberFormat(), undefined, 'Should return undefined for no argument'); - assert.strictEqual(numberFormat._numberFormat('test'), undefined, 'Should return undefined for no number'); - assert.strictEqual(numberFormat._numberFormat(12), '12', 'Should return basic int as string'); - assert.strictEqual(numberFormat._numberFormat(12, true), 12, 'Should return basic int as number'); - assert.strictEqual(numberFormat._numberFormat(12.2, true), 12.2, 'Should round tenths properly'); - assert.strictEqual(numberFormat._numberFormat(12.2), '12.20', 'Should pad decial to two places'); - assert.strictEqual(numberFormat._numberFormat(35.555, true), 35.56, 'Should round 35.555 to 35.56'); - assert.strictEqual(numberFormat._numberFormat(35.555), '35.56', 'Should return 35.555 as string "35.56"'); -}); - -test('_getValidNumber', function(assert) { - let numberFormat = Ember.Object.extend(NumberFormat).create(); - - assert.strictEqual(numberFormat._getValidNumber(), 0, 'Should return 0 for no argument'); - assert.strictEqual(numberFormat._getValidNumber('test'), 0, 'Should return 0 for invalid number'); - assert.strictEqual(numberFormat._getValidNumber(NaN), 0, 'Should return 0 for NaN'); - assert.strictEqual(numberFormat._getValidNumber('12.2'), 12.2, 'Should convert string to number'); - assert.strictEqual(numberFormat._getValidNumber(1), 1, 'Should return basic int'); -}); - -test('_validNumber', function(assert) { - let numberFormat = Ember.Object.extend(NumberFormat).create(); - - assert.strictEqual(numberFormat._validNumber(1), true, 'Should return true for basic int'); - assert.strictEqual(numberFormat._validNumber(1.5), true, 'Should return true for float'); - assert.strictEqual(numberFormat._validNumber('1'), true, 'Should return true for numeric string'); - assert.strictEqual(numberFormat._validNumber(-1), false, 'Should return false for negative'); - assert.strictEqual(numberFormat._validNumber('test'), false, 'Should return false for non numeric string'); -}); - -test('_round100', function(assert) { - let numberFormat = Ember.Object.extend(NumberFormat).create(); - - assert.strictEqual(numberFormat._round100(1), 1, 'Should leave number untouched'); - assert.strictEqual(numberFormat._round100(10.5), 10.5, 'Should leave 1 decimal untouched'); - assert.strictEqual(numberFormat._round100(10.55), 10.55, 'Should leave 2 decimal untouched'); - assert.strictEqual(numberFormat._round100(10.358), 10.36, 'Should round 10.358, 10.36'); - assert.strictEqual(numberFormat._round100(35.555), 35.56, 'Should round 8.455 to 8.46'); -}); From 8a3b8ba1c9a66b76af19abfd98248bcca19ed69e Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Tue, 13 Dec 2016 20:54:36 -0500 Subject: [PATCH 7/7] Prefer _numberFormat to _round100 --- app/models/inv-purchase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/inv-purchase.js b/app/models/inv-purchase.js index aa909d465a..e2a0d72e22 100644 --- a/app/models/inv-purchase.js +++ b/app/models/inv-purchase.js @@ -24,7 +24,7 @@ let InventoryPurchaseItem = AbstractModel.extend(LocationName, NumberFormat, { if (Ember.isEmpty(purchaseCost) || Ember.isEmpty(quantity) || purchaseCost === 0 || quantity === 0) { return 0; } - return this._round100(purchaseCost / quantity); + return this._numberFormat(purchaseCost / quantity, true); }.property('purchaseCost', 'originalQuantity'), originalQuantity: DS.attr('number'), currentQuantity: DS.attr('number'),