private IEnumerable <CommandButtonViewModel <object> > CreateCommandButtons()
        {
            var result = new List <CommandButtonViewModel <object> >();

            if (_paymentEditor.SelectedTicket != null)
            {
                result.AddRange(_applicationState.GetCalculationSelectors().Where(x => !string.IsNullOrEmpty(x.ButtonHeader))
                                .Select(x => new CommandButtonViewModel <object>
                {
                    Caption   = x.ButtonHeader,
                    Command   = _serviceSelectedCommand,
                    Color     = x.ButtonColor,
                    FontSize  = x.FontSize,
                    Parameter = x
                }));

                result.AddRange(_applicationState.GetAutomationCommands().Where(x => x.AutomationCommand != null && !string.IsNullOrEmpty(x.AutomationCommand.ButtonHeader) && x.DisplayOnPayment && x.CanDisplay(_paymentEditor.SelectedTicket))
                                .Select(x => new CommandButtonViewModel <object>
                {
                    Caption   = x.AutomationCommand.ButtonHeader,
                    Command   = _executeAutomationCommand,
                    Color     = x.AutomationCommand.Color,
                    FontSize  = x.AutomationCommand.FontSize,
                    Parameter = x
                }));
            }
            return(result);
        }
Exemplo n.º 2
0
        private Ticket CreateTicket()
        {
            var account = _cacheService.GetAccountById(_applicationState.CurrentTicketType.SaleTransactionType.DefaultTargetAccountId);
            var result  = Ticket.Create(
                _applicationState.CurrentDepartment.Model,
                _applicationState.CurrentTicketType,
                GetExchangeRate(account),
                _applicationState.GetCalculationSelectors().Where(x => string.IsNullOrEmpty(x.ButtonHeader)).SelectMany(y => y.CalculationTypes));

            _applicationState.NotifyEvent(RuleEventNames.TicketCreated, new { Ticket = result, TicketTypeName = _applicationState.CurrentTicketType.Name });
            return(result);
        }
Exemplo n.º 3
0
        public void UpdateCalculations()
        {
            _ticketService.RecalculateTicket(SelectedTicket);
            if (GetRemainingAmount() < 0)
            {
                foreach (var cSelector in _applicationState.GetCalculationSelectors().Where(x => !string.IsNullOrEmpty(x.ButtonHeader)))
                {
                    foreach (var ctemplate in cSelector.CalculationTypes)
                    {
                        while (SelectedTicket.Calculations.Any(x => x.CalculationTypeId == ctemplate.Id))
                        {
                            SelectedTicket.AddCalculation(ctemplate, 0);
                        }
                    }
                }

                _ticketService.RecalculateTicket(SelectedTicket);
                if (GetRemainingAmount() >= 0)
                {
                    InteractionService.UserIntraction.GiveFeedback(Resources.AllDiscountsRemoved);
                }
            }
        }