diff --git a/app/inventory/edit/controller.js b/app/inventory/edit/controller.js index efc9f503f1..e5fd4461e7 100644 --- a/app/inventory/edit/controller.js +++ b/app/inventory/edit/controller.js @@ -40,6 +40,11 @@ export default AbstractEditController.extend(InventoryLocations, InventoryTypeLi return (this.get('isNew')); }.property('isNew'), + haveTransactions: function() { + var transactions = this.get('transactions'); + return transactions !== null; + }.property('transactions.@each'), + inventoryTypes: function() { var defaultInventoryTypes = this.get('defaultInventoryTypes'), inventoryTypeList = this.get('inventoryTypeList'); @@ -86,6 +91,13 @@ export default AbstractEditController.extend(InventoryLocations, InventoryTypeLi } }.observes('originalQuantity'), + showTransactions: function() { + var transactions = this.get('transactions'); + return !Ember.isEmpty(transactions); + }.property('transactions.@each'), + + transactions: null, + updateCapability: 'add_inventory_item', actions: { @@ -191,7 +203,7 @@ export default AbstractEditController.extend(InventoryLocations, InventoryTypeLi request.get('inventoryItem').then(function() { //Make sure relationships are resolved before saving this._saveRequest(request); - }.bind(this)); + }.bind(this)); }, updatePurchase: function(purchase, updateQuantity) { @@ -278,10 +290,26 @@ export default AbstractEditController.extend(InventoryLocations, InventoryTypeLi request.set('completedBy',request.getUserName()); request.save().then(function() { this.send('update',true); - this.send('closeModal'); + this.send('closeModal'); + this.getTransactions(); }.bind(this)); }, + getTransactions: function() { + var inventoryId = 'inventory_'+this.get('id'); + this.set('transactions',null); + this.store.find('inv-request', { + options: { + endkey: [inventoryId, 'Completed', 0], + startkey: [inventoryId, 'Completed', 9999999999999], + descending: true + }, + mapReduce: 'inventory_request_by_item' + }).then(function(transactions) { + this.set('transactions', transactions); + }.bind(this)); + }, + beforeUpdate: function() { if (this.get('isNew')) { var type = this.get('type'); diff --git a/app/inventory/edit/route.js b/app/inventory/edit/route.js index a1b04e99bc..edb8f153d4 100644 --- a/app/inventory/edit/route.js +++ b/app/inventory/edit/route.js @@ -11,6 +11,10 @@ export default AbstractEditRoute.extend(InventoryId, { this.controller.send('adjustItems',inventoryLocation); }, + doneFulfillRequest: function() { + this.controller.getTransactions(); + }, + deletePurchase: function(purchase, deleteFromLocation) { this.controller.send('deletePurchase', purchase, deleteFromLocation); }, @@ -32,5 +36,10 @@ export default AbstractEditRoute.extend(InventoryId, { return Ember.RSVP.resolve({ dateReceived: new Date() }); + }, + + setupController: function(controller, model) { + this._super(controller, model); + controller.getTransactions(); } }); \ No newline at end of file diff --git a/app/inventory/edit/template.hbs b/app/inventory/edit/template.hbs index 3cf25fa498..1e3b4ecc3d 100644 --- a/app/inventory/edit/template.hbs +++ b/app/inventory/edit/template.hbs @@ -104,5 +104,57 @@ {{/if}} {{/each}} + {{#if showTransactions}} +
Date Completed | +Quantity | +Transaction | +Details | +
---|---|---|---|
{{date-format dateCompleted}} | +{{quantity}} | +{{transactionType}} | +
+ {{#if isAdjustment}}
+ {{#if haveReason}}
+ Reason: {{reason}} + {{/if}} + Location Adjusted: {{deliveryDetails}} + {{/if}} + {{#if isFulfillment}} + Cost Per Unit: {{costPerUnit}} + Quantity At Completion: {{quantityAtCompletion}} + Pulled From: + {{#each locationsAffected}} + {{name}} + {{/each}} + {{#if patient}} + Prescription For: {{deliveryDetails}} + {{else}} + Delivered To: {{deliveryDetails}} + {{/if}} + {{/if}} + {{#if isTransfer}} + Transferred From: + {{#each locationsAffected}} + {{name}} + {{/each}} + Transferred To: {{deliveryDetails}} + {{/if}} + |
+
Loading transactions.... | +