Example #1
0
        public TicketItemProperty GetOrCreateCustomProperty()
        {
            var tip = GetCustomProperty();

            if (tip == null)
            {
                tip = new TicketItemProperty
                {
                    Name            = "",
                    PropertyPrice   = new Price(0, LocalSettings.CurrencySymbol),
                    PropertyGroupId = 0,
                    MenuItemId      = 0,
                    Quantity        = 0
                };
                Properties.Add(tip);
            }
            return(tip);
        }
 private static string GetTicketItemPropertyDisplayName(TicketItemProperty ticketItemProperty)
 {
     return ticketItemProperty.Quantity > 1
         ? ticketItemProperty.Quantity + " " + ticketItemProperty.Name
         : ticketItemProperty.Name;
 }
Example #3
0
        public TicketItemProperty ToggleProperty(MenuItemPropertyGroup group, MenuItemProperty property)
        {
            if (property.Name.ToLower() == "x")
            {
                var groupItems = Properties.Where(x => x.PropertyGroupId == group.Id).ToList();
                foreach (var tip in groupItems)
                {
                    Properties.Remove(tip);
                }
                if (group.MultipleSelection)
                {
                    Quantity = 1;
                }
                return(null);
            }

            var ti = FindProperty(property);

            if (ti == null)
            {
                ti = new TicketItemProperty
                {
                    Name          = property.Name,
                    PropertyPrice = new Price {
                        Amount = property.Price.Amount, CurrencyCode = property.Price.CurrencyCode
                    },
                    PropertyGroupId          = group.Id,
                    MenuItemId               = property.MenuItemId,
                    CalculateWithParentPrice = group.CalculateWithParentPrice,
                    PortionName              = PortionName,
                    Quantity = group.MultipleSelection ? 0 : 1
                };

                if (VatIncluded && VatRate > 0)
                {
                    ti.PropertyPrice.Amount = ti.PropertyPrice.Amount / ((100 + VatRate) / 100);
                    ti.PropertyPrice.Amount = decimal.Round(ti.PropertyPrice.Amount, 2);
                    ti.VatAmount            = property.Price.Amount - ti.PropertyPrice.Amount;
                }
                else if (VatRate > 0)
                {
                    ti.VatAmount = (property.Price.Amount * VatRate) / 100;
                }
                else
                {
                    ti.VatAmount = 0;
                }
            }
            if (group.SingleSelection || !string.IsNullOrEmpty(group.GroupTag))
            {
                var tip = Properties.FirstOrDefault(x => x.PropertyGroupId == group.Id);
                if (tip != null)
                {
                    Properties.Insert(Properties.IndexOf(tip), ti);
                    Properties.Remove(tip);
                }
            }
            else if (group.MultipleSelection)
            {
                ti.Quantity++;
            }
            else if (!group.MultipleSelection && Properties.Contains(ti))
            {
                Properties.Remove(ti);
                _lastSelectedProperty = ti;
                return(ti);
            }

            if (!Properties.Contains(ti))
            {
                Properties.Add(ti);
            }

            _lastSelectedProperty = ti;
            return(ti);
        }
Example #4
0
 public TicketItemProperty GetOrCreateCustomProperty()
 {
     var tip = GetCustomProperty();
     if (tip == null)
     {
         tip = new TicketItemProperty
                   {
                       Name = "",
                       PropertyPrice = new Price(0, LocalSettings.CurrencySymbol),
                       PropertyGroupId = 0,
                       MenuItemId = 0,
                       Quantity = 0
                   };
         Properties.Add(tip);
     }
     return tip;
 }
Example #5
0
        public TicketItemProperty ToggleProperty(MenuItemPropertyGroup group, MenuItemProperty property)
        {
            if (property.Name.ToLower() == "x")
            {
                var groupItems = Properties.Where(x => x.PropertyGroupId == group.Id).ToList();
                foreach (var tip in groupItems) Properties.Remove(tip);
                if (group.MultipleSelection) Quantity = 1;
                return null;
            }

            var ti = FindProperty(property);
            if (ti == null)
            {
                ti = new TicketItemProperty
                        {
                            Name = property.Name,
                            PropertyPrice = new Price { Amount = property.Price.Amount, CurrencyCode = property.Price.CurrencyCode },
                            PropertyGroupId = group.Id,
                            MenuItemId = property.MenuItemId,
                            CalculateWithParentPrice = group.CalculateWithParentPrice,
                            PortionName = PortionName,
                            Quantity = group.MultipleSelection ? 0 : 1
                        };

                if (VatIncluded && VatRate > 0)
                {
                    ti.PropertyPrice.Amount = ti.PropertyPrice.Amount / ((100 + VatRate) / 100);
                    ti.PropertyPrice.Amount = decimal.Round(ti.PropertyPrice.Amount, 2);
                    ti.VatAmount = property.Price.Amount - ti.PropertyPrice.Amount;
                }
                else if (VatRate > 0) ti.VatAmount = (property.Price.Amount * VatRate) / 100;
                else ti.VatAmount = 0;
            }
            if (group.SingleSelection || !string.IsNullOrEmpty(group.GroupTag))
            {
                var tip = Properties.FirstOrDefault(x => x.PropertyGroupId == group.Id);
                if (tip != null)
                {
                    Properties.Insert(Properties.IndexOf(tip), ti);
                    Properties.Remove(tip);
                }
            }
            else if (group.MultipleSelection)
            {
                ti.Quantity++;
            }
            else if (!group.MultipleSelection && Properties.Contains(ti))
            {
                Properties.Remove(ti);
                _lastSelectedProperty = ti;
                return ti;
            }

            if (!Properties.Contains(ti)) Properties.Add(ti);

            _lastSelectedProperty = ti;
            return ti;
        }
 public TicketItemPropertyViewModel(TicketItemProperty model)
 {
     Model = model;
 }