コード例 #1
0
 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);
 }
コード例 #2
0
 public void UpdateTicket(Ticket ticket)
 {
     Model.UpdateTicket(ticket);
     Selectors.Clear();
     Selectors.AddRange(Model.Selectors.Select(x => new SelectorViewModel(x)));
     Refresh();
 }
コード例 #3
0
ファイル: Helper.cs プロジェクト: GHLabs/SambaPOS-3
        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;
        }
コード例 #4
0
ファイル: TicketService.cs プロジェクト: basio/SambaPOS-3
        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;
        }
コード例 #5
0
 public void CanUpdatesTicketCorrectly()
 {
     var ticket = new Ticket();
     var orderSelector = new OrderSelector();
     orderSelector.UpdateTicket(ticket);
     Assert.AreEqual(ticket, orderSelector.SelectedTicket);
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 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);
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 public TicketTotalsViewModel(ICacheService cacheService, AccountBalances accountBalances)
 {
     _cacheService = cacheService;
     _accountBalances = accountBalances;
     ResetCache();
     _model = Ticket.Empty;
 }
コード例 #10
0
ファイル: MainDataContext.cs プロジェクト: hpbaotho/sambapos
 public void Reset()
 {
     Debug.Assert(Ticket != null);
     Debug.Assert(_workspace != null);
     Ticket = null;
     _workspace = null;
 }
コード例 #11
0
ファイル: TicketPrinter.cs プロジェクト: GHLabs/SambaPOS-3
 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);
     }
 }
コード例 #12
0
ファイル: ExpressionTests.cs プロジェクト: GHLabs/SambaPOS-3
 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);
 }
コード例 #13
0
ファイル: TicketService.cs プロジェクト: hperassi/SambaPOS-3
 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);
     }
 }
コード例 #14
0
ファイル: TicketPrinter.cs プロジェクト: basio/veropos
 public static void AutoPrintTicket(Ticket ticket)
 {
     foreach (var customPrinter in AppServices.CurrentTerminal.PrintJobs.Where(x => !x.UseForPaidTickets))
     {
         if (ShouldAutoPrint(ticket, customPrinter))
             ManualPrintTicket(ticket, customPrinter);
     }
 }
コード例 #15
0
 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);
 }
コード例 #16
0
 public string[] Process(Ticket ticket, IList<Order> orders, string[] formattedLines)
 {
     var fileName = Settings.FileName;
     if (!string.IsNullOrEmpty(fileName))
     {
         File.WriteAllLines(fileName, formattedLines);
     }
     return null;
 }
コード例 #17
0
 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);
 }
コード例 #18
0
ファイル: TicketService.cs プロジェクト: BOBAHbI4/SambaPOS-3
 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));
     }
 }
コード例 #19
0
 public TicketTotalsViewModel(ICacheService cacheService, AccountBalances accountBalances,
     IApplicationState applicationState)
 {
     _cacheService = cacheService;
     _accountBalances = accountBalances;
     _applicationState = applicationState;
     ResetCache();
     _model = Ticket.Empty;
 }
コード例 #20
0
 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();
 }
コード例 #21
0
 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);
 }
コード例 #22
0
ファイル: MainDataContext.cs プロジェクト: hpbaotho/sambapos
            public void CreateTicket(Department department)
            {
                Debug.Assert(_workspace == null);
                Debug.Assert(Ticket == null);
                Debug.Assert(department != null);

                _workspace = WorkspaceFactory.Create();
                Ticket = Ticket.Create(department);
            }
コード例 #23
0
 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;
 }
コード例 #24
0
        private void ResetValues(Ticket selectedTicket)
        {
            SelectedTicket = null;
            SelectedOrder = null;

            SelectedItemPortions.Clear();
            OrderTagGroups.Clear();
            GroupedOrderTagGroups.Clear();

            SetSelectedTicket(selectedTicket);
        }
コード例 #25
0
ファイル: ExpressionTests.cs プロジェクト: GHLabs/SambaPOS-3
 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);
 }
コード例 #26
0
ファイル: ExpressionTests.cs プロジェクト: GHLabs/SambaPOS-3
 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);
 }
コード例 #27
0
ファイル: TicketPrinter.cs プロジェクト: basio/veropos
        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));
                        }
                    }));
        }
コード例 #28
0
ファイル: MenuGroupBuilder.cs プロジェクト: basio/veropos
 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();
 }
コード例 #29
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();
 }
コード例 #30
0
ファイル: MainDataContext.cs プロジェクト: hpbaotho/sambapos
 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);
     }
 }