MonthlyInventory report

This commit is contained in:
2016-09-19 10:22:53 -04:00
parent 679ef75152
commit d242fea781
23 changed files with 448 additions and 65 deletions
+10 -1
View File
@@ -1,5 +1,14 @@
(function() {
'use strict';
window.app = angular.module('InventoryTraker', ['ngAnimate', 'ui.bootstrap', 'ui.grid', 'ui.grid.pagination', 'mgcrea.ngStrap']);
window.app =
angular
.module('InventoryTraker', ['ngAnimate', 'ui.bootstrap', 'ui.grid', 'ui.grid.pagination', 'mgcrea.ngStrap'])
.config(function($datepickerProvider) {
angular.extend($datepickerProvider.defaults,
{
iconLeft: 'fa fa-chevron-left',
iconRight: 'fa fa-chevron-right'
});
});
})();
@@ -36,7 +36,7 @@
</tr>
</thead>
<tbody ng-hide="vm.loadingTransactions">
<tr ng-repeat-start="transaction in vm.transactions | orderBy:'-transactionDate'">
<tr ng-repeat-start="transaction in vm.transactions | orderBy:['-transactionDate', 'currentQuantity']">
<td>{{transaction.transactionType}}</td>
<td>{{transaction.memo}}</td>
<td>{{transaction.transactionDate | date:'shortDate'}}</td>
@@ -53,8 +53,8 @@
<tr ng-repeat-end ng-show="$first && vm.confirmDeleteTransaction">
<td colspan="7">
<span ng-show="vm.transactions.length == 1" class="text-danger">
Warning: Deleting the only transaction will delete the entire inventory
</span>
Warning: Deleting the only transaction will delete the entire inventory
</span>
<button
ng-click="vm.deleteTransaction(transaction.id)"
class="btn btn-danger btn-sm pull-right">
@@ -7,7 +7,7 @@
<dd>{{inventory.addedDate | date:'shortDate'}}</dd>
<dt>Expiration Date</dt>
<dd>
<span ng-class="{ 'bg-danger': inventory.isExpired }">
<span ng-class="{ 'bg-danger': inventory.quantity && inventory.isExpired }">
{{inventory.expirationDate | date:'shortDate'}}
<span ng-show="inventory.isExpired" class="label label-danger">Expired</span>
</span>
@@ -1,4 +1,4 @@
<table class="table">
<table class="table table-striped">
<thead>
<tr>
<th class="control-column"></th>
@@ -6,6 +6,7 @@
DistributionReportController.$inject = ['$scope', 'reportSvc'];
function DistributionReportController($scope, reportSvc) {
var vm = this;
vm.loadData = reportSvc.loadDistributionReport;
vm.distributionData = reportSvc.distributionData;
}
})();
@@ -6,6 +6,7 @@
MonthlyInventoryReportController.$inject = ['$scope', 'reportSvc'];
function MonthlyInventoryReportController($scope, reportSvc) {
var vm = this;
vm.loadData = reportSvc.loadMonthlyInventoryData;
vm.monthlyInventoryData = reportSvc.monthlyInventoryData;
}
})();
@@ -0,0 +1,29 @@
(function() {
'use strict';
window.app.directive('monthlyInventoryReport', monthlyInventoryReport);
function monthlyInventoryReport() {
return {
scope: { monthlyInventoryData: "=" },
templateUrl: '/report/template/monthlyInventoryReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', '$uibModal', 'inventorySvc'];
function controller($scope, $uibModal, inventorySvc) {
var vm = this;
vm.monthlyInventoryData = $scope.monthlyInventoryData;
vm.editInventory = function (inventoryId) {
inventorySvc.find(inventoryId)
.success(function (inventory) {
$uibModal.open({
template: '<edit-inventory inventory="inventory" />',
scope: angular.extend($scope.$new(true), { inventory: inventory })
});
});
}
}
})();
+3 -3
View File
@@ -4,15 +4,15 @@
reportSvc.$inject = ['$http'];
function reportSvc($http) {
var distributionData = [];
var monthlyInventoryData = [];
var monthlyInventoryData = {};
var svc = {
distributionData: distributionData,
loadDistributionReport: loadDistributionReport,
monthlyInventoryData: monthlyInventoryData,
loadDistributionReport: loadDistributionReport
loadMonthlyInventoryData: loadMonthlyInventoryData
};
loadDistributionReport({ startDate: '2015-05-01', endDate: '2016-01-01' });
return svc;
function loadDistributionReport(query) {
@@ -1,7 +1,7 @@
<div ng-repeat="distribution in vm.distributionData">
<h3>{{distribution.destination}}</h3>
<h4>{{distribution.date | date:'shortDate'}}</h4>
<table class="table">
<table class="table table-striped">
<thead>
<tr>
<th class="col-md-3">Name</th>
@@ -0,0 +1,47 @@
<table class="table table-striped">
<thead>
<tr>
@*<th></th>*@
<th class="col-md-2">Name of Commodity</th>
<th class="col-md-1">Pack Size / Units per Case</th>
<th class="col-md-1">Beginning Inventory</th>
<th class="col-md-1">Units Rec'd</th>
<th class="col-md-1">Total Units Available</th>
<th class="col-md-1">Adjustments (show + or -)</th>
<th class="col-md-1">Units Distributed</th>
<th class="col-md-1">Ending Inventory</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.monthlyInventoryData.items | orderBy:'inventoryType.name'">
@*<td><a href="" ng-click="vm.editInventory(item.inventory.id)"><i class="fa fa-edit"></i></a> </td>*@
<td>{{item.inventoryType.name}}</td>
<td>{{item.inventoryType.unitsPerCase}} / {{item.inventoryType.containerType}}</td>
<td>
{{item.beginningQuantity | toUnits:item.inventoryType.unitsPerCase}}
{{item.beginningQuantity | formatCases}}
</td>
<td>
{{item.addedQuantity | hideZero | toUnits:item.inventoryType.unitsPerCase}}
{{item.addedQuantity | hideZero | formatCases}}
</td>
<td>
{{item.totalAvailableQuantity | hideZero | toUnits:item.inventoryType.unitsPerCase}}
{{item.totalAvailableQuantity | hideZero | formatCases}}
</td>
<td>
{{item.adjustmentQuantity ? '-' : ''}}
{{item.adjustmentQuantity | hideZero | toUnits:item.inventoryType.unitsPerCase}}
{{item.adjustmentQuantity | hideZero | formatCases}}
</td>
<td>
{{item.distributedQuantity | hideZero | toUnits:item.inventoryType.unitsPerCase}}
{{item.distributedQuantity | hideZero | formatCases}}
</td>
<td>
{{item.endingQuantity | toUnits:item.inventoryType.unitsPerCase}}
{{item.endingQuantity | formatCases}}
</td>
</tr>
</tbody>
</table>
@@ -1,18 +1,20 @@
(function() {
'use strict';
window.app.directive('distributionReportQuery', distributionReportQuery);
function distributionReportQuery() {
window.app.directive('dateRangeQuery', dateRangeQuery);
function dateRangeQuery() {
return {
scope: true,
templateUrl: '/report/template/distributionReportQuery.tmpl.cshtml',
scope: {
queryFn: '='
},
templateUrl: '/utility/template/dateRangeQuery.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'reportSvc'];
function controller($scope, reportSvc) {
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
vm.submitting = false;
@@ -21,7 +23,7 @@
function submit() {
vm.submitting = true;
reportSvc.loadDistributionReport(vm.query)
$scope.queryFn(vm.query)
.error(function (data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
@@ -0,0 +1,12 @@
(function() {
window.app.filter('formatCases', formatCases);
function formatCases() {
return function (qty) {
if (qty === '' || !isFinite(qty))
return '';
return '(' + qty + ' cs)';
}
}
})();
@@ -0,0 +1,35 @@
(function() {
'use strict';
window.app.directive('monthQuery', monthQuery);
function monthQuery() {
return {
scope: {
queryFn: '='
},
templateUrl: '/utility/template/monthQuery.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
vm.submitting = false;
vm.errorMessages = [];
vm.submit = submit;
function submit() {
vm.submitting = true;
$scope.queryFn({ month: vm.query })
.error(function (data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function () {
vm.submitting = false;
});
}
}
})();
+13
View File
@@ -0,0 +1,13 @@
(function() {
window.app.filter('toUnits', toUnits);
function toUnits() {
return function (caseQty, unitsPerCase) {
if (caseQty === '' || !isFinite(caseQty) || !isFinite(unitsPerCase))
return '';
return caseQty * unitsPerCase;
}
}
})();
@@ -0,0 +1,25 @@
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.submit()">
<fieldset ng-disabled="vm.submitting">
<error-list errors="vm.errorMessages"></error-list>
<div class="row">
<div class="col-md-12">
<div class="form-group" form-group-validation="Month">
<label for="Month" class="control-label">Month</label>
<input name="Month" type="text"
ng-model="vm.query"
required
data-min-view="1"
data-date-format="M/yy"
class="form-control"
bs-datepicker="" />
</div>
</div>
</div>
</div>
<button class="btn btn-success pull-right">Submit</button>
</fieldset>
</form>