From ba2b98a20d0574164fc426f0014d5b6bcaca44f2 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 20 Jul 2015 17:02:40 -0400 Subject: [PATCH] Don't show items with zero items in a location in the inventory by location report. Resolves HospitalRun/frontend#119 --- app/inventory/reports/controller.js | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/inventory/reports/controller.js b/app/inventory/reports/controller.js index 80b2f07c6c..61bebdf2e7 100644 --- a/app/inventory/reports/controller.js +++ b/app/inventory/reports/controller.js @@ -476,20 +476,22 @@ export default AbstractReportController.extend(LocationName, ModalHelper, Number currentLocation = parentLocation; } for (var id in location.items) { - this._addReportRow({ - giftInKind: location.items[id].giftInKind, - inventoryItem: location.items[id].item, - quantity: location.items[id].quantity, - locations: [{ - name: location.name - }], - totalCost: location.items[id].totalCost, - unitCost: location.items[id].unitCost - }); - parentCount += this._getValidNumber(location.items[id].quantity); - locationCost += this._getValidNumber(location.items[id].totalCost); - this.incrementProperty('grandCost', this._getValidNumber(location.items[id].totalCost)); - this.incrementProperty('grandQuantity', this._getValidNumber(location.items[id].quantity)); + if (location.items[id].quantity > 0) { + this._addReportRow({ + giftInKind: location.items[id].giftInKind, + inventoryItem: location.items[id].item, + quantity: location.items[id].quantity, + locations: [{ + name: location.name + }], + totalCost: location.items[id].totalCost, + unitCost: location.items[id].unitCost + }); + parentCount += this._getValidNumber(location.items[id].quantity); + locationCost += this._getValidNumber(location.items[id].totalCost); + this.incrementProperty('grandCost', this._getValidNumber(location.items[id].totalCost)); + this.incrementProperty('grandQuantity', this._getValidNumber(location.items[id].quantity)); + } } }.bind(this)); this._addTotalsRow('Total for %@: '.fmt(parentLocation), locationCost, parentCount);