Remove inventory, delete transactions

This commit is contained in:
2016-09-14 07:53:41 -04:00
parent 9cdf90b1e9
commit 052f812d6f
33 changed files with 3250 additions and 142 deletions
@@ -1,8 +1,8 @@
(function() {
window.app.factory('inventorySvc', inventorySvc);
inventorySvc.$inject = ['$http'];
function inventorySvc($http) {
inventorySvc.$inject = ['$http', '$filter'];
function inventorySvc($http, $filter) {
var inventories = [];
loadInventories();
@@ -11,8 +11,11 @@
add: add,
distribute: distribute,
update: update,
remove: remove,
inventories: inventories,
getInventory: getInventory
get: get,
refresh: refresh,
find: find
};
return svc;
@@ -45,7 +48,34 @@
});
}
function getInventory(id) {
// remove quantity from this inventory
function remove(removeForm) {
var existingInventory = get(removeForm.inventoryId);
return $http.post('/Inventory/Remove', removeForm)
.success(function(data) {
angular.copy(data, existingInventory);
});
}
function get(id) {
var results = $filter('filter')(inventories, { id: id });
if (results.length > 0)
return results[0];
return null;
}
// refresh this inventory from the server
function refresh(id) {
var existingInventory = get(id);
if (existingInventory) {
find(id)
.success(function(inventory) {
angular.copy(inventory, existingInventory);
});
}
}
function find(id) {
return $http.post('/Inventory/Find', { id: id });
}
}