public void UpdateNextInventory(DateTime day, double change) { RequirementsDay nextDay; if (day.AddDays(1) <= RequirementsHandler.GetLatestDay()) { nextDay = GetRequirementDay(day.AddDays(1)); nextDay.Inventory += change; } }
public void OutputString(StringBuilder outputString) { var product = StaticInventoryTracker.ProductMasterList.FirstOrDefault(x => x.MasterID == MasterItem.MasterID); string name = product?.ProductionCode; outputString.Append($"{name}"); for (int i = 0; i < RequirementsHandler.GetNumDays(); ++i) { outputString.Append($",{" "}"); // keep columns } outputString.AppendLine(); // end product line StringBuilder grossBuilder = new StringBuilder(); StringBuilder onHandBuilder = new StringBuilder(); StringBuilder netBuilder = new StringBuilder(); StringBuilder purchaseBuilder = new StringBuilder(); grossBuilder.Append($"{"Gross"},"); onHandBuilder.Append($"{"OnHand"},"); netBuilder.Append($"{"Net"},"); purchaseBuilder.Append($"{"POS"},"); DateTime current = RequirementsHandler.GetEarliestDay(); while (current <= RequirementsHandler.GetLatestDay()) { RequirementsDay day = null; if (RequiredPieces.ContainsKey(current)) { day = RequiredPieces[current]; } if (day != null) { grossBuilder.Append($"{day.GrossPieces},"); onHandBuilder.Append($"{day.Inventory},"); netBuilder.Append($"{day.NetRequiredPieces},"); purchaseBuilder.Append($"{day.PurchaseOrderPieces},"); } else { grossBuilder.Append($"{"0"},"); onHandBuilder.Append($"{"0"},"); netBuilder.Append($"{"0"},"); purchaseBuilder.Append($"{"0"},"); } current = current.AddDays(1); } outputString.AppendLine(grossBuilder.ToString()); outputString.AppendLine(onHandBuilder.ToString()); outputString.AppendLine(netBuilder.ToString()); outputString.AppendLine(purchaseBuilder.ToString()); }
public void UpdateInventory(DateTime startDay) { // Validate day var validDate = RequirementsHandler.ValidateDay(startDay); RequirementsDay reqDay = null; RequirementsDay prevDay = null; // add inventory numbers for each day reqDay = GetRequirementDay(validDate); validDate = validDate.AddDays(1); while (validDate <= RequirementsHandler.GetLatestDay()) { prevDay = reqDay; reqDay = GetRequirementDay(validDate); reqDay.Inventory = prevDay.NextInventoryPieces; validDate = validDate.AddDays(1); } }