From 41283987b90c827ba8d93befdbcb73bd377c4369 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 1 Aug 2026 10:48:56 -0400 Subject: [PATCH] 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. --- CutList.Web/Services/CutListPackingService.cs | 37 ++----------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/CutList.Web/Services/CutListPackingService.cs b/CutList.Web/Services/CutListPackingService.cs index cbb83b0..e1ce59b 100644 --- a/CutList.Web/Services/CutListPackingService.cs +++ b/CutList.Web/Services/CutListPackingService.cs @@ -46,10 +46,10 @@ public class CutListPackingService // Build stock bins var stockBins = new List(); - // 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) {