Add transaction type
This commit is contained in:
@@ -81,13 +81,18 @@ namespace InventoryTraker.Web
|
|||||||
{
|
{
|
||||||
var inventoryType = inventoryTypes.ElementAt(r.Next(0, context.InventoryTypes.Count()));
|
var inventoryType = inventoryTypes.ElementAt(r.Next(0, context.InventoryTypes.Count()));
|
||||||
var addedDate = DateTime.Today.AddMonths(-r.Next(1, 24));
|
var addedDate = DateTime.Today.AddMonths(-r.Next(1, 24));
|
||||||
var expiration = addedDate.AddMonths(r.Next(12, 48));
|
var expiration = addedDate.AddMonths(r.Next(2, 48));
|
||||||
var memo = "New " + inventoryType.Name;
|
var memo = "New " + inventoryType.Name;
|
||||||
var quantity = r.Next(5, 112);
|
var quantity = r.Next(5, 112);
|
||||||
|
|
||||||
var previousTransaction = new Transaction
|
var previousTransaction = new Transaction
|
||||||
{
|
{
|
||||||
AddedQuantity = quantity, Memo = "Arrival", CurrentQuantity = quantity, TransactionDate = addedDate, Timestamp = addedDate
|
TransactionType = TransactionType.Added,
|
||||||
|
AddedQuantity = quantity,
|
||||||
|
Memo = "Arrival",
|
||||||
|
CurrentQuantity = quantity,
|
||||||
|
TransactionDate = addedDate,
|
||||||
|
Timestamp = addedDate
|
||||||
};
|
};
|
||||||
var inventory = new Inventory
|
var inventory = new Inventory
|
||||||
{
|
{
|
||||||
@@ -106,21 +111,46 @@ namespace InventoryTraker.Web
|
|||||||
if (transactionDate >= DateTime.Today)
|
if (transactionDate >= DateTime.Today)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Transaction transaction;
|
||||||
|
if (transactionDate >= expiration)
|
||||||
|
{
|
||||||
|
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);
|
var quantityRemoved = r.Next(1, 100);
|
||||||
if (quantityRemoved > previousTransaction.CurrentQuantity)
|
if (quantityRemoved > previousTransaction.CurrentQuantity)
|
||||||
quantityRemoved = previousTransaction.CurrentQuantity;
|
quantityRemoved = previousTransaction.CurrentQuantity;
|
||||||
|
|
||||||
var destCity = cityNames.ElementAt(r.Next(0, cityNames.Count));
|
var transMemo = $"Distributed to {cityNames.ElementAt(r.Next(0, cityNames.Count))}";
|
||||||
|
var transType = TransactionType.Distributed;
|
||||||
|
|
||||||
var transaction = new Transaction
|
if (r.Next(1, 15) == 1)
|
||||||
{
|
{
|
||||||
|
transMemo = "Loss";
|
||||||
|
transType = TransactionType.Loss;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction = new Transaction
|
||||||
|
{
|
||||||
|
TransactionType = transType,
|
||||||
RemovedQuantity = quantityRemoved,
|
RemovedQuantity = quantityRemoved,
|
||||||
CurrentQuantity = previousTransaction.CurrentQuantity - quantityRemoved,
|
CurrentQuantity = previousTransaction.CurrentQuantity - quantityRemoved,
|
||||||
Inventory = inventory,
|
Inventory = inventory,
|
||||||
Memo = $"Distributed to {destCity}",
|
Memo = transMemo,
|
||||||
TransactionDate = transactionDate,
|
TransactionDate = transactionDate,
|
||||||
Timestamp = transactionDate
|
Timestamp = transactionDate
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
inventory.Quantity = transaction.CurrentQuantity;
|
inventory.Quantity = transaction.CurrentQuantity;
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
new Transaction
|
new Transaction
|
||||||
{
|
{
|
||||||
|
TransactionType = TransactionType.Added,
|
||||||
AddedQuantity = inventory.Quantity,
|
AddedQuantity = inventory.Quantity,
|
||||||
CurrentQuantity = inventory.Quantity,
|
CurrentQuantity = inventory.Quantity,
|
||||||
Memo = "Arrival",
|
Memo = "Arrival",
|
||||||
@@ -88,6 +89,7 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
|
|
||||||
inventory.Transactions.Add(new Transaction
|
inventory.Transactions.Add(new Transaction
|
||||||
{
|
{
|
||||||
|
TransactionType = TransactionType.Distributed,
|
||||||
RemovedQuantity = quantityForm.Quantity,
|
RemovedQuantity = quantityForm.Quantity,
|
||||||
CurrentQuantity = inventory.Quantity,
|
CurrentQuantity = inventory.Quantity,
|
||||||
Memo = "Distributed to " + form.Destination,
|
Memo = "Distributed to " + form.Destination,
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ namespace InventoryTraker.Web.Core
|
|||||||
|
|
||||||
public virtual Inventory Inventory { get; set; }
|
public virtual Inventory Inventory { get; set; }
|
||||||
|
|
||||||
|
public TransactionType TransactionType { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int AddedQuantity { get; set; }
|
public int AddedQuantity { get; set; }
|
||||||
|
|
||||||
@@ -26,4 +28,12 @@ namespace InventoryTraker.Web.Core
|
|||||||
[Required]
|
[Required]
|
||||||
public DateTime Timestamp { get; set; }
|
public DateTime Timestamp { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TransactionType
|
||||||
|
{
|
||||||
|
Added,
|
||||||
|
Distributed,
|
||||||
|
Expired,
|
||||||
|
Loss
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -240,6 +240,7 @@
|
|||||||
<Content Include="js\transaction\transactionSvc.js" />
|
<Content Include="js\transaction\transactionSvc.js" />
|
||||||
<Content Include="js\utility\ArrayExtensions.js" />
|
<Content Include="js\utility\ArrayExtensions.js" />
|
||||||
<Content Include="js\utility\FormGroupValidationDirective.js" />
|
<Content Include="js\utility\FormGroupValidationDirective.js" />
|
||||||
|
<Content Include="js\utility\HideZeroFilter.js" />
|
||||||
<Content Include="js\utility\InputValidationIconsDirective.js" />
|
<Content Include="js\utility\InputValidationIconsDirective.js" />
|
||||||
<Content Include="js\utility\MvcGridDirective.js" />
|
<Content Include="js\utility\MvcGridDirective.js" />
|
||||||
<Content Include="js\utility\ParseDateFilter.js" />
|
<Content Include="js\utility\ParseDateFilter.js" />
|
||||||
|
|||||||
@@ -17,21 +17,20 @@ namespace InventoryTraker.Web.Models
|
|||||||
public DateTime ExpirationDate { get; set; }
|
public DateTime ExpirationDate { get; set; }
|
||||||
public DateTime AddedDate { get; set; }
|
public DateTime AddedDate { get; set; }
|
||||||
|
|
||||||
[Required]
|
public string TransactionType { get; set; }
|
||||||
|
|
||||||
|
public int PreviousQuantity { get; set; }
|
||||||
|
|
||||||
public int AddedQuantity { get; set; }
|
public int AddedQuantity { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int RemovedQuantity { get; set; }
|
public int RemovedQuantity { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int CurrentQuantity { get; set; }
|
public int CurrentQuantity { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTime TransactionDate { get; set; }
|
public DateTime TransactionDate { get; set; }
|
||||||
|
|
||||||
public string Memo { get; set; }
|
public string Memo { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTime Timestamp { get; set; }
|
public DateTime Timestamp { get; set; }
|
||||||
|
|
||||||
public void CreateMappings(IMapperConfiguration configuration)
|
public void CreateMappings(IMapperConfiguration configuration)
|
||||||
@@ -46,7 +45,11 @@ namespace InventoryTraker.Web.Models
|
|||||||
.ForMember(d => d.UnitsPerCase,
|
.ForMember(d => d.UnitsPerCase,
|
||||||
opt => opt.MapFrom(s => s.Inventory.InventoryType.UnitsPerCase))
|
opt => opt.MapFrom(s => s.Inventory.InventoryType.UnitsPerCase))
|
||||||
.ForMember(d => d.ContainerType,
|
.ForMember(d => d.ContainerType,
|
||||||
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType));
|
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType))
|
||||||
|
.ForMember(d => d.TransactionType,
|
||||||
|
opt => opt.MapFrom(s => s.TransactionType.ToString()))
|
||||||
|
.ForMember(d => d.PreviousQuantity,
|
||||||
|
opt => opt.MapFrom(s => s.CurrentQuantity - s.AddedQuantity + s.RemovedQuantity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<table class="table" ng-class="vm.getValidationClass()">
|
<table class="table" ng-class="vm.getValidationClass()">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name<br />Units per Case</th>
|
<th>Name<br/>Units per Case<br/>Expiration Date</th>
|
||||||
<th>Available Case Qty</th>
|
<th>Available Case Qty</th>
|
||||||
<th>Distribute Case Qty</th>
|
<th>Distribute Case Qty</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -34,14 +34,13 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="inventory in vm.quantities" inventory="inventory">
|
<tr ng-repeat="inventory in vm.quantities" inventory="inventory">
|
||||||
<td>
|
<td>
|
||||||
<label class="control-label" for="DistributeQuantity{{inventory.name}}">
|
|
||||||
{{inventory.name}}<br />
|
{{inventory.name}}<br />
|
||||||
{{inventory.unitsPerCase}} / {{inventory.containerType}}
|
{{inventory.unitsPerCase}} / {{inventory.containerType}}<br/>
|
||||||
</label>
|
Exp: {{inventory.expirationDate | date:'shortDate'}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{inventory.quantity}}</td>
|
<td>{{inventory.quantity}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="form-group" form-group-validation="DistributeQuantity{{inventory.name}}">
|
<div class="form-group col-sm-7" form-group-validation="DistributeQuantity{{inventory.name}}">
|
||||||
<input name="DistributeQuantity{{inventory.name}}" type="number"
|
<input name="DistributeQuantity{{inventory.name}}" type="number"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
ng-model="inventory.distributeQuantity"
|
ng-model="inventory.distributeQuantity"
|
||||||
|
|||||||
@@ -28,15 +28,17 @@
|
|||||||
cellTemplate: '<div class="ui-grid-cell-contents" ' +
|
cellTemplate: '<div class="ui-grid-cell-contents" ' +
|
||||||
'title="{{row.entity.name}}' +
|
'title="{{row.entity.name}}' +
|
||||||
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
|
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
|
||||||
'\rExp Date: {{row.entity.expirationDate | date:shortDate}}' +
|
'\rExp Date: {{row.entity.expirationDate | date:\'shortDate\'}}' +
|
||||||
'\rAdd Date: {{row.entity.addedDate | date:shortDate}}">' +
|
'\rAdd Date: {{row.entity.addedDate | date:\'shortDate\'}}">' +
|
||||||
'<a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a> ' +
|
'<a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a> ' +
|
||||||
'{{row.entity.name}}</div>'
|
'{{row.entity.name}}</div>'
|
||||||
},
|
},
|
||||||
|
{ field: 'transactionType', name: 'Type', width: "10%" },
|
||||||
{ field: 'memo', cellTooltip: true },
|
{ field: 'memo', cellTooltip: true },
|
||||||
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
|
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:'shortDate'", width: "15%" },
|
||||||
{ field: 'addedQuantity', name: 'Add Qty', width: "10%", enableSorting: false },
|
{ field: 'previousQuantity', name: 'Prev Qty', width: "10%", enableSorting: false },
|
||||||
{ field: 'removedQuantity', name: 'Remove 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: "15%", enableSorting: false }
|
||||||
],
|
],
|
||||||
onRegisterApi: function(gridApi) {
|
onRegisterApi: function(gridApi) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
(function () {
|
||||||
|
window.app.filter('hideZero', hideZero);
|
||||||
|
|
||||||
|
function hideZero() {
|
||||||
|
return function (input) {
|
||||||
|
|
||||||
|
return input > 0 ? input : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user