public static List <MakeOrder> GetMakeOrders(DateTime date) { foreach (var masterItem in StaticInventoryTracker.ProductMasterList) { Configuration config = null; foreach ( var conGroup in MachineHandler.Instance.MachineList.SelectMany(machine => machine.ConfigurationList) ) { config = conGroup.Configurations.FirstOrDefault(con => con.CanMake(masterItem)); } ProductRequirements.CreateProductRequirements(masterItem, config); if (config == null) { StaticFunctions.OutputDebugLine("***ProductRequirements failed to find configuration for " + masterItem); } } AddSalesUntilDate(date); //AddCurrentInventory(); CalculateAllRequirements(); // output the requirements OutputStringToFile(); var orders = new List <MakeOrder>(); DateTime current = _earliestDay; while (current <= _latestDay) { foreach (var productRequirements in _allRequirements)//.Where(req => req.MasterItem.MadeIn.ToUpper().Equals("COATING"))) { if (productRequirements.RequiredPieces.ContainsKey(current)) { var day = productRequirements.RequiredPieces[current]; if (day.PurchaseOrderPieces > 0) { orders.Insert(0, new MakeOrder(productRequirements.MasterItem.MasterID, day.PurchaseOrderPieces, current)); } } } current = current.AddDays(1); } return(orders); }
public static void UpdateGross(DateTime POdate, double change, ProductRequirements requirements) { DateTime grossDate = POdate.AddDays(-RequirementsHandler.LeadTimeDays); // get each item required to make this foreach (var configItem in requirements.Input) { var conversionRatio = requirements.OutPieces / configItem.Pieces; var prodRequirement = RequirementsHandler.GetRequirements(configItem.MasterID); if (prodRequirement == null) { Configuration childConfiguration = MachineHandler.Instance.AllConfigurations.FirstOrDefault(conf => conf.CanMake(configItem.MasterItem)); prodRequirement = ProductRequirements.CreateProductRequirements(configItem.MasterItem, childConfiguration); } if (prodRequirement != null) { var reqDay = prodRequirement.GetRequirementDay(grossDate); reqDay.GrossPieces += (change * conversionRatio); } } }