Distribution report

This commit is contained in:
2016-09-16 10:34:14 -04:00
parent 521ceda710
commit 3bdd202e81
34 changed files with 579 additions and 136 deletions
+160 -44
View File
@@ -74,21 +74,24 @@ namespace InventoryTraker.Web
{
var r = new Random(1);
var inventoryTypes = context.InventoryTypes.ToList();
var cityNames = new List<string> {"Maryville", "Wartburg", "Clinton", "Oak Ridge", "Alcoa", "Jellico"};
var colorNames = new List<string> {"Red", "Purple", "Blue", "Yellow", "White"};
var counties = new List<string> {"Blount County", "Morgan County", "Knox County", "Anderson County", "Claiborne County", "Campbell County"};
var colors = new List<string> {"Red", "Purple", "Blue", "Yellow", "White"};
for (int i = 0; i < 200; i++)
for (var dd = DateTime.Today.AddYears(-4); dd < DateTime.Today.AddMonths(-2); dd = dd.AddMonths(3))
{
// add some inventory
for (int i = 0; i < r.Next(5,10); i++)
{
var inventoryType = inventoryTypes.ElementAt(r.Next(0, context.InventoryTypes.Count()));
var addedDate = DateTime.Today.AddMonths(-r.Next(1, 24));
var addedDate = dd.AddDays(r.Next(-10, 10));
var expiration = addedDate.AddMonths(r.Next(2, 48));
var memo =
r.Next(0,3) > 0
? colorNames.ElementAt(r.Next(0, colorNames.Count)) + $" {inventoryType.ContainerType}"
r.Next(0, 3) > 0
? colors.ElementAt(r.Next(0, colors.Count)) + $" {inventoryType.ContainerType}"
: string.Empty;
var quantity = r.Next(5, 112);
var previousTransaction = new Transaction
var addedTransaction = new Transaction
{
TransactionType = TransactionType.Added,
AddedQuantity = quantity,
@@ -104,67 +107,180 @@ namespace InventoryTraker.Web
AddedDate = addedDate,
Memo = memo,
Quantity = quantity,
Transactions = new List<Transaction> { previousTransaction}
Transactions = new List<Transaction> {addedTransaction}
};
context.Inventories.Add(inventory);
}
dd = dd.AddDays(14);
// expire/loss some inventory
var availableInventories =
context.Inventories.Local.Where(i => i.Quantity > 0).ToList();
for (int j = 0; j < 5 && previousTransaction.CurrentQuantity > 0; j++)
foreach (var inventory in availableInventories)
{
var transactionDate = previousTransaction.TransactionDate.AddDays(r.Next(1, 100));
if (transactionDate >= DateTime.Today)
break;
Transaction transaction;
if (transactionDate >= expiration)
if (inventory.ExpirationDate <= dd && r.Next(0, 3) > 0)
{
if (r.Next(1, 3) == 1)
break;
transaction = new Transaction
var expiredTransaction = new Transaction
{
TransactionType = TransactionType.Expired,
RemovedQuantity = previousTransaction.CurrentQuantity,
RemovedQuantity = inventory.Quantity,
CurrentQuantity = 0,
Inventory = inventory,
Memo = $"Expired on {expiration.ToShortDateString()}",
TransactionDate = transactionDate,
Timestamp = transactionDate
Memo = $"Expired on {inventory.ExpirationDate.ToShortDateString()}",
TransactionDate = dd,
Timestamp = dd
};
inventory.Quantity = expiredTransaction.CurrentQuantity;
inventory.Transactions.Add(expiredTransaction);
}
else
else if (r.Next(0, 20) == 0)
{
var quantityRemoved = r.Next(1, 100);
if (quantityRemoved > previousTransaction.CurrentQuantity)
quantityRemoved = previousTransaction.CurrentQuantity;
var lossQty = r.Next(1, inventory.Quantity + 1);
var lossTransaction = new Transaction
{
TransactionType = TransactionType.Loss,
RemovedQuantity = lossQty,
CurrentQuantity = inventory.Quantity - lossQty,
Inventory = inventory,
Memo = $"Missing",
TransactionDate = dd,
Timestamp = dd
};
inventory.Quantity = lossTransaction.CurrentQuantity;
inventory.Transactions.Add(lossTransaction);
}
}
var transMemo = $"Distributed to {cityNames.ElementAt(r.Next(0, cityNames.Count))}";
dd = dd.AddDays(14);
// distribute some inventory
foreach (var destination in counties)
{
availableInventories =
context.Inventories.Local.Where(i => i.Quantity > 0).ToList();
for (
var i = r.Next(0, availableInventories.Count);
i < availableInventories.Count;
i += r.Next(1, availableInventories.Count / 2))
{
var inventory = availableInventories.ElementAt(i);
if (inventory.ExpirationDate <= dd)
continue;
var quantityRemoved = r.Next(1, inventory.Quantity + 1);
var transMemo = $"Distributed to {destination}";
var transType = TransactionType.Distributed;
if (r.Next(1, 15) == 1)
{
transMemo = "Loss";
transType = TransactionType.Loss;
}
transaction = new Transaction
var distributeTransaction = new Transaction
{
TransactionType = transType,
RemovedQuantity = quantityRemoved,
CurrentQuantity = previousTransaction.CurrentQuantity - quantityRemoved,
CurrentQuantity = inventory.Quantity - quantityRemoved,
Inventory = inventory,
Memo = transMemo,
TransactionDate = transactionDate,
Timestamp = transactionDate
TransactionDate = dd,
Timestamp = dd,
Destination = destination
};
}
inventory.Quantity = distributeTransaction.CurrentQuantity;
inventory.Quantity = transaction.CurrentQuantity;
inventory.Transactions.Add(transaction);
previousTransaction = transaction;
inventory.Transactions.Add(distributeTransaction);
}
}
}
//for (int i = 0; i < 200; i++)
//{
// var inventoryType = inventoryTypes.ElementAt(r.Next(0, context.InventoryTypes.Count()));
// var addedDate = DateTime.Today.AddMonths(-r.Next(1, 24));
// var expiration = addedDate.AddMonths(r.Next(2, 48));
// var memo =
// r.Next(0,3) > 0
// ? colors.ElementAt(r.Next(0, colors.Count)) + $" {inventoryType.ContainerType}"
// : string.Empty;
// var quantity = r.Next(5, 112);
// var previousTransaction = new Transaction
// {
// TransactionType = TransactionType.Added,
// AddedQuantity = quantity,
// Memo = "Arrival",
// CurrentQuantity = quantity,
// TransactionDate = addedDate,
// Timestamp = addedDate
// };
// var inventory = new Inventory
// {
// InventoryType = inventoryType,
// ExpirationDate = expiration,
// AddedDate = addedDate,
// Memo = memo,
// Quantity = quantity,
// Transactions = new List<Transaction> { previousTransaction}
// };
// context.Inventories.Add(inventory);
// for (int j = 0; j < 5 && previousTransaction.CurrentQuantity > 0; j++)
// {
// var transactionDate = previousTransaction.TransactionDate.AddDays(r.Next(1, 100));
// if (transactionDate >= DateTime.Today)
// break;
// Transaction transaction;
// if (transactionDate >= expiration)
// {
// if (r.Next(1, 3) == 1)
// break;
//transaction = new Transaction
//{
// TransactionType = TransactionType.Expired,
// RemovedQuantity = previousTransaction.CurrentQuantity,
// CurrentQuantity = 0,
// Inventory = inventory,
// Memo = $"Expired on {expiration.ToShortDateString()}",
// TransactionDate = transactionDate,
// Timestamp = transactionDate
//};
// }
// else
// {
// var quantityRemoved = r.Next(1, 100);
// if (quantityRemoved > previousTransaction.CurrentQuantity)
// quantityRemoved = previousTransaction.CurrentQuantity;
// var destination = counties.ElementAt(r.Next(0, counties.Count));
// var transMemo = $"Distributed to {destination}";
// var transType = TransactionType.Distributed;
// if (r.Next(1, 15) == 1)
// {
// transMemo = "Loss";
// transType = TransactionType.Loss;
// }
// transaction = new Transaction
// {
// TransactionType = transType,
// RemovedQuantity = quantityRemoved,
// CurrentQuantity = previousTransaction.CurrentQuantity - quantityRemoved,
// Inventory = inventory,
// Memo = transMemo,
// TransactionDate = transactionDate,
// Timestamp = transactionDate,
// Destination = destination
// };
// }
// inventory.Quantity = transaction.CurrentQuantity;
// inventory.Transactions.Add(transaction);
// previousTransaction = transaction;
// }
//}
}
}
}
@@ -119,11 +119,8 @@ namespace InventoryTraker.Web.Controllers
TransactionType = TransactionType.Distributed,
RemovedQuantity = quantityForm.Quantity,
CurrentQuantity = inventory.Quantity,
Memo =
string.IsNullOrEmpty(form.Memo)
? $"{form.Memo} | "
: ""
+ $"Distributed to {form.Destination}",
Destination = form.Destination,
Memo = form.Memo,
Timestamp = DateTime.Now,
TransactionDate = form.DistributedDate
});
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using InventoryTraker.Web.Core;
using InventoryTraker.Web.Data;
using InventoryTraker.Web.Models;
namespace InventoryTraker.Web.Controllers
{
public class ReportController : ControllerBase
{
private readonly AppDbContext _context;
public ReportController(AppDbContext context)
{
_context = context;
}
[HttpGet]
public ActionResult Distribution()
{
return View();
}
public ActionResult Distribution(DateTime startDate, DateTime endDate)
{
var query =
from t in _context.Transactions
where
t.TransactionType == TransactionType.Distributed
&& t.TransactionDate >= startDate
&& t.TransactionDate < endDate
group t by new { t.TransactionDate, t.Destination }
into g
select new
{
Date = g.Key.TransactionDate,
Destination = g.Key.Destination,
Transactions = g.ToList()
//(from transaction in g
//select Mapper.Map<TransactionViewModel>(transaction)).ToArray()
};
var report =
from item in query.ToArray()
select new DistributionReport
{
Date = item.Date,
Destination = item.Destination,
Transactions =
Mapper.Map<IList<Transaction>, IList<TransactionViewModel>>
(item.Transactions).ToArray()
};
return BetterJson(report.ToArray());
}
}
}
@@ -1,4 +1,5 @@
using System.Linq;
using System.Collections;
using System.Linq;
using System.Web.Mvc;
using AutoMapper.QueryableExtensions;
using InventoryTraker.Web.Attributes;
+5
View File
@@ -25,6 +25,11 @@ namespace InventoryTraker.Web.Core
public string Memo { get; set; }
/// <summary>
/// Used only when inventory was distributed
/// </summary>
public string Destination { get; set; }
[Required]
public DateTime Timestamp { get; set; }
}
@@ -246,9 +246,15 @@
<Content Include="js\inventory\InventoryEditDirective.js" />
<Content Include="js\inventory\InventoryDistributeDirective.js" />
<Content Include="js\profile\EditProfileController.js" />
<Content Include="js\report\DistributionReportDirective.js" />
<Content Include="js\report\DistributionReportQueryDirective.js" />
<Content Include="js\report\DistributionReportController.js" />
<Content Include="js\report\reportSvc.js" />
<Content Include="js\transaction\TransactionController.js" />
<Content Include="js\transaction\transactionSvc.js" />
<Content Include="js\utility\ArrayExtensions.js" />
<Content Include="js\utility\StatusMessage.js" />
<Content Include="js\utility\ErrorList.js" />
<Content Include="js\utility\FormGroupValidationDirective.js" />
<Content Include="js\utility\HideZeroFilter.js" />
<Content Include="js\utility\InputValidationIconsDirective.js" />
@@ -293,6 +299,10 @@
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="js\report\templates\distributionReportQuery.tmpl.cshtml" />
<Content Include="js\utility\templates\errorList.tmpl.cshtml" />
<Content Include="js\report\templates\distributionReport.tmpl.cshtml" />
<Content Include="js\utility\templates\statusMessage.tmpl.cshtml" />
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
@@ -319,6 +329,7 @@
<Compile Include="App_Start\Startup.cs" />
<Compile Include="App_Start\StructureMapConfig.cs" />
<Compile Include="Attributes\ActionLogAttribute.cs" />
<Compile Include="Controllers\ReportController.cs" />
<Compile Include="Controllers\TransactionController.cs" />
<Compile Include="Controllers\InventoryController.cs" />
<Compile Include="Controllers\AuthenticationController.cs" />
@@ -345,6 +356,8 @@
<Compile Include="Identity\ApplicationUserManager.cs" />
<Compile Include="Identity\AspNetIdentityRegistry.cs" />
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\DateRangeQuery.cs" />
<Compile Include="Models\DistributionReport.cs" />
<Compile Include="Models\InventoryDistributeForm.cs" />
<Compile Include="Models\InventoryAddForm.cs" />
<Compile Include="Models\InventoryQuantityForm.cs" />
@@ -381,6 +394,7 @@
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Transaction\Index.cshtml" />
<Content Include="Views\InventoryType\Index.cshtml" />
<Content Include="Views\Report\Distribution.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -0,0 +1,11 @@
using System;
namespace InventoryTraker.Web.Models
{
public class DateRangeQuery
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}
@@ -0,0 +1,13 @@
using System;
namespace InventoryTraker.Web.Models
{
public class DistributionReport
{
public TransactionViewModel[] Transactions;
public string Destination { get; set; }
public DateTime Date { get; set; }
}
}
@@ -17,6 +17,7 @@ namespace InventoryTraker.Web.Models
public string ContainerType { get; set; }
public DateTime ExpirationDate { get; set; }
public DateTime AddedDate { get; set; }
public double WeightPerCase { get; set; }
public string TransactionType { get; set; }
@@ -32,6 +33,8 @@ namespace InventoryTraker.Web.Models
public string Memo { get; set; }
public string Destination { get; set; }
public DateTime Timestamp { get; set; }
public void CreateMappings(IMapperConfiguration configuration)
@@ -49,6 +52,8 @@ namespace InventoryTraker.Web.Models
opt => opt.MapFrom(s => s.Inventory.InventoryType.UnitsPerCase))
.ForMember(d => d.ContainerType,
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType))
.ForMember(d => d.WeightPerCase,
opt => opt.MapFrom(s => s.Inventory.InventoryType.WeightPerCase))
.ForMember(d => d.TransactionType,
opt => opt.MapFrom(s => s.TransactionType.ToString()))
.ForMember(d => d.PreviousQuantity,
@@ -0,0 +1,24 @@
@using Microsoft.Web.Mvc.Html
@{
ViewBag.Title = "Inventory Distribution Report";
}
<div ng-controller="DistributionReportController as vm">
<h1 class="page-header">
<i class="fa fa-file-o"></i> @ViewBag.Title
</h1>
<div class="row hidden-print">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
<distribution-report-query></distribution-report-query>
</div>
</div>
</div>
</div>
<div class="row" ng-show="vm.distributionData.length">
<div class="col-md-12">
<distribution-report distribution-data="vm.distributionData"></distribution-report>
</div>
</div>
</div>
@@ -0,0 +1,24 @@
@using Microsoft.Web.Mvc.Html
@{
ViewBag.Title = "Monthly Inventory Report";
}
<div ng-controller="MonthlyInventoryReportController as vm">
<h1 class="page-header">
<i class="fa fa-file-o"></i> @ViewBag.Title
</h1>
<div class="row hidden-print">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
<monthly-report-query></monthly-report-query>
</div>
</div>
</div>
</div>
<div class="row" ng-show="vm.inventoryData.length">
<div class="col-md-12">
<monthly-report distribution-data="vm.distributionData"></monthly-report>
</div>
</div>
</div>
@@ -32,6 +32,17 @@
<li>
<a href="@(Html.BuildUrlFromExpression<TransactionController>(c => c.Index()))"><i class="fa fa-fw fa-list"></i> Transaction History</a>
</li>
<li>
<a href="#"><i class="fa fa-file-o"></i> Reports</a>
<ul>
<li>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Distribution()))"><i class="fa fa-file-o"></i> Distribution</a>
</li>
<li>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Distribution()))"><i class="fa fa-file-o"></i> Monthly Inventory</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
@@ -17,9 +17,11 @@
var vm = this;
vm.add = add;
vm.saving = false;
vm.inventory = { };
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
vm.saving = false;
vm.statusMessage = "Enter details for the inventory arrival below.";
vm.errorMessages = [];
vm.quantity = quantity;
@@ -43,6 +45,7 @@
});
function add() {
vm.statusMessage = null;
vm.saving = true;
inventorySvc.add(vm.inventory)
.success(function () {
@@ -16,9 +16,11 @@
var vm = this;
vm.save = save;
vm.saving = false;
vm.quantities = angular.copy(inventorySvc.inventories);
vm.distribution = {};
vm.saving = false;
vm.statusMessage = "Enter details for the inventory distribution below.";
vm.errorMessages = [];
function getInventoryDistributeQuantities(inventory) {
@@ -31,6 +33,7 @@
}
function save() {
vm.statusMessage = null;
vm.saving = true;
vm.distribution.inventoryQuantities = getInventoryDistributeQuantities(vm.quantities);
inventorySvc.distribute(vm.distribution)
@@ -25,9 +25,11 @@
transactionType: vm.inventory.isExpired ? "Expired" : null
};
vm.statusMessage = "Enter details for the inventory removal below.";
vm.errorMessages = [];
function save() {
vm.statusMessage = null;
vm.saving = true;
inventorySvc.remove(vm.removeForm)
.success(function (data) {
@@ -14,15 +14,8 @@
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessages.length">
Enter details for the inventory arrival below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessages.length">
There were problems adding the inventory.
<ul>
<li ng-repeat="error in vm.errorMessages">{{error}}</li>
</ul>
</div>
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<script type="text/ng-template" id="commodityTypeahead.html">
<a>
@@ -14,15 +14,8 @@
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessages.length">
Enter details for the inventory distribution below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessages.length">
There were problems distributing the inventory.
<ul>
<li ng-repeat="error in vm.errorMessages">{{error}}</li>
</ul>
</div>
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@distribution.FormGroupFor(m => m.Destination)
@@ -10,9 +10,7 @@
<div class="modal-body">
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
<error-list errors="vm.errorMessages"></error-list>
<inventory-info inventory="inventory"></inventory-info>
<div class="modal-footer">
@@ -14,15 +14,8 @@
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessages.length">
Enter details for the inventory removal below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessages.length">
There were problems removing the inventory.
<ul>
<li ng-repeat="error in vm.errorMessages">{{error}}</li>
</ul>
</div>
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<div class="panel panel-default">
<div class="panel-body">
@@ -12,24 +12,25 @@
}
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc) {
function controller($scope, inventoryTypeSvc){
var vm = this;
vm.add = add;
vm.saving = false;
vm.inventoryType = {};
vm.statusMessage = "Add a new commodity";
vm.errorMessages = [];
function add() {
vm.statusMessage = null;
vm.saving = true;
inventoryTypeSvc.add(vm.inventoryType)
.success(function () {
//Close the modal
$scope.$close();
})
.error(function(data) {
.error(function (data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
@@ -22,9 +22,12 @@
vm.saving = false;
vm.inventoryTypeSvc = inventoryTypeSvc;
vm.statusMessage = "Edit this commodity";
vm.errorMessages = [];
function save() {
vm.statusMessage = null;
vm.saving = true;
inventoryTypeSvc.update($scope.inventoryType, vm.inventoryType)
.success(function () {
@@ -1,8 +1,6 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryTypeViewModel
@{
var inventoryType = Html.Angular().ModelFor("vm.inventoryType");
}
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.add()">
@@ -13,16 +11,8 @@
</div>
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessages.length">
Enter details for the added commodity below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessages.length">
There were problems adding the commodity.
<ul>
<li ng-repeat="error in vm.errorMessages">{{error}}</li>
</ul>
</div>
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@Html.Angular().FormForModel("vm.inventoryType")
@@ -11,15 +11,8 @@
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessages.length">
Edit details for the commodity below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessages.length">
There were problems saving the commodity.
<ul>
<li ng-repeat="error in vm.errorMessages">{{error}}</li>
</ul>
</div>
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@Html.Angular().FormForModel("vm.inventoryType")
@@ -0,0 +1,11 @@
(function () {
'use strict';
window.app.controller('DistributionReportController', DistributionReportController);
DistributionReportController.$inject = ['$scope', 'reportSvc'];
function DistributionReportController($scope, reportSvc) {
var vm = this;
vm.distributionData = reportSvc.distributionData;
}
})();
@@ -0,0 +1,19 @@
(function() {
'use strict';
window.app.directive('distributionReport', distributionReport);
function distributionReport() {
return {
scope: {distributionData: "="},
templateUrl: '/report/template/distributionReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.distributionData = $scope.distributionData;
}
})();
@@ -0,0 +1,33 @@
(function() {
'use strict';
window.app.directive('distributionReportQuery', distributionReportQuery);
function distributionReportQuery() {
return {
scope: true,
templateUrl: '/report/template/distributionReportQuery.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'reportSvc'];
function controller($scope, reportSvc) {
var vm = this;
vm.query = {};
vm.submitting = false;
vm.errorMessages = [];
vm.submit = submit;
function submit() {
vm.submitting = true;
reportSvc.loadDistributionReport(vm.query)
.error(function (data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function () {
vm.submitting = false;
});
}
}
})();
@@ -0,0 +1,23 @@
(function () {
window.app.factory('reportSvc', reportSvc);
reportSvc.$inject = ['$http'];
function reportSvc($http) {
var distributionData = [];
var svc = {
distributionData: distributionData,
loadDistributionReport: loadDistributionReport
};
//loadDistributionReport({ startDate: '2015-06-01', endDate: '2016-01-01' });
return svc;
function loadDistributionReport(query) {
return $http.post('/Report/Distribution', query)
.success(function (data) {
angular.copy(data, distributionData);
});
}
}
})();
@@ -0,0 +1,26 @@
<div ng-repeat="distribution in vm.distributionData">
<h3>{{distribution.destination}}</h3>
<h4>{{distribution.date | date:'shortDate'}}</h4>
<table class="table">
<thead>
<tr>
<th class="col-md-3">Name</th>
<th class="col-md-3">Units per Case</th>
<th class="col-md-2">Exp. Date</th>
<th class="col-md-1">Case Qty</th>
<th class="col-md-1">Unit Qty</th>
<th class="col-md-2">Weight</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="transaction in distribution.transactions | orderBy:'name'">
<td>{{transaction.name}}</td>
<td>{{transaction.unitsPerCase}} / {{transaction.containerType}}</td>
<td>{{transaction.expirationDate | date:'shortDate'}}</td>
<td>{{transaction.removedQuantity}}</td>
<td>{{transaction.removedQuantity * transaction.unitsPerCase}}</td>
<td>{{transaction.weightPerCase * transaction.unitsPerCase | number:0 }} lbs</td>
</tr>
</tbody>
</table>
</div>
@@ -0,0 +1,23 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.DateRangeQuery
@{
var query = Html.Angular().ModelFor("vm.query");
}
<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-6">
@query.FormGroupFor(m => m.StartDate)
</div>
<div class="col-md-6">
@query.FormGroupFor(m => m.EndDate)
</div>
</div>
<button class="btn btn-success pull-right">Submit</button>
</fieldset>
</form>
@@ -32,15 +32,17 @@
'\rExp Date: {{row.entity.expirationDate | date:\'shortDate\'}}' +
'\rAdd Date: {{row.entity.addedDate | date:\'shortDate\'}}">' +
'<a href="" ng-click="grid.appScope.editInventory(row.entity.inventoryId)"><i class="fa fa-edit"></i></a> ' +
'{{row.entity.name}}</div>'
'{{row.entity.name}}</div>',
width: "20%"
},
{ field: 'transactionType', name: 'Type', width: "10%" },
{ field: 'memo', cellTooltip: true },
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:'shortDate'", width: "15%" },
{ field: 'destination', cellTooltip: true, width: "10%" },
{ field: 'memo', cellTooltip: true, width: "15%" },
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:'shortDate'", width: "10%" },
{ field: 'previousQuantity', name: 'Prev Qty', width: "10%", enableSorting: false },
{ field: 'addedQuantity', name: 'Add Qty', width: "10%", enableSorting: false, cellFilter: "hideZero" },
{ field: 'removedQuantity', name: 'Remove Qty', width: "10%", enableSorting: false, cellFilter: "hideZero" },
{ field: 'currentQuantity', name: 'Current Qty', width: "15%", enableSorting: false }
{ field: 'currentQuantity', name: 'Current Qty', width: "10%", enableSorting: false }
],
onRegisterApi: function(gridApi) {
vm.gridApi = gridApi;
@@ -0,0 +1,23 @@
(function() {
'use strict';
window.app.directive('errorList', errorList);
function errorList() {
return {
scope: {
errors: "=",
editMsg: "="
},
templateUrl: '/utility/template/errorList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.errors = $scope.errors;
vm.editMsg = $scope.editMsg;
}
})();
@@ -0,0 +1,20 @@
(function() {
'use strict';
window.app.directive('statusMessage', statusMessage);
function statusMessage() {
return {
scope: {
message: "=",
severity: "=?"
},
templateUrl: '/utility/template/statusMessage.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope'];
function controller($scope) {
}
})();
@@ -0,0 +1,6 @@
<div class="alert alert-danger" ng-show="vm.errors.length">
Correct the following issues.
<ul>
<li ng-repeat="error in vm.errors">{{error}}</li>
</ul>
</div>
@@ -0,0 +1,3 @@
<div class="alert alert-{{angular.isDefined(severity) ? severity : 'info'}}" ng-show="message">
{{message}}
</div>