public static void AdjustInventory(TicketItemOption ticketItemOption, double portionSize, bool increaseInventory) { ItemOption itemOption = ItemOption.Get(ticketItemOption.ItemOptionId); if (itemOption.UsesItem && (itemOption.ProductId != null) && (itemOption.ProductAmount != null)) { PosModelHelper.AdjustInventoryByItem( itemOption.ProductId.Value, itemOption.ProductAmount.Value * portionSize, increaseInventory); } else if (itemOption.UsesIngredient && (itemOption.ProductId != null) && (itemOption.ProductAmount != null) && (itemOption.ProductMeasurementUnit != null)) { PosModelHelper.AdjustInventoryByIngredient( itemOption.ProductId.Value, increaseInventory, itemOption.ProductAmount.Value * portionSize, itemOption.ProductMeasurementUnit.Value); } }
public static void AdjustInventory(TicketItem ticketItem, bool increase, int?difference = null) { int quantity = (difference != null ? difference.Value : (ticketItem.QuantityPending != null ? ticketItem.QuantityPending.Value : ticketItem.Quantity)); foreach (ItemIngredient itemIngredient in ItemIngredient.GetAll(ticketItem.ItemId)) { PosModelHelper.AdjustInventoryByIngredient(itemIngredient.IngredientId, increase, itemIngredient.Amount * quantity, itemIngredient.MeasurementUnit); } foreach (TicketItemOption ticketItemOption in TicketItemOption.GetAll(ticketItem.PrimaryKey)) { TicketItemOption.AdjustInventory(ticketItemOption, quantity, increase); } }