Ejemplo n.º 1
0
 public GroupedOrderTagViewModel(Order selectedItem, IGrouping<string, OrderTagGroup> orderTagGroups)
 {
     Name = orderTagGroups.Key;
     OrderTags = orderTagGroups.Select(x => new GroupedOrderTagButtonViewModel(selectedItem, x)).ToList();
     ColumnCount = orderTagGroups.First().ColumnCount;
     ButtonHeight = orderTagGroups.First().ButtonHeight;
 }
Ejemplo n.º 2
0
 public OrderViewModel(Order model)
 {
     _model = model;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand<OrderViewModel>(OnItemSelected);
     UpdateItemColor();
 }
Ejemplo n.º 3
0
 private static bool OrderStatesEqual(Order order1, Order order2)
 {
     var order1OrderStateValues = order1.GetOrderStateValues().ToList();
     var order2OrderStateValues = order2.GetOrderStateValues().ToList();
     if (!order1OrderStateValues.Any() && !order2OrderStateValues.Any()) return true;
     if (order1OrderStateValues.Count() != order2OrderStateValues.Count()) return false;
     return order1OrderStateValues.All(ps => order2OrderStateValues.Any(cs => cs.Equals(ps)));
 }
Ejemplo n.º 4
0
 public OrderViewModel(Order model, IAutomationService automationService)
 {
     _model = model;
     _automationService = automationService;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand<OrderViewModel>(OnItemSelected);
     UpdateItemColor();
 }
Ejemplo n.º 5
0
 public OrderViewModel(Order model, ICacheService cacheService, IApplicationState applicationState)
 {
     _model = model;
     _cacheService = cacheService;
     _applicationState = applicationState;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand<OrderViewModel>(OnItemSelected);
     UpdateItemColor();
 }
Ejemplo n.º 6
0
 public OrderViewModel(Order model, TicketTemplate ticketTemplate, IAutomationService ruleService)
 {
     _model = model;
     _ticketTemplate = ticketTemplate;
     _automationService = ruleService;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand<OrderViewModel>(OnItemSelected);
     UpdateItemColor();
 }
Ejemplo n.º 7
0
 private static decimal GetPrice(Order order, decimal serviceAmount, decimal sum, decimal exchangeRate, bool taxIncluded)
 {
     var result = order.GetPrice();
     var tax = taxIncluded ? 0 : order.GetTaxAmount(false, sum, serviceAmount);
     if (serviceAmount != 0 && sum != 0) result += (result * serviceAmount) / sum;
     result += tax;
     result = result / exchangeRate;
     return result;
 }
 public void Update(Order order)
 {
     StopTimer = false;
     SelectedOrder = order;
     RaisePropertyChanged(() => Start);
     RaisePropertyChanged(() => End);
     RaisePropertyChanged(() => Duration);
     RaisePropertyChanged(() => Price);
     RaisePropertyChanged(() => Value);
 }
Ejemplo n.º 9
0
 private void UpdateSelector(Order order, decimal serviceAmount, decimal sum, bool taxIncluded)
 {
     var selector = Selectors.FirstOrDefault(x => x.Key == GetKey(order));
     if (selector == null)
     {
         selector = new Selector { Key = GetKey(order), Description = order.MenuItemName + order.GetPortionDesc() };
         Selectors.Add(selector);
     }
     selector.Quantity += order.Quantity;
     selector.Price = GetPrice(order, serviceAmount, sum, ExchangeRate, taxIncluded);
 }
Ejemplo n.º 10
0
 public static decimal CalculateOrderTotal(Ticket ticket, Order order)
 {
     var discount = ticket.GetPreTaxServicesTotal();
     if (discount != 0)
     {
         var tsum = ticket.GetPlainSum();
         var rate = tsum > 0 ? (discount * 100) / tsum : 100;
         var tiTotal = order.GetTotal();
         var itemDiscount = (tiTotal * rate) / 100;
         return tiTotal + itemDiscount;
     }
     return order.GetTotal();
 }
Ejemplo n.º 11
0
 public static bool CanMergeOrders(Order order1, Order order2)
 {
     if (order1.Quantity != order2.Quantity) return false;
     if (order1.Price != order2.Price) return false;
     if (order1.MenuItemId != order2.MenuItemId) return false;
     if (order1.PortionName != order2.PortionName) return false;
     if (order1.CalculatePrice != order2.CalculatePrice) return false;
     if (order1.IncreaseInventory != order2.IncreaseInventory) return false;
     if (order1.DecreaseInventory != order2.DecreaseInventory) return false;
     if (order1.OrderTagValues.Count > 0 || order2.OrderTagValues.Count > 0) return false;
     if (!OrderStatesEqual(order1, order2)) return false;
     return true;
 }
