public Order AddOrder(Ticket ticket, int menuItemId, decimal quantity, string portionName, OrderTagTemplate template) { if (ticket.IsLocked && !_userService.IsUserPermittedFor(PermissionNames.AddItemsToLockedTickets)) return null; if (!ticket.CanSubmit) return null; var menuItem = _cacheService.GetMenuItem(x => x.Id == menuItemId); var portion = _cacheService.GetMenuItemPortion(menuItemId, portionName); if (portion == null) return null; var priceTag = _applicationState.CurrentDepartment.PriceTag; var productTimer = _applicationState.GetProductTimer(menuItemId); var order = ticket.AddOrder( _applicationState.CurrentTicketType.SaleTransactionType, _applicationState.CurrentDepartment.Model, _applicationState.CurrentLoggedInUser.Name, menuItem, _applicationState.GetTaxTemplates(menuItem.Id).ToList(), portion, priceTag, productTimer); order.Quantity = quantity > 9 ? decimal.Round(quantity / portion.Multiplier, 3, MidpointRounding.AwayFromZero) : quantity; if (template != null) template.OrderTagTemplateValues.ToList().ForEach(x => order.ToggleOrderTag(x.OrderTagGroup, x.OrderTag, 0, "")); RecalculateTicket(ticket); order.PublishEvent(EventTopicNames.OrderAdded); _automationService.NotifyEvent(RuleEventNames.OrderAdded, new { Ticket = ticket, Order = order, order.MenuItemName }); return order; }
public Order AddOrder(Ticket ticket, int menuItemId, decimal quantity, string portionName, string orderState) { if (ticket.IsLocked && !_userService.IsUserPermittedFor(PermissionNames.AddItemsToLockedTickets)) return null; if (!ticket.CanSubmit) return null; var menuItem = _cacheService.GetMenuItem(x => x.Id == menuItemId); var portion = _cacheService.GetMenuItemPortion(menuItemId, portionName); if (portion == null) return null; var priceTag = _applicationState.CurrentDepartment.PriceTag; var productTimer = _applicationState.GetProductTimer(menuItemId); var order = ticket.AddOrder( _applicationState.CurrentTicketType.SaleTransactionType, _applicationState.CurrentDepartment.Model, _applicationState.CurrentLoggedInUser.Name, menuItem, _applicationState.GetTaxTemplates(menuItem.Id).ToList(), portion, priceTag, productTimer); order.Quantity = quantity > 9 ? decimal.Round(quantity / portion.Multiplier, 3, MidpointRounding.AwayFromZero) : quantity; order.ResetSelectedQuantity(); SetOrderState(order, orderState); RecalculateTicket(ticket); _applicationState.NotifyEvent(RuleEventNames.OrderAdded, new { Ticket = ticket, Order = order, MenuItemName = order.MenuItemName, MenuItemTag = menuItem.Tag, MenuItemGroupCode = menuItem.GroupCode }); return order; }
private void AddOrderToTicket(Ticket ticket, IList<TaxTemplate> tax, decimal price, decimal quantity) { var order = ticket.AddOrder(TicketType.SaleTransactionType, Department.Default, "Emre", Product, tax, Product.Portions[0], "", null); order.Price = price; order.Quantity = quantity; }