Exemple #1
0
 public void VoidItem(TicketItem item, int reasonId, int userId)
 {
     Locked = false;
     if (item.Locked && !item.Voided && !item.Gifted)
     {
         item.Voided           = true;
         item.ModifiedUserId   = userId;
         item.ModifiedDateTime = DateTime.Now;
         item.ReasonId         = reasonId;
         item.Locked           = false;
     }
     else if (item.Voided && !item.Locked)
     {
         item.ReasonId = 0;
         item.Voided   = false;
         item.Locked   = true;
     }
     else if (item.Gifted)
     {
         item.ReasonId = 0;
         item.Gifted   = false;
         if (!item.Locked)
         {
             RemoveTicketItem(item);
         }
     }
     else if (!item.Locked)
     {
         RemoveTicketItem(item);
     }
 }
Exemple #2
0
 public void RemoveTicketItem(TicketItem ti)
 {
     TicketItems.Remove(ti);
     if (ti.Id > 0)
     {
         _removedTicketItems.Add(ti);
     }
 }
 public TicketItemViewModel(TicketItem model)
 {
     _model = model;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand<TicketItemViewModel>(OnItemSelected);
     Properties = new ObservableCollection<TicketItemPropertyViewModel>(model.Properties.Select(x => new TicketItemPropertyViewModel(x)));
     UpdateItemColor();
 }
Exemple #4
0
 public void GiftItem(TicketItem item, int reasonId, int userId)
 {
     Locked                = false;
     item.Gifted           = true;
     item.ModifiedUserId   = userId;
     item.ModifiedDateTime = DateTime.Now;
     item.ReasonId         = reasonId;
 }
Exemple #5
0
        public TicketItem CloneItem(TicketItem item)
        {
            Debug.Assert(_ticketItems.Contains(item));
            var result = ObjectCloner.Clone(item);

            result.Quantity = 0;
            _ticketItems.Add(result);
            return(result);
        }
Exemple #6
0
        public TicketItem AddTicketItem(int userId, int departmentId, MenuItem menuItem, string portionName, string priceTag, string defaultProperties)
        {
            Locked = false;
            var tif = new TicketItem {
                DepartmentId = departmentId
            };

            tif.UpdateMenuItem(userId, menuItem, portionName, priceTag, 1, defaultProperties);
            TicketItems.Add(tif);
            return(tif);
        }
Exemple #7
0
 public static decimal CalculateTicketItemTotal(Ticket ticket, TicketItem ticketItem)
 {
     var discount = ticket.GetDiscountAndRoundingTotal();
     if (discount != 0)
     {
         var tsum = ticket.GetSumWithoutTax() + discount;
         var rate = tsum > 0 ? (discount * 100) / tsum : 100;
         var tiTotal = ticketItem.GetTotal();
         var itemDiscount = (tiTotal * rate) / 100;
         return tiTotal - itemDiscount;
     }
     return ticketItem.GetTotal();
 }
Exemple #8
0
 public void CancelItem(TicketItem item)
 {
     Locked = false;
     if (item.Voided && !item.Locked)
     {
         item.ReasonId = 0;
         item.Voided   = false;
         item.Locked   = true;
     }
     else if (item.Gifted && !item.Locked)
     {
         item.ReasonId = 0;
         item.Gifted   = false;
         item.Locked   = true;
     }
     else if (!item.Locked)
     {
         RemoveTicketItem(item);
     }
 }
