public void Update(Ticket selectedTicket) { _selectedTicket = selectedTicket; TicketTagValueViewModels.Clear(); TicketTagValueViewModels.AddRange(_applicationState.GetTicketTagGroups().Where(x => x.AskBeforeCreatingTicket).Select(x => new TicketTagValueViewModel(x, selectedTicket))); RaisePropertyChanged(() => RowCount); }
public void UpdateTicket(Ticket ticket) { Model.UpdateTicket(ticket); Selectors.Clear(); Selectors.AddRange(Model.Selectors.Select(x => new SelectorViewModel(x))); Refresh(); }
public static IList<Order> GetOrders(ActionData x, Ticket ticket) { IList<Order> orders = new List<Order>(); var selectedOrder = x.GetDataValue<Order>("Order"); if (selectedOrder != null && ticket != null && selectedOrder.SelectedQuantity > 0 && selectedOrder.SelectedQuantity != selectedOrder.Quantity) { selectedOrder = ticket.ExtractSelectedOrder(selectedOrder); x.DataObject.Order = selectedOrder; } if (selectedOrder == null) { if (ticket != null) { orders = ticket.Orders.Any(y => y.IsSelected) ? ticket.ExtractSelectedOrders().ToList() : ticket.Orders; x.DataObject.Order = null; } } else orders.Add(selectedOrder); return orders; }
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; }
public void CanUpdatesTicketCorrectly() { var ticket = new Ticket(); var orderSelector = new OrderSelector(); orderSelector.UpdateTicket(ticket); Assert.AreEqual(ticket, orderSelector.SelectedTicket); }
public TicketViewModel(Ticket model, TicketTemplate ticketTemplate, bool forcePayment, ITicketService ticketService, IAutomationService automationService, IApplicationState applicationState) { _ticketService = ticketService; _forcePayment = forcePayment; _model = model; _ticketTemplate = ticketTemplate; _automationService = automationService; _applicationState = applicationState; _orders = new ObservableCollection<OrderViewModel>(model.Orders.Select(x => new OrderViewModel(x, ticketTemplate, _automationService)).OrderBy(x => x.Model.CreatedDateTime)); _itemsViewSource = new CollectionViewSource { Source = _orders }; _itemsViewSource.GroupDescriptions.Add(new PropertyGroupDescription("GroupObject")); SelectAllItemsCommand = new CaptionCommand<string>("", OnSelectAllItemsExecute); PrintJobButtons = _applicationState.CurrentTerminal.PrintJobs .Where(x => (!string.IsNullOrEmpty(x.ButtonHeader)) && (x.PrinterMaps.Count(y => y.DepartmentId == 0 || y.DepartmentId == model.DepartmentId) > 0)) .OrderBy(x => x.Order) .Select(x => new PrintJobButton(x, Model)); if (PrintJobButtons.Count(x => x.Model.UseForPaidTickets) > 0) { PrintJobButtons = IsPaid ? PrintJobButtons.Where(x => x.Model.UseForPaidTickets) : PrintJobButtons.Where(x => !x.Model.UseForPaidTickets); } }
public bool CanDisplay(Ticket selectedTicket) { if (string.IsNullOrEmpty(VisibleStates)) return false; if (VisibleStates == "*") return true; if (DisplayOnOrders) return selectedTicket.Orders.Where(x => x.IsSelected).All(x => IsInState(x, VisibleStates)); return IsInState(selectedTicket, VisibleStates); }
private IEnumerable<Order> GetOrders(PrintJob printJob, Ticket ticket, Func<Order, bool> orderSelector) { if (printJob.ExcludeTax) ticket.TaxIncluded = false; IEnumerable<Order> ti; switch (printJob.WhatToPrint) { case (int)WhatToPrintTypes.LastLinesByPrinterLineCount: ti = GetLastOrders(ticket, printJob, orderSelector); break; case (int)WhatToPrintTypes.LastPaidOrders: ti = GetLastPaidOrders(ticket); break; case (int)WhatToPrintTypes.OrdersByQuanity: ti = SeparateOrders(ticket, orderSelector).OrderBy(x => x.MenuItemName); break; case (int)WhatToPrintTypes.SeparatedByQuantity: ti = SeparateOrders(ticket, orderSelector).OrderBy(x => x.MenuItemName); break; default: ti = ticket.Orders.Where(orderSelector).OrderBy(x => x.Id).ToList(); break; } return ti; }
public TicketTotalsViewModel(ICacheService cacheService, AccountBalances accountBalances) { _cacheService = cacheService; _accountBalances = accountBalances; ResetCache(); _model = Ticket.Empty; }
public void Reset() { Debug.Assert(Ticket != null); Debug.Assert(_workspace != null); Ticket = null; _workspace = null; }
private void InternalPrint(Ticket ticket, PrintJob printJob, Func<Order, bool> orderSelector) { var tasks = _ticketPrintTaskBuilder.GetPrintTasksForTicket(ticket, printJob, orderSelector); foreach (var ticketPrintTask in tasks.Where(x => x != null && x.Printer != null && x.Lines != null)) { PrintJobFactory.CreatePrintJob(ticketPrintTask.Printer, _printerService).DoPrint(ticketPrintTask.Lines); } }
public void CanUpdateExchangeRate() { var ticket = new Ticket(1); ExpressionService.Eval("Ticket.Model.ExchangeRate=1.15", (new { Ticket = ticket }).ToDynamic(), 0); Assert.AreEqual(1.15m, ticket.ExchangeRate); var result = ExpressionService.Eval("result = Ticket.Model.ExchangeRate", (new { Ticket = ticket }).ToDynamic(), 0m); Assert.AreEqual(1.15m, result); }
public void AddAccountTransaction(Ticket ticket, Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate) { var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId, sourceAccount.Id, targetAccount.Id); if (transactionType != null) { ticket.TransactionDocument.AddNewTransaction(transactionType, ticket.GetTicketAccounts(), amount, exchangeRate); } }
public static void AutoPrintTicket(Ticket ticket) { foreach (var customPrinter in AppServices.CurrentTerminal.PrintJobs.Where(x => !x.UseForPaidTickets)) { if (ShouldAutoPrint(ticket, customPrinter)) ManualPrintTicket(ticket, customPrinter); } }
public void Update(Ticket selectedTicket) { ResourceList.Clear(); var rt = _cacheService.GetTicketTypeById(selectedTicket.TicketTypeId).ResourceTypeAssignments.First( x => x.AskBeforeCreatingTicket && !selectedTicket.TicketResources.Any(y => y.ResourceTypeId == x.ResourceTypeId)); ResourceList.AddRange(_cacheService.GetResources(rt.ResourceTypeId, rt.State)); RaisePropertyChanged(() => RowCount); RaisePropertyChanged(() => ColumnCount); }
public string[] Process(Ticket ticket, IList<Order> orders, string[] formattedLines) { var fileName = Settings.FileName; if (!string.IsNullOrEmpty(fileName)) { File.WriteAllLines(fileName, formattedLines); } return null; }
public bool CanExecute(Ticket selectedTicket) { if (string.IsNullOrEmpty(EnabledStates)) return false; if (EnabledStates.Contains("IsClosed") && selectedTicket.IsClosed) return true; if (selectedTicket.IsClosed) return false; if (EnabledStates == "*") return true; if (DisplayOnOrders) return selectedTicket.Orders.Where(x => x.IsSelected).All(x => IsInState(x, EnabledStates)); return IsInState(selectedTicket, EnabledStates); }
public void AddAccountTransaction(Ticket ticket, Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate) { var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId, sourceAccount.Id, targetAccount.Id); if (transactionType != null) { var transaction = ticket.TransactionDocument.AddNewTransaction(transactionType, ticket.GetTicketAccounts(), amount, exchangeRate); transaction.UpdateDescription(string.Format("{0} - {1}: {2}", transaction.Name, Resources.TicketNumber, ticket.TicketNumber)); } }
public TicketTotalsViewModel(ICacheService cacheService, AccountBalances accountBalances, IApplicationState applicationState) { _cacheService = cacheService; _accountBalances = accountBalances; _applicationState = applicationState; ResetCache(); _model = Ticket.Empty; }
public static string[] GetFormattedTicket(Ticket ticket, IEnumerable<Order> lines, PrinterTemplate printerTemplate) { var orders = printerTemplate.MergeLines ? MergeLines(lines) : lines; ticket.Orders.Clear(); orders.ToList().ForEach(ticket.Orders.Add); var content = TicketValueChanger.GetValue(printerTemplate, ticket); content = UpdateExpressions(content); return content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); }
public void Update(Ticket selectedTicket) { EntityList.Clear(); var rt = _cacheService.GetTicketTypeById(selectedTicket.TicketTypeId).EntityTypeAssignments.First( x => x.AskBeforeCreatingTicket && selectedTicket.TicketEntities.All(y => y.EntityTypeId != x.EntityTypeId)); EntityList.AddRange(_cacheService.GetEntities(rt.EntityTypeId, rt.State)); RaisePropertyChanged(() => RowCount); RaisePropertyChanged(() => ColumnCount); }
public void CreateTicket(Department department) { Debug.Assert(_workspace == null); Debug.Assert(Ticket == null); Debug.Assert(department != null); _workspace = WorkspaceFactory.Create(); Ticket = Ticket.Create(department); }
private static IEnumerable<Order> GetLastPaidOrders(Ticket ticket) { IEnumerable<PaidItem> paidItems = ticket.GetPaidItems().ToList(); var result = paidItems.Select(x => ticket.Orders.First(y => y.MenuItemId + "_" + y.Price == x.Key)).ToList(); foreach (var order in result) { order.Quantity = paidItems.First(x => x.Key == order.MenuItemId + "_" + order.Price).Quantity; } return result; }
private void ResetValues(Ticket selectedTicket) { SelectedTicket = null; SelectedOrder = null; SelectedItemPortions.Clear(); OrderTagGroups.Clear(); GroupedOrderTagGroups.Clear(); SetSelectedTicket(selectedTicket); }
public void CanSupportFluentSyntax() { var ticket = new Ticket(1); ticket.SetStateValue("Status", "New", ""); var result = ExpressionService.Eval("result = IsInState Ticket 'New'", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(true, result); result = ExpressionService.Eval("result = Ticket IsInState 'New'", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(true, result); result = ExpressionService.Eval("result = Ticket InState 'Status','New'", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(true, result); }
public void CanTestTicketState() { var ticket = new Ticket(1); ticket.SetStateValue("Status", "New", ""); var result = ExpressionService.Eval("result = Ticket.IsInState('New')", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(true, result); result = ExpressionService.Eval("result = Ticket.InState('Status','New')", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(true, result); ticket.SetStateValue("Status", "Paid", ""); result = ExpressionService.Eval("result = Ticket.InState('Status','New')", (new { Ticket = ticket }).ToDynamic(), false); Assert.AreEqual(false, result); }
public static void PrintOrders(PrintJob printJob, Ticket ticket) { if (printJob.ExcludeVat) { ticket = ObjectCloner.Clone(ticket); ticket.TicketItems.ToList().ForEach(x => x.VatIncluded = false); } IEnumerable<TicketItem> ti; switch (printJob.WhatToPrint) { case (int)WhatToPrintTypes.NewLines: ti = ticket.GetUnlockedLines(); break; case (int)WhatToPrintTypes.GroupedByBarcode: ti = GroupLinesByValue(ticket, x => x.Barcode ?? "", "1", true); break; case (int)WhatToPrintTypes.GroupedByGroupCode: ti = GroupLinesByValue(ticket, x => x.GroupCode ?? "", Resources.UndefinedWithBrackets); break; case (int)WhatToPrintTypes.GroupedByTag: ti = GroupLinesByValue(ticket, x => x.Tag ?? "", Resources.UndefinedWithBrackets); break; case (int)WhatToPrintTypes.LastLinesByPrinterLineCount: ti = GetLastItems(ticket, printJob); break; case (int)WhatToPrintTypes.LastPaidItems: ti = GetLastPaidItems(ticket).ToList(); ticket = ObjectCloner.Clone(ticket); ticket.TicketItems.Clear(); ticket.PaidItems.Clear(); ticket.Payments.Clear(); ti.ToList().ForEach(x => ticket.TicketItems.Add(x)); break; default: ti = ticket.TicketItems.OrderBy(x => x.Id).ToList(); break; } Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action( delegate { try { InternalPrintOrders(printJob, ticket, ti); } catch (Exception e) { AppServices.LogError(e, string.Format(Resources.PrintingErrorMessage_f, e.Message)); } })); }
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(); }
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(); }
public void OpenTicket(int ticketId) { Debug.Assert(_workspace == null); Debug.Assert(Ticket == null); _workspace = WorkspaceFactory.Create(); if (LocalSettings.DatabaseLabel == "CE") Ticket = _workspace.Single<Ticket>(ticket => ticket.Id == ticketId); else { Ticket = _workspace.Single<Ticket>(ticket => ticket.Id == ticketId, x => x.TicketItems.Select(y => y.Properties), x => x.Payments, x => x.Discounts, x => x.TaxServices); } }