예제 #1
0
 public PriceViewModel(MenuItemPortion model, string itemName, IEnumerable<string> tags)
 {
     Model = model;
     ItemName = itemName;
     _additionalPrices = new List<MenuItemPriceViewModel>();
     tags.ToList().ForEach(x =>
                               {
                                   var pr = model.Prices.SingleOrDefault(y => y.PriceTag == x);
                                   if (pr != null) _additionalPrices.Add(new MenuItemPriceViewModel(pr));
                               });
 }
예제 #2
0
 public MenuItemPortion AddPortion(string portionName, decimal price, string currencyCode)
 {
     var mip = new MenuItemPortion
     {
         Name = portionName,
         Price = new Price(price, currencyCode),
         MenuItemId = Id
     };
     Portions.Add(mip);
     return mip;
 }
예제 #3
0
        public MenuItemPortion AddPortion(string portionName, decimal price, string currencyCode)
        {
            var mip = new MenuItemPortion
            {
                Name       = portionName,
                Price      = price,
                MenuItemId = Id
            };

            Portions.Add(mip);
            return(mip);
        }
예제 #4
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = OrderBuilder.Create()
                                    .WithDepartment(department)
                                    .ForMenuItem(menuItem)
                                    .WithUserName(userName)
                                    .WithTaxTemplates(taxTemplates)
                                    .WithPortion(portion)
                                    .WithPriceTag(priceTag)
                                    .WithAccountTransactionType(template)
                                    .WithProductTimer(timer)
                                    .Build();

            AddOrder(order, taxTemplates, template, userName);
            return order;
        }
예제 #5
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;
        }
예제 #6
0
 public PortionViewModel(MenuItemPortion model)
 {
     Model = model;
 }
예제 #7
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;
        }
예제 #8
0
 public void UpdateMenuItem(string userName, MenuItem menuItem, MenuItemPortion portion, string priceTag, int quantity)
 {
     MenuItemId = menuItem.Id;
     MenuItemName = menuItem.Name;
     Debug.Assert(portion != null);
     UpdatePortion(portion, priceTag, menuItem.TaxTemplate);
     Quantity = quantity;
     _selectedQuantity = quantity;
     PortionCount = menuItem.Portions.Count;
     CreatingUserName = userName;
     CreatedDateTime = DateTime.Now;
 }
예제 #9
0
        public void UpdatePortion(MenuItemPortion portion, string priceTag, TaxTemplate taxTemplate)
        {
            PortionName = portion.Name;

            if (taxTemplate != null)
            {
                TaxRate = taxTemplate.Rate;
                TaxIncluded = taxTemplate.TaxIncluded;
                TaxTemplateId = taxTemplate.Id;
                TaxTemplateName = taxTemplate.Name;
                TaxTempleteAccountTransactionTypeId = taxTemplate.AccountTransactionType.Id;
            }

            if (!string.IsNullOrEmpty(priceTag))
            {
                string tag = priceTag;
                var price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag);
                if (price != null && price.Price > 0)
                {
                    UpdatePrice(price.Price, price.PriceTag);
                }
                else priceTag = "";
            }

            if (string.IsNullOrEmpty(priceTag))
            {
                UpdatePrice(portion.Price, "");
            }

            foreach (var orderTagValue in OrderTagValues)
            {
                orderTagValue.PortionName = portion.Name;
            }
        }
예제 #10
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = new Order();
            order.UpdateMenuItem(userName, menuItem, taxTemplates, portion, priceTag, 1);
            order.AccountTransactionTypeId = template.Id;
            order.WarehouseId = department.WarehouseId;
            order.DepartmentId = department.Id;
            TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts());

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

            order.UpdateProductTimer(timer);
            Orders.Add(order);
            return order;
        }
예제 #11
0
        public void UpdatePortion(MenuItemPortion portion, string priceTag, IEnumerable<TaxTemplate> taxTemplates)
        {
            PortionName = portion.Name;

            UpdateTaxTemplates(taxTemplates);

            if (!string.IsNullOrEmpty(priceTag))
            {
                string tag = priceTag;
                var price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag);
                if (price != null && price.Price > 0)
                {
                    UpdatePrice(price.Price, price.PriceTag);
                }
                else priceTag = "";
            }

            if (string.IsNullOrEmpty(priceTag))
            {
                UpdatePrice(portion.Price, "");
            }

            if (OrderTagValues.Any(x => x.MenuItemId > 0 && x.PortionName != portion.Name))
            {
                foreach (var orderTagValue in OrderTagValues.Where(x => x.MenuItemId > 0))
                {
                    orderTagValue.PortionName = portion.Name;
                }
                OrderTags = JsonHelper.Serialize(OrderTagValues);
                _orderTagValues = null;
            }
        }
 private void OnPortionSelected(MenuItemPortion obj)
 {
     SelectedItem.UpdatePortion(obj, AppServices.MainDataContext.SelectedDepartment.PriceTag);
     SelectedTicket.RefreshVisuals();
     SelectedTicket.RecalculateTicket();
     if (SelectedItemPropertyGroups.Count == 0 && SelectedItemGroupedPropertyItems.Count == 0)
         SelectedTicket.ClearSelectedItems();
 }