Exemple #9
0
        private static PrinterMap GetPrinterMapForItem(IEnumerable<PrinterMap> printerMaps, Ticket ticket, TicketItem ticketItem)
        {
            var menuItemGroupCode = Dao.Single<MenuItem, string>(ticketItem.MenuItemId, x => x.GroupCode);

            var maps = printerMaps;

            maps = maps.Count(x => !string.IsNullOrEmpty(x.TicketTag) && !string.IsNullOrEmpty(ticket.GetTagValue(x.TicketTag))) > 0
                ? maps.Where(x => !string.IsNullOrEmpty(x.TicketTag) && !string.IsNullOrEmpty(ticket.GetTagValue(x.TicketTag)))
                : maps.Where(x => string.IsNullOrEmpty(x.TicketTag));

            maps = maps.Count(x => x.Department != null && x.Department.Id == ticketItem.DepartmentId) > 0
                       ? maps.Where(x => x.Department != null && x.Department.Id == ticketItem.DepartmentId)
                       : maps.Where(x => x.Department == null);

            maps = maps.Count(x => x.MenuItemGroupCode == menuItemGroupCode) > 0
                       ? maps.Where(x => x.MenuItemGroupCode == menuItemGroupCode)
                       : maps.Where(x => x.MenuItemGroupCode == null);

            maps = maps.Count(x => x.MenuItem != null && x.MenuItem.Id == ticketItem.MenuItemId) > 0
                       ? maps.Where(x => x.MenuItem != null && x.MenuItem.Id == ticketItem.MenuItemId)
                       : maps.Where(x => x.MenuItem == null);

            return maps.FirstOrDefault();
        }
Exemple #10
0
 public void VoidItem(TicketItem item, int reasonId, int userId)
 {
     Locked = false;
     if (item.Locked && !item.Voided && !item.Gifted)
     {
         item.Voided = true;
         item.ModifiedUserId = userId;
         item.ModifiedDateTime = DateTime.Now;
         item.ReasonId = reasonId;
         item.Locked = false;
     }
     else if (item.Voided && !item.Locked)
     {
         item.ReasonId = 0;
         item.Voided = false;
         item.Locked = true;
     }
     else if (item.Gifted)
     {
         item.ReasonId = 0;
         item.Gifted = false;
         if (!item.Locked)
             RemoveTicketItem(item);
     }
     else if (!item.Locked)
         RemoveTicketItem(item);
 }
Exemple #11
0
 public void GiftItem(TicketItem item, int reasonId, int userId)
 {
     Locked = false;
     item.Gifted = true;
     item.ModifiedUserId = userId;
     item.ModifiedDateTime = DateTime.Now;
     item.ReasonId = reasonId;
 }
Exemple #12
0
 public void RemoveTicketItem(TicketItem ti)
 {
     TicketItems.Remove(ti);
     if (ti.Id > 0) _removedTicketItems.Add(ti);
 }
Exemple #13
0
 public void CancelItem(TicketItem item)
 {
     Locked = false;
     if (item.Voided && !item.Locked)
     {
         item.ReasonId = 0;
         item.Voided = false;
         item.Locked = true;
     }
     else if (item.Gifted && !item.Locked)
     {
         item.ReasonId = 0;
         item.Gifted = false;
         item.Locked = true;
     }
     else if (!item.Locked)
         RemoveTicketItem(item);
 }
Exemple #14
0
 public TicketItem CloneItem(TicketItem item)
 {
     Debug.Assert(_ticketItems.Contains(item));
     var result = ObjectCloner.Clone(item);
     result.Quantity = 0;
     _ticketItems.Add(result);
     return result;
 }
Exemple #15
0
 public MenuItemPropertyGroup GetUnselectedItem(TicketItem ticketItem)
 {
     var mi = GetMenuItem(ticketItem.MenuItemId);
     return mi.PropertyGroups.FirstOrDefault(x => x.ForceValue && ticketItem.Properties.Count(y => y.PropertyGroupId == x.Id) == 0);
 }
Exemple #16
0
 public TicketItem AddTicketItem(int userId, int departmentId, MenuItem menuItem, string portionName, string priceTag, string defaultProperties)
 {
     Locked = false;
     var tif = new TicketItem { DepartmentId = departmentId };
     tif.UpdateMenuItem(userId, menuItem, portionName, priceTag, 1, defaultProperties);
     TicketItems.Add(tif);
     return tif;
 }
Exemple #17
0
 public void AddItemToSelectedTicket(TicketItem model)
 {
     _workspace.Add(model);
 }
Exemple #18
0
 private static string GetMenuItemGroup(TicketItem ticketItem)
 {
     return Dao.SingleWithCache<MenuItem>(x => x.Id == ticketItem.MenuItemId).GroupCode;
 }
