コード例 #1
0
ファイル: TicketService.cs プロジェクト: basio/SambaPOS-3
        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;
        }
コード例 #2
0
 public OrderViewModel AddOrder(int menuItemId, decimal quantity, string portionName, OrderTagTemplate template)
 {
     ClearSelectedOrders();
     var order = _ticketService.AddOrder(SelectedTicket, menuItemId, quantity, portionName, template);
     var result = order == null ? null : Add(order);
     order.PublishEvent(EventTopicNames.OrderAdded);
     return result;
 }
コード例 #3
0
 public OrderViewModel AddOrder(int menuItemId, decimal quantity, string portionName, OrderTagTemplate template)
 {
     ClearSelectedOrders();
     var order = _ticketService.AddOrder(SelectedTicket, menuItemId, quantity, portionName, template);
     return order == null ? null : Add(order);
 }
コード例 #4
0
        public OrderViewModel AddNewItem(int menuItemId, decimal quantity, string portionName, OrderTagTemplate template)
        {
            if (!SelectedTicket.Model.CanSubmit) return null;
            SelectedTicket.ClearSelectedItems();
            var menuItem = _cacheService.GetMenuItem(x => x.Id == menuItemId);
            if (menuItem.Portions.Count == 0) return null;

            var portion = menuItem.Portions[0];

            if (!string.IsNullOrEmpty(portionName) && menuItem.Portions.Count(x => x.Name == portionName) > 0)
            {
                portion = menuItem.Portions.First(x => x.Name == portionName);
            }

            var ti = SelectedTicket.Model.AddOrder(
                _applicationState.CurrentDepartment.TicketTemplate.SaleTransactionTemplate,
                _applicationState.CurrentLoggedInUser.Name, menuItem, portion.Name, SelectedDepartment.PriceTag);

            ti.Quantity = quantity > 9 ? decimal.Round(quantity / portion.Multiplier, LocalSettings.Decimals) : quantity;

            if (template != null) template.OrderTagTemplateValues.ToList().ForEach(x => ti.ToggleOrderTag(x.OrderTagGroup, x.OrderTag, 0));

            var orderViewModel = new OrderViewModel(ti, SelectedDepartment.TicketTemplate, _automationService);
            SelectedTicket.Orders.Add(orderViewModel);
            _ticketService.RecalculateTicket(SelectedTicket.Model);
            orderViewModel.PublishEvent(EventTopicNames.OrderAdded);
            _automationService.NotifyEvent(RuleEventNames.TicketLineAdded, new { Ticket = SelectedTicket.Model, orderViewModel.Model.MenuItemName });
            return orderViewModel;
        }