예제 #13
0
 public void UpdatePortion(MenuItemPortion portion, string priceTag, TaxTemplate taxTemplate)
 {
     _model.UpdatePortion(portion, priceTag, taxTemplate);
     RaisePropertyChanged(() => Description);
     RaisePropertyChanged(() => TotalPrice);
 }
예제 #14
0
 public PriceData(MenuItemPortion portion, string name)
 {
     Portion = portion;
     Name = name;
 }
예제 #15
0
 private void OnPortionSelected(MenuItemPortion obj)
 {
     obj.PublishEvent(EventTopicNames.PortionSelected);
     if (OrderTagGroups.Count == 0)
         EventServiceFactory.EventService.PublishEvent(EventTopicNames.ActivatePosView);
 }
예제 #16
0
        public void UpdatePortion(MenuItemPortion portion, string priceTag, VatTemplate vatTemplate)
        {
            PortionName = portion.Name;

            if (vatTemplate != null)
            {
                VatRate = vatTemplate.Rate;
                VatIncluded = vatTemplate.VatIncluded;
                VatTemplateId = vatTemplate.Id;
            }

            if (!string.IsNullOrEmpty(priceTag))
            {
                string tag = priceTag;
                var price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag);
                if (price != null && price.Price > 0)
                {
                    UpdatePrice(price.Price, price.PriceTag);
                }
                else priceTag = "";
            }

            if (string.IsNullOrEmpty(priceTag))
            {
                UpdatePrice(portion.Price.Amount, "");
            }

            CurrencyCode = LocalSettings.CurrencySymbol;
            foreach (var ticketItemProperty in Properties)
            {
                ticketItemProperty.PortionName = portion.Name;
            }
        }
예제 #17
0
 public void UpdatePortion(MenuItemPortion portion, string priceTag)
 {
     _model.UpdatePortion(portion, priceTag, AppServices.MainDataContext.GetVatTemplate(portion.MenuItemId));
     RuleExecutor.NotifyEvent(RuleEventNames.PortionSelected,
            new
            {
                Ticket = AppServices.MainDataContext.SelectedTicket,
                TicketItem = Model,
                TicketTag = AppServices.MainDataContext.SelectedTicket.Tag,
                MenuItemName = _model.MenuItemName,
                PortionName = portion.Name,
                PortionPrice = _model.Price
            });
     RaisePropertyChanged("Description");
     RaisePropertyChanged("TotalPrice");
 }
예제 #18
0
        public IEnumerable<MenuItem> BatchCreateMenuItems(string[] values, IWorkspace workspace)
        {
            var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            IList<MenuItem> result = new List<MenuItem>();
            if (values.Length > 0)
            {
                var currentCategory = Resources.Common;

                foreach (var item in values)
                {
                    if (item.StartsWith("#"))
                    {
                        currentCategory = item.Trim('#', ' ');
                    }
                    else if (item.Contains("|"))
                    {
                        //Sundae|Small:1.99|Medium:2.99|Large:3.99
                        IList<string> parts = new List<string>(item.Split('|'));
                        var mi = MenuItem.Create();
                        mi.Name = parts[0];
                        for (int i = 1; i < parts.Count; i++)
                        {

                            var tokens = parts[i].Split(':');
                            if (tokens.Count() != 2)
                            {
                                var price = ConvertToDecimal(tokens[0], ds);
                                mi.Portions[i - 1].Price.Amount = price;
                            }
                            else
                            {

                                var price = ConvertToDecimal(tokens[1], ds);
                                if (mi.Portions.Count < i - 1)
                                {
                                    var mp = new MenuItemPortion();
                                    mp.Price = new Price(price,"");
                                    mp.Name = tokens[0];
                                    mi.Portions.Add(mp);
                                }

                            }

                        }
                        mi.GroupCode = currentCategory;
                        workspace.Add(mi);
                        foreach (var p in mi.Portions)
                        {
                            workspace.Add(p);
                        }

                        result.Add(mi);
                    }
                    else if (item.Contains(" "))
                    {
                        //Sundae 2.99
                        IList<string> parts = new List<string>(item.Split(' '));
                        var price = ConvertToDecimal(parts[parts.Count - 1], ds);
                        parts.RemoveAt(parts.Count - 1);

                        var itemName = string.Join(" ", parts.ToArray());
                        var mi = MenuItem.Create();
                        mi.Name = itemName;
                        mi.Portions[0].Price.Amount = price;
                        mi.GroupCode = currentCategory;
                        workspace.Add(mi);
                        workspace.Add(mi.Portions[0]);
                        result.Add(mi);
                    }
                }
            }
            return result;
        }