diff --git a/src/PowderCoating.Application/Interfaces/ISeedDataService.cs b/src/PowderCoating.Application/Interfaces/ISeedDataService.cs
index 70ddfdd..d108a62 100644
--- a/src/PowderCoating.Application/Interfaces/ISeedDataService.cs
+++ b/src/PowderCoating.Application/Interfaces/ISeedDataService.cs
@@ -45,6 +45,8 @@ public class RemoveSeedDataOptions
public bool Catalog { get; set; }
public bool PricingTiers { get; set; }
public bool OperatingCosts { get; set; }
+ public bool Bills { get; set; }
+ public bool Expenses { get; set; }
}
public class SeedDataResult
diff --git a/src/PowderCoating.Infrastructure/Services/SeedDataService.Remove.cs b/src/PowderCoating.Infrastructure/Services/SeedDataService.Remove.cs
index 9f8dc5d..35b7c3e 100644
--- a/src/PowderCoating.Infrastructure/Services/SeedDataService.Remove.cs
+++ b/src/PowderCoating.Infrastructure/Services/SeedDataService.Remove.cs
@@ -333,6 +333,65 @@ public partial class SeedDataService
}
}
+ // --- Vendor Bills (all bills for the company) ---
+ if (options.Bills)
+ {
+ var billIds = await _context.Set()
+ .IgnoreQueryFilters()
+ .Where(b => b.CompanyId == companyId)
+ .Select(b => b.Id)
+ .ToListAsync();
+
+ if (billIds.Any())
+ {
+ var payments = await _context.Set()
+ .IgnoreQueryFilters()
+ .Where(p => billIds.Contains(p.BillId))
+ .ToListAsync();
+ if (payments.Any()) _context.Set().RemoveRange(payments);
+
+ var lineItems = await _context.Set()
+ .IgnoreQueryFilters()
+ .Where(li => billIds.Contains(li.BillId))
+ .ToListAsync();
+ if (lineItems.Any()) _context.Set().RemoveRange(lineItems);
+
+ var bills = await _context.Set()
+ .IgnoreQueryFilters()
+ .Where(b => billIds.Contains(b.Id))
+ .ToListAsync();
+ _context.Set().RemoveRange(bills);
+ totalRemoved += bills.Count;
+ details.Add($"✓ Removed {bills.Count} vendor bill(s)");
+ await _context.SaveChangesAsync();
+ }
+ else
+ {
+ details.Add("• No vendor bills found");
+ }
+ }
+
+ // --- Expenses ---
+ if (options.Expenses)
+ {
+ var expenses = await _context.Set()
+ .IgnoreQueryFilters()
+ .Where(e => e.CompanyId == companyId)
+ .ToListAsync();
+
+ if (expenses.Any())
+ {
+ _context.Set().RemoveRange(expenses);
+ totalRemoved += expenses.Count;
+ details.Add($"✓ Removed {expenses.Count} expense(s)");
+ await _context.SaveChangesAsync();
+ }
+ else
+ {
+ details.Add("• No expenses found");
+ }
+ }
+
result.ItemsSeeded = totalRemoved;
result.Details = details;
result.Message = totalRemoved > 0
diff --git a/src/PowderCoating.Web/Controllers/SeedDataController.cs b/src/PowderCoating.Web/Controllers/SeedDataController.cs
index 351f900..2f16eec 100644
--- a/src/PowderCoating.Web/Controllers/SeedDataController.cs
+++ b/src/PowderCoating.Web/Controllers/SeedDataController.cs
@@ -134,6 +134,8 @@ public class SeedDataController : Controller
Catalog = true,
PricingTiers = true,
OperatingCosts = true,
+ Bills = true,
+ Expenses = true,
};
var removeResult = await _seedDataService.RemoveSeedDataAsync(demo.Id, removeOptions);
@@ -148,7 +150,7 @@ public class SeedDataController : Controller
if (seedResult.Success)
{
- TempData["SuccessMessage"] = $"Demo company reset complete. {seedResult.ItemsSeeded} records re-seeded with today's dates.";
+ TempData["SuccessMessage"] = $"Demo company reset complete. {seedResult.ItemsSeeded} records re-seeded with today's dates.";
TempData["SeedDetails"] = string.Join("|", seedResult.Details);
TempData["ItemsSeeded"] = seedResult.ItemsSeeded;
@@ -157,7 +159,7 @@ public class SeedDataController : Controller
TempData["WarningMessage"] = $"{seedResult.ItemsSkipped} item(s) were skipped";
var displayWarnings = seedResult.Warnings.Take(30).ToList();
if (seedResult.Warnings.Count > 30)
- displayWarnings.Add($"… and {seedResult.Warnings.Count - 30} more (see logs)");
+ displayWarnings.Add($"... and {seedResult.Warnings.Count - 30} more (see logs)");
TempData["SeedWarnings"] = string.Join("|", displayWarnings);
}
}
diff --git a/src/PowderCoating.Web/Views/SeedData/Index.cshtml b/src/PowderCoating.Web/Views/SeedData/Index.cshtml
index d208e7b..b723ee2 100644
--- a/src/PowderCoating.Web/Views/SeedData/Index.cshtml
+++ b/src/PowderCoating.Web/Views/SeedData/Index.cshtml
@@ -117,7 +117,7 @@
so jobs, quotes, invoices, and AR aging always look current.
- - Removes: customers, jobs, quotes, invoices, inventory, equipment, catalog, pricing tiers, operating costs
+ - Removes: customers, jobs, quotes, invoices, inventory, equipment, catalog, pricing tiers, operating costs, vendor bills, expenses
- Re-seeds: 100 customers, 50 jobs across all statuses, quotes, invoices, inventory transactions, vendor bills, appointments — all dated from today
- Preserves: user accounts, company settings, lookup tables (job statuses, priorities, etc.)