This commit is contained in:
@@ -1538,6 +1538,7 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
PartInventoryBiz PartInventoryBizNess = PartInventoryBiz.GetBiz(ct);
|
||||
int OpeningInventoryLevel = 1;
|
||||
// 50% chance it has serial numbers
|
||||
if (Fake.Random.Number() == 1)
|
||||
{
|
||||
@@ -1548,14 +1549,31 @@ namespace AyaNova.Util
|
||||
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
//add inventory to cover serials
|
||||
await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = serialCount });
|
||||
//ensure add enough inventory to cover serials
|
||||
OpeningInventoryLevel = serialCount;
|
||||
}
|
||||
else
|
||||
|
||||
OpeningInventoryLevel += Fake.Random.Number(1, 1000);
|
||||
PartInventory partInventory = null;
|
||||
|
||||
//add opening inventory
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, 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 = 1, Quantity = -1, Description = "example adjustment" });
|
||||
|
||||
if (partInventory != null)
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = Fake.Random.Number(1, 100), Description = "example adjustment" });
|
||||
|
||||
|
||||
if (partInventory == null)
|
||||
{
|
||||
//add random inventory level
|
||||
await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = Fake.Random.Number(1, 100) });
|
||||
var err = $"Seeder::SeedPart - error creating {o.PartNumber} INVENTORY \r\n{PartInventoryBizNess.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user