This commit is contained in:
2021-02-25 18:39:23 +00:00
parent d13fea35fe
commit a1946398b2
7 changed files with 38 additions and 24 deletions

View File

@@ -238,7 +238,7 @@ namespace AyaNova.Util
await SeedLoanLoanUnitAsync(log, 5);
await SeedCustomerServiceRequestAsync(log, 5);
await SeedPartWarehouseAsync(log, 5);
await SeedPartAsync(log, 20);
await SeedPartAsync(log, 20, 5);
await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 20);
@@ -292,7 +292,7 @@ namespace AyaNova.Util
await SeedLoanLoanUnitAsync(log, 10);
await SeedCustomerServiceRequestAsync(log, 10);
await SeedPartWarehouseAsync(log, 10);
await SeedPartAsync(log, 100);
await SeedPartAsync(log, 100, 10);
await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 30);
@@ -357,7 +357,7 @@ namespace AyaNova.Util
await SeedLoanLoanUnitAsync(log, 15);
await SeedCustomerServiceRequestAsync(log, 15);
await SeedPartWarehouseAsync(log, 15);
await SeedPartAsync(log, 200);
await SeedPartAsync(log, 200, 15);
await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 50);
@@ -422,7 +422,7 @@ namespace AyaNova.Util
await SeedLoanLoanUnitAsync(log, 20);
await SeedCustomerServiceRequestAsync(log, 20);
await SeedPartWarehouseAsync(log, 20);
await SeedPartAsync(log, 500);
await SeedPartAsync(log, 500, 20);
await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 200);
@@ -1574,7 +1574,7 @@ namespace AyaNova.Util
//////////////////////////////////////////////////////
//PART
//
public async Task SeedPartAsync(ILogger log, int count)
public async Task SeedPartAsync(ILogger log, int count, int maxQuantity)
{
for (int x = 0; x < count; x++)
{
@@ -1616,23 +1616,23 @@ namespace AyaNova.Util
throw new System.Exception(err);
}
int OpeningInventoryLevel = Fake.Random.Number(1, maxQuantity);
PartInventoryBiz PartInventoryBizNess = PartInventoryBiz.GetBiz(ct);
int OpeningInventoryLevel = 1;
// 50% chance it has serial numbers
if (Fake.Random.Number() == 1)
// 25% chance it has serial numbers
if (Fake.Random.Number(0, 4) == 1)
{
var serialCount = Fake.Random.Number(1, 5);
for (int y = 0; y < serialCount; y++)
var serialStart = Fake.Finance.Account(5).ToString();
for (int y = 0; y < OpeningInventoryLevel; y++)
{
await ct.PartSerial.AddAsync(new PartSerial() { PartId = NewObject.Id, Serial = Fake.Finance.Account().ToString() + y.ToString() });
await ct.PartSerial.AddAsync(new PartSerial() { PartId = NewObject.Id, Serial = serialStart + "-" + y.ToString() });
}
await ct.SaveChangesAsync();
//ensure add enough inventory to cover serials
OpeningInventoryLevel = serialCount;
}
OpeningInventoryLevel += Fake.Random.Number(1, 1000);
PartInventory partInventory = null;
//Add inventory into multiple warehouses for testing
@@ -1643,14 +1643,16 @@ namespace AyaNova.Util
//add opening inventory
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = OpeningInventoryLevel, Description = "New part opening inventory" });
//make two adjustments to have some testing data
if (partInventory != null)
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = -1, Description = "example adjustment" });
if (partInventory != null)
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = Fake.Random.Number(1, 100), Description = "example adjustment" });
//Example adjustments?
if (Fake.Random.Number(1, 10) == 1) // 10% adjusted
{
//make two adjustments to have some testing data
if (partInventory != null)
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = -1, Description = "example adjustment" });
if (partInventory != null)
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = Fake.Random.Number(1, 3), Description = "example adjustment" });
}
if (partInventory == null)
{
var err = $"Seeder::SeedPart - error creating {o.PartNumber} INVENTORY \r\n{PartInventoryBizNess.GetErrorsAsString()}";
@@ -1761,7 +1763,7 @@ namespace AyaNova.Util
partId = Fake.Random.Long(1, TotalSeededParts);
} while (partsAdded.Contains(partId));
partsAdded.Add(partId);
var qty = Fake.Random.Int(1, 100);
var qty = Fake.Random.Int(1, 5);
var cost = Fake.Random.Decimal(1, 25);
// 50% chance it has received serial numbers