refactor: remove packing auto-discovery fallback

The fallback silently pulled from StockItem.QuantityOnHand and always
added an extra unlimited bin on top when a job had no stock configured
- i.e. it assumed unlimited purchasing. Per
docs/superpowers/specs/2026-08-01-remove-inventory-quantity-tracking-design.md,
a job's available stock must now be exactly what's explicitly entered.
This commit is contained in:
aj
2026-08-01 10:48:56 -04:00
parent 41dda11062
commit 41283987b9
+3 -34
View File
@@ -46,10 +46,10 @@ public class CutListPackingService
// Build stock bins
var stockBins = new List<StockBinSource>();
// Check if job has specific stock configured for this material
if (jobStockByMaterial.TryGetValue(materialId, out var materialJobStock) && materialJobStock.Count > 0)
// Use job-specific stock configuration. Jobs must have stock explicitly configured -
// there is no fallback to "whatever's in inventory."
if (jobStockByMaterial.TryGetValue(materialId, out var materialJobStock))
{
// Use job-specific stock configuration
foreach (var stock in materialJobStock.OrderBy(s => s.Priority))
{
stockBins.Add(new StockBinSource
@@ -61,37 +61,6 @@ public class CutListPackingService
});
}
}
else
{
// No job-specific stock - use all available stock items for this material
var stockItems = await context.StockItems
.Where(s => s.MaterialId == materialId && s.IsActive)
.ToListAsync();
foreach (var stock in stockItems)
{
if (stock.QuantityOnHand > 0)
{
// In-stock with finite quantity
stockBins.Add(new StockBinSource
{
LengthInches = stock.LengthInches,
Quantity = stock.QuantityOnHand,
Priority = 1,
IsInStock = true
});
}
// Always add as purchasable (unlimited) - algorithm will use in-stock first due to priority
stockBins.Add(new StockBinSource
{
LengthInches = stock.LengthInches,
Quantity = -1, // unlimited
Priority = 2,
IsInStock = false
});
}
}
if (stockBins.Count == 0)
{