Ejemplo n.º 12
0
 public decimal GetTaxExcludedSum(Order order)
 {
     var plainSum = order.GetTotal();
     var services = CalculateServices(Calculations.Where(x => !x.IncludeTax), plainSum);
     var tax = TaxIncluded ? order.GetTotalTaxAmount(TaxIncluded, plainSum, services) : 0;
     return plainSum - tax;
 }
Ejemplo n.º 13
0
 private void UpdateOrderTag(Ticket ticket, Order order, string orderTagGroup, string orderTag)
 {
     var ot = string.IsNullOrEmpty(orderTagGroup)
         ? _cacheService.GetOrderTagGroupByOrderTagName(orderTag)
         : _cacheService.GetOrderTagGroupByName(orderTagGroup);
     if (ot != null)
     {
         var otn = ot.OrderTags.First(x => x.Name == orderTag);
         _ticketService.TagOrders(ticket, new List<Order> { order }, ot, otn, "");
     }
 }
Ejemplo n.º 14
0
 private void UpdateOrderState(Ticket ticket, Order order, string stateName, string state)
 {
     _ticketService.UpdateOrderStates(ticket, new List<Order> { order }, stateName, null, 0, state, 0, "");
 }
Ejemplo n.º 15
0
 private OrderViewModel Add(Order ti)
 {
     var result = new OrderViewModel(ti);
     Orders.Add(result);
     return result;
 }
Ejemplo n.º 16
0
 public Order CloneOrder(Order item)
 {
     Debug.Assert(_orders.Contains(item));
     var result = ObjectCloner.Clone(item);
     result.CreatedDateTime = DateTime.Now;
     result.Quantity = 0;
     _orders.Add(result);
     return result;
 }
Ejemplo n.º 17
0
        public void AddOrder(Order order, IEnumerable<TaxTemplate> taxTemplates, AccountTransactionType template, string userName)
        {
            TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts());

            if (taxTemplates != null)
            {
                foreach (var taxTemplate in taxTemplates)
                {
                    TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id,
                                               taxTemplate.AccountTransactionType,
                                               GetTicketAccounts());
                }
            }

            Orders.Add(order);
            LastModifiedUserName = userName;
        }
Ejemplo n.º 18
0
 public decimal GetTaxExcludedSum(Order order)
 {
     var tax = TaxIncluded ? order.GetTotalTaxAmount(TaxIncluded, GetPlainSum(), GetPreTaxServicesTotal()) : 0;
     return order.GetTotal() - tax;
 }
Ejemplo n.º 19
0
 private void DisplayProdcutTimerEdior(Order selectedOrder)
 {
     _productTimerEditorViewModel.Update(selectedOrder);
     _regionManager.Regions[RegionNames.PosSubRegion].Activate(_productTimerEditorView);
 }
Ejemplo n.º 20
0
 public void CanDivideOrderPrice()
 {
     var order = new Order { Price = 10, Quantity = 1 };
     ExpressionService.Eval("Order.Price = Order.Price / 2", (new { Order = order }).ToDynamic(), 0);
     Assert.AreEqual(5, order.Price);
 }
Ejemplo n.º 21
0
 public void CancelOrder(Order item)
 {
     Locked = false;
     if (item.Id == 0) RemoveOrder(item);
 }
Ejemplo n.º 22
0
        public Order AddOrder(AccountTransactionType template, string userName, MenuItem menuItem, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            Locked = false;
            var order = new Order();
            order.UpdateMenuItem(userName, menuItem, portion, priceTag, 1);
            order.AccountTransactionTypeId = template.Id;

            TransactionDocument.AddSingletonTransaction(template.Id, template, AccountTypeId, AccountId);

            if (menuItem.TaxTemplate != null)
            {
                TransactionDocument.AddSingletonTransaction(order.TaxTempleteAccountTransactionTypeId,
                                                               menuItem.TaxTemplate.AccountTransactionType,
                                                               AccountTypeId, AccountId);
            }

            order.UpdateProductTimer(timer);
            Orders.Add(order);
            return order;
        }
Ejemplo n.º 23
0
 public Order ExtractSelectedOrder(Order order)
 {
     if (order.SelectedQuantity > 0 && order.SelectedQuantity < order.Quantity)
     {
         return FixOrder(order);
     }
     return order;
 }
