public RequirementBatch(List <PurchaseRequirement> requirements) { UnfulfilledOrder = new UnfulfilledOrder(); _purchaseOrders = new Dictionary <Supplier, IPurchaseOrder>(); _requirements = requirements.ToDictionary(x => x.Product.ToProduct(), y => y.Quantity); Cache = new StockCache(requirements); }
/// <summary> /// Removes requirements that can't be fulfilled because of no stock and adds entries to Unfulfilled. /// </summary> public void ProcessNoStock() { foreach (var req in Unallocated) { if (Cache.GetAvailableStock(req.Product).Sum(x => x.Quantity) == 0) { UnfulfilledOrder.Add(new OrderLineBase(req.Product, req.Quantity)); _requirements[req.Product] = 0; } } }