Expand demo seed: 178 inventory items + 30 vendors
Inventory (11 → 178): - 101 total powders: 6 core + 55 Prismatic + 20 Columbia + 13 Tiger Drylac + 9 Sherwin-Williams - 77 supplies: 21 masking, 16 chemicals, 16 abrasives, 15 hanging hardware, 9 PPE - ForceRemoveAll path now deletes all inventory for the company (not just the 11 enumerated SKUs), since transactions are pre-swept before this block Vendors (5 → 30): - Tiger Drylac, Sherwin-Williams Powders, Eastwood (powder suppliers) - Clemco, Triangle Abrasives, Airgas, Linde (blasting/gases) - Duke Energy, AT&T, Spectrum, Raleigh Electric, Carolina Industrial Water (utilities) - Safety-Kleen, Raleigh Waste (environmental) - Work N Gear, HD Supply, Carolina Office, First Insurance (services) - Triangle Commercial Properties LLC (landlord — shop lease with address + terms) - Fastenal, MSC, McMaster-Carr, Uline, Amazon Business, Lowe's Pro, NAPA (supply chain) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -389,18 +389,37 @@ public partial class SeedDataService
|
||||
// ── Inventory Items ───────────────────────────────────────────────────
|
||||
if (options.InventoryItems)
|
||||
{
|
||||
var seededSkus = SeededInventorySkuSuffixes.Select(s => $"{company.CompanyCode}{s}").ToArray();
|
||||
var inventoryItems = await _context.InventoryItems
|
||||
.IgnoreQueryFilters()
|
||||
.Where(i => i.CompanyId == companyId && seededSkus.Contains(i.SKU))
|
||||
.ToListAsync();
|
||||
List<InventoryItem> inventoryItems;
|
||||
|
||||
if (options.ForceRemoveAll)
|
||||
{
|
||||
// Full reset: wipe all inventory for this company.
|
||||
// InventoryTransactions were already cleared in the pre-sweep above.
|
||||
inventoryItems = await _context.InventoryItems
|
||||
.IgnoreQueryFilters()
|
||||
.Where(i => i.CompanyId == companyId)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Selective removal: only remove the 11 core seeded SKUs by fingerprint.
|
||||
var seededSkus = SeededInventorySkuSuffixes.Select(s => $"{company.CompanyCode}{s}").ToArray();
|
||||
inventoryItems = await _context.InventoryItems
|
||||
.IgnoreQueryFilters()
|
||||
.Where(i => i.CompanyId == companyId && seededSkus.Contains(i.SKU))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
if (inventoryItems.Any())
|
||||
{
|
||||
var inventoryIds = inventoryItems.Select(i => i.Id).ToList();
|
||||
var transactions = await _context.InventoryTransactions.IgnoreQueryFilters()
|
||||
.Where(t => inventoryIds.Contains(t.InventoryItemId)).ToListAsync();
|
||||
if (transactions.Any()) _context.InventoryTransactions.RemoveRange(transactions);
|
||||
if (!options.ForceRemoveAll)
|
||||
{
|
||||
// In selective mode transactions weren't pre-swept — remove them now.
|
||||
var inventoryIds = inventoryItems.Select(i => i.Id).ToList();
|
||||
var transactions = await _context.InventoryTransactions.IgnoreQueryFilters()
|
||||
.Where(t => inventoryIds.Contains(t.InventoryItemId)).ToListAsync();
|
||||
if (transactions.Any()) _context.InventoryTransactions.RemoveRange(transactions);
|
||||
}
|
||||
|
||||
_context.InventoryItems.RemoveRange(inventoryItems);
|
||||
totalRemoved += inventoryItems.Count;
|
||||
|
||||
Reference in New Issue
Block a user