InventoryType from XML
Transaction updates
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc'];
|
||||
|
||||
function controller($scope, inventorySvc, inventoryTypeSvc) {
|
||||
var vm = this;
|
||||
|
||||
@@ -19,6 +20,7 @@
|
||||
vm.saving = false;
|
||||
vm.inventory = {};
|
||||
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
|
||||
|
||||
vm.errorMessage = null;
|
||||
vm.quantity = quantity;
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('inventoryDistribute', inventoryDistribute);
|
||||
|
||||
function inventoryDistribute() {
|
||||
return {
|
||||
templateUrl: '/inventory/template/inventoryDistribute.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'inventorySvc'];
|
||||
function controller($scope, inventorySvc) {
|
||||
var vm = this;
|
||||
|
||||
vm.save = save;
|
||||
vm.saving = false;
|
||||
vm.quantities = angular.copy(inventorySvc.inventories);
|
||||
vm.distribution = {};
|
||||
vm.errorMessage = null;
|
||||
|
||||
function getInventoryDistributeQuantities(inventory) {
|
||||
var invQty = [];
|
||||
inventory.forEach(function (i) {
|
||||
if (i.distributeQuantity > 0)
|
||||
invQty.push({ inventoryId: i.id, quantity: i.distributeQuantity });
|
||||
});
|
||||
return invQty;
|
||||
}
|
||||
|
||||
function save() {
|
||||
vm.saving = true;
|
||||
vm.distribution.inventoryQuantities = getInventoryDistributeQuantities(vm.quantities);
|
||||
inventorySvc.distribute(vm.distribution)
|
||||
.success(function () {
|
||||
//Close the modal
|
||||
$scope.$close();
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage =
|
||||
'There was a problem distributing the inventory: ' + data.errorMessage;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -6,7 +6,9 @@
|
||||
InventoryListController.$inject = ['$uibModal', 'inventorySvc'];
|
||||
function InventoryListController($uibModal, inventorySvc) {
|
||||
var vm = this;
|
||||
|
||||
vm.add = add;
|
||||
vm.distribute = distribute;
|
||||
vm.inventories = inventorySvc.inventories;
|
||||
|
||||
function add() {
|
||||
@@ -15,5 +17,12 @@
|
||||
backdrop: 'static'
|
||||
});
|
||||
}
|
||||
|
||||
function distribute() {
|
||||
$uibModal.open({
|
||||
template: '<inventory-distribute />',
|
||||
backdrop: 'static'
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -9,9 +9,10 @@
|
||||
|
||||
var svc = {
|
||||
add: add,
|
||||
distribute: distribute,
|
||||
update: update,
|
||||
inventories: inventories,
|
||||
getInventory: getInventory,
|
||||
getInventory: getInventory
|
||||
};
|
||||
|
||||
return svc;
|
||||
@@ -19,7 +20,7 @@
|
||||
function loadInventories() {
|
||||
$http.post('/Inventory/All')
|
||||
.success(function(data) {
|
||||
inventories.addRange(data);
|
||||
angular.copy(data, inventories);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,6 +31,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function distribute(distribution) {
|
||||
return $http.post('/Inventory/Distribute', distribution)
|
||||
.success(function (data) {
|
||||
angular.copy(data, inventories);
|
||||
});
|
||||
}
|
||||
|
||||
function update(existingInventory, updatedInventory) {
|
||||
return $http.post('/Inventory/Update', updatedInventory)
|
||||
.success(function(inventory) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</a>
|
||||
</script>
|
||||
|
||||
<div class="form-group has-feedback" ng-class="vm.getValidationClass()" form-group-validation="Commodity">
|
||||
<div class="form-group" form-group-validation="Commodity">
|
||||
<label for="Commodity" class="control-label">Commodity</label>
|
||||
<input name="Commodity" type="text"
|
||||
ng-model="vm.commodity"
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
@inventory.FormGroupFor(m => m.ExpirationDate)
|
||||
|
||||
<div class="form-group has-feedback panel panel-default">
|
||||
<div class="form-group panel panel-default">
|
||||
<div class="panel-heading"><label>Quantity</label></div>
|
||||
<div class="panel-body container-fluid">
|
||||
<div class="row">
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.InventoryDistributeForm
|
||||
@{
|
||||
var distribution = Html.Angular().ModelFor("vm.distribution");
|
||||
}
|
||||
<form novalidate
|
||||
name="vm.form"
|
||||
ng-submit="vm.form.$valid && vm.save()">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Inventory Distribution</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Enter details for the inventory arrival below.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@distribution.FormGroupFor(m => m.Destination)
|
||||
|
||||
<table class="table" ng-class="vm.getValidationClass()">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name<br />Units per Case</th>
|
||||
<th>Available Case Qty</th>
|
||||
<th>Distribute Case Qty</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="inventory in vm.quantities" inventory="inventory">
|
||||
<td>
|
||||
<label class="control-label" for="DistributeQuantity{{inventory.name}}">
|
||||
{{inventory.name}}<br />
|
||||
{{inventory.unitsPerCase}} / {{inventory.containerType}}
|
||||
</label>
|
||||
</td>
|
||||
<td>{{inventory.quantity}}</td>
|
||||
<td>
|
||||
<div class="form-group" form-group-validation="DistributeQuantity{{inventory.name}}">
|
||||
<input name="DistributeQuantity{{inventory.name}}" type="number"
|
||||
class="form-control"
|
||||
ng-model="inventory.distributeQuantity"
|
||||
ng-max="{{inventory.quantity}}"
|
||||
ng-min="0" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@distribution.FormGroupFor(m => m.DistributedDate)
|
||||
|
||||
@distribution.FormGroupFor(m => m.Memo)
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Save</button>
|
||||
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,40 @@
|
||||
(function() {
|
||||
window.app.factory('transactionSvc', transactionSvc);
|
||||
|
||||
transactionSvc.$inject = ['$http'];
|
||||
function transactionSvc($http) {
|
||||
var transactions = [];
|
||||
|
||||
loadTransactions();
|
||||
|
||||
var svc = {
|
||||
add: add,
|
||||
update: update,
|
||||
transactions: transactions,
|
||||
getTransaction: getTransaction
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function loadTransactions() {
|
||||
$http.post('/Transaction/All')
|
||||
.success(function(data) {
|
||||
angular.copy(data, transactions);
|
||||
});
|
||||
}
|
||||
|
||||
function update(existingTransaction, updatedTransaction) {
|
||||
return $http.post('/Transaction/Update', updatedTransaction)
|
||||
.success(function(transaction) {
|
||||
angular.extend(existingTransaction, transaction);
|
||||
});
|
||||
}
|
||||
|
||||
function getTransaction(id) {
|
||||
for (var i = 0; i < transactions.length; i++) {
|
||||
if (transactions[i].Id == id) return transactions[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -11,7 +11,7 @@
|
||||
template:
|
||||
'<div class="has-feedback" ng-class="vm.getValidationClass()">' +
|
||||
'<ng-transclude></ng-transclude>' +
|
||||
'<input-validation-icons field="vm.field"></input-validation-icons>' +
|
||||
//'<input-validation-icons field="vm.field"></input-validation-icons>' +
|
||||
'</div>',
|
||||
scope: {
|
||||
field: '@formGroupValidation'
|
||||
|
||||
Reference in New Issue
Block a user