Ejemplo n.º 24
0
 public void RemoveOrder(Order order)
 {
     var transactionId = order.AccountTransactionTypeId;
     Orders.Remove(order);
     if (Orders.All(x => x.AccountTransactionTypeId != transactionId))
     {
         TransactionDocument.AccountTransactions.Where(x => x.AccountTransactionTypeId == transactionId)
                .ToList().ForEach(x => TransactionDocument.AccountTransactions.Remove(x));
     }
 }
Ejemplo n.º 25
0
 private Order FixOrder(Order order)
 {
     Debug.Assert(order.SelectedQuantity > 0);
     Debug.Assert(Orders.Contains(order));
     if (order.SelectedQuantity >= order.Quantity) return null;
     var result = CloneOrder(order);
     result.Id = 0;
     result.Quantity = order.SelectedQuantity;
     result.ResetSelectedQuantity();
     order.Quantity -= order.SelectedQuantity;
     order.ResetSelectedQuantity();
     return result;
 }
Ejemplo n.º 26
0
        private void ExecuteAutomationCommand(Ticket selectedTicket, Order order, string automationCommand, string automationCommandValue)
        {
            if (string.IsNullOrEmpty(automationCommand)) return;

            if (string.IsNullOrEmpty(automationCommandValue))
            {
                var ac = _cacheService.GetAutomationCommandByName(automationCommand);
                if (ac != null)
                {
                    if (!string.IsNullOrEmpty(ac.Values))
                    {
                        ac.PublishEvent(EventTopicNames.SelectAutomationCommandValue);
                        return;
                    }
                }
            }

            _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new
            {
                Ticket = selectedTicket,
                Order = order,
                AutomationCommandName = automationCommand,
                Value = automationCommandValue ?? ""
            });
        }
Ejemplo n.º 27
0
        public Order AddOrder(AccountTransactionTemplate template, string userName, MenuItem menuItem, MenuItemPortion portion, string priceTag)
        {
            Locked = false;
            var tif = new Order();
            tif.UpdateMenuItem(userName, menuItem, portion, priceTag, 1);
            tif.AccountTransactionTemplateId = template.Id;
            if (AccountTransactions.AccountTransactions.SingleOrDefault(x => x.AccountTransactionTemplateId == template.Id) == null)
            {
                var transaction = AccountTransaction.Create(template);
                transaction.UpdateAccounts(AccountTemplateId, AccountId);
                AccountTransactions.AccountTransactions.Add(transaction);
            }

            if (tif.AccountTransactionTaxTemplateId > 0
                && AccountTransactions.AccountTransactions
                    .SingleOrDefault(x => x.AccountTransactionTemplateId == tif.AccountTransactionTaxTemplateId) == null)
            {
                var transaction = AccountTransaction.Create(menuItem.TaxTemplate.AccountTransactionTemplate);
                transaction.UpdateAccounts(AccountTemplateId, AccountId);
                AccountTransactions.AccountTransactions.Add(transaction);
            }
            Orders.Add(tif);
            return tif;
        }
Ejemplo n.º 28
0
        private void UpdateOrderStates(Ticket ticket, Order order, string orderStates)
        {
            if (string.IsNullOrEmpty(orderStates)) return;

            orderStates.Split(',')
                           .Where(x => x.Contains('='))
                           .Select(x => x.Split(new[] { '=' }, 2))
                           .ToList()
                           .ForEach(x => UpdateOrderState(ticket, order, x[0], x[1]));
        }
Ejemplo n.º 29
0
 public void RemoveOrder(Order ti)
 {
     var transactionId = ti.AccountTransactionTemplateId;
     Orders.Remove(ti);
     if (!Orders.Any(x => x.AccountTransactionTemplateId == transactionId))
     {
         AccountTransactions.AccountTransactions.Where(x => x.AccountTransactionTemplateId == transactionId)
                .ToList().ForEach(x => AccountTransactions.AccountTransactions.Remove(x));
     }
 }
Ejemplo n.º 30
0
 private void UpdateOrderTags(Ticket ticket, Order order, string orderTags)
 {
     if (string.IsNullOrEmpty(orderTags)) return;
     foreach (var orderTag in orderTags.Split(','))
     {
         if (orderTag.Contains("="))
         {
             var parts = orderTag.Split('=');
             UpdateOrderTag(ticket, order, parts[0], parts[1]);
         }
         else
         {
             UpdateOrderTag(ticket, order, "", orderTag);
         }
     }
 }
Ejemplo n.º 31
0
        public decimal GetTaxExcludedSum(Order order)
        {
            var tax = TaxIncluded ? order.GetTotalTaxAmount(TaxIncluded, GetPlainSum(), GetPreTaxServicesTotal()) : 0;

            return(order.GetTotal() - tax);
        }