Exemple #19
0
 private static string GetMenuItemTag(TicketItem ticketItem)
 {
     var result = Dao.SingleWithCache<MenuItem>(x => x.Id == ticketItem.MenuItemId).Tag;
     if (string.IsNullOrEmpty(result)) result = ticketItem.MenuItemName;
     return result;
 }
Exemple #20
0
        private static string FormatLines(PrinterTemplate template, TicketItem ticketItem)
        {
            if (ticketItem.Gifted)
            {
                if (!string.IsNullOrEmpty(template.GiftLineTemplate))
                {
                    return template.GiftLineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                        .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem));
                }
                return "";
            }

            if (ticketItem.Voided)
            {
                if (!string.IsNullOrEmpty(template.VoidedLineTemplate))
                {
                    return template.VoidedLineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                        .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem));
                }
                return "";
            }

            if (!string.IsNullOrEmpty(template.LineTemplate))
                return template.LineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                    .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem));
            return "";
        }
Exemple #21
0
        private static string ReplaceLineVars(string line, TicketItem ticketItem)
        {
            string result = line;

            if (ticketItem != null)
            {
                result = FormatData(result, Resources.TF_LineItemQuantity, () => ticketItem.Quantity.ToString("#,#0.##"));
                result = FormatData(result, Resources.TF_LineItemName, () => ticketItem.MenuItemName + ticketItem.GetPortionDesc());
                result = FormatData(result, Resources.TF_LineItemPrice, () => ticketItem.Price.ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemTotal, () => ticketItem.GetItemPrice().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemTotalAndQuantity, () => ticketItem.GetItemValue().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemPriceCents, () => (ticketItem.Price * 100).ToString("#,##"));
                result = FormatData(result, Resources.TF_LineItemTotalWithoutGifts, () => ticketItem.GetTotal().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineOrderNumber, () => ticketItem.OrderNumber.ToString());
                result = FormatData(result, Resources.TF_LineGiftOrVoidReason, () => AppServices.MainDataContext.GetReason(ticketItem.ReasonId));
                result = FormatData(result, "{MENU ITEM GROUP}", () => GetMenuItemGroup(ticketItem));
                result = FormatData(result, "{MENU ITEM TAG}", () => GetMenuItemTag(ticketItem));
                result = FormatData(result, "{PRICE TAG}", () => ticketItem.PriceTag);
                result = FormatData(result, "{ITEM TAG}", () => ticketItem.Tag);

                while (Regex.IsMatch(result, "{ITEM TAG:[^}]+}", RegexOptions.Singleline))
                {
                    var tags = ticketItem.Tag.Split('|');
                    var match = Regex.Match(result, "{ITEM TAG:([^}]+)}");
                    var tagName = match.Groups[0].Value;
                    int index;
                    int.TryParse(match.Groups[1].Value, out index);
                    var value = tags.Count() > index ? tags[index].Trim() : "";
                    result = result.Replace(tagName, value);
                }

                if (result.Contains(Resources.TF_LineItemDetails.Substring(0, Resources.TF_LineItemDetails.Length - 1)))
                {
                    string lineFormat = result;
                    if (ticketItem.Properties.Count > 0)
                    {
                        string label = "";
                        foreach (var property in ticketItem.Properties)
                        {
                            var itemProperty = property;
                            var lineValue = FormatData(lineFormat, Resources.TF_LineItemDetails, () => itemProperty.Name);
                            lineValue = FormatData(lineValue, Resources.TF_LineItemDetailQuantity, () => itemProperty.Quantity.ToString("#.##"));
                            lineValue = FormatData(lineValue, Resources.TF_LineItemDetailPrice, () => itemProperty.CalculateWithParentPrice ? "" : itemProperty.PropertyPrice.Amount.ToString("#,#0.00"));
                            label += lineValue + "\r\n";
                        }
                        result = "\r\n" + label;
                    }
                    else result = "";
                }

                result = UpdateGlobalValues(result);
                result = result.Replace("<", "\r\n<");
            }
            return result;
        }