InventoryType from XML

Transaction updates
This commit is contained in:
2016-08-25 13:00:09 -04:00
parent 53ed1b3af9
commit a5fcb46e04
28 changed files with 471 additions and 70 deletions
+47 -35
View File
@@ -84,47 +84,59 @@ namespace InventoryTraker.Web
private static void AddInventory(AppDbContext context)
{
var pork = context.InventoryTypes.First(it => it.Identifier == "100139");
var beans = context.InventoryTypes.First(it => it.Identifier == "100363");
var pb = context.InventoryTypes.First(it => it.Identifier == "100395");
var r = new Random(1);
var inventoryTypes = context.InventoryTypes.ToList();
context.Inventories.Add(new Inventory
for (int i = 0; i < 100; i++)
{
InventoryType = pork,
ExpirationDate = DateTime.Now.AddYears(1).AtMidnight(),
AddedDate = DateTime.Now.AddDays(-1).AtMidnight(),
Memo = "Hormel",
Quantity = 10,
Transactions = new List<Transaction> { new Transaction
{
AddedQuantity = 10, Memo = "arrival", TransactionDate = DateTime.Now.AddDays(-1).AtMidnight(), Timestamp = DateTime.Now
}}
});
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(12, 48));
var memo = "New " + inventoryType.Name;
var quantity = r.Next(5, 112);
context.Inventories.Add(new Inventory
{
InventoryType = beans,
ExpirationDate = DateTime.Now.AddMonths(4).AtMidnight(),
AddedDate = DateTime.Now.AddMonths(-2).AtMidnight(),
Memo = "Cut",
Quantity = 15,
Transactions = new List<Transaction> { new Transaction
var previousTransaction = new Transaction
{
AddedQuantity = 15, Memo = "arrival", TransactionDate = DateTime.Now.AddMonths(-2).AtMidnight(), Timestamp = DateTime.Now
}}
});
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);
context.Inventories.Add(new Inventory
{
InventoryType = pb,
ExpirationDate = DateTime.Now.AddDays(300).AtMidnight(),
AddedDate = DateTime.Now.AddDays(-34).AtMidnight(),
Quantity = 700,
Transactions = new List<Transaction> { new Transaction
for (int j = 0; j < 5 && previousTransaction.CurrentQuantity > 0; j++)
{
AddedQuantity = 700, Memo = "arrival", TransactionDate = DateTime.Now.AddDays(-34).AtMidnight(), Timestamp = DateTime.Now
}}
});
var transactionDate = previousTransaction.TransactionDate.AddDays(r.Next(1, 100));
if (transactionDate >= DateTime.Today)
break;
var quantityRemoved = r.Next(1, 100);
if (quantityRemoved > previousTransaction.CurrentQuantity)
quantityRemoved = previousTransaction.CurrentQuantity;
var transaction = new Transaction
{
RemovedQuantity = quantityRemoved,
CurrentQuantity = previousTransaction.CurrentQuantity - quantityRemoved,
Inventory = inventory,
Memo = "Distributed",
TransactionDate = transactionDate,
Timestamp = transactionDate
};
inventory.Quantity = transaction.CurrentQuantity;
inventory.Transactions.Add(transaction);
previousTransaction = transaction;
}
}
}
private static void AddTerminatedCustomers(AppDbContext context)