public decimal GetReturningAmount(decimal tenderedAmount, decimal paymentDueAmount, ChangePaymentType changeTemplate)
        {
            var returningAmount = 0m;

            if (tenderedAmount > paymentDueAmount)
            {
                ReturningAmount = "";
                returningAmount = (tenderedAmount - paymentDueAmount);
                if (changeTemplate != null)
                {
                    var currency = _cacheService.GetCurrencyById(changeTemplate.Account.ForeignCurrencyId);
                    ReturningAmount = string.Format(Resources.ChangeAmount_f,
                            currency != null
                                ? string.Format(currency.CurrencySymbol, returningAmount / currency.ExchangeRate)
                                : returningAmount.ToString(LocalSettings.CurrencyFormat));
                }
            }

            if (string.IsNullOrEmpty(ReturningAmount))
                ReturningAmount = string.Format(Resources.ChangeAmount_f,
                    (returningAmount / _paymentEditor.ExchangeRate).ToString(LocalSettings.CurrencyFormat));

            if (returningAmount != 0)
            {
                _applicationState.NotifyEvent(RuleEventNames.ChangeAmountChanged,
                                               new
                                               {
                                                   Ticket = _paymentEditor.SelectedTicket,
                                                   TicketAmount = _paymentEditor.SelectedTicket.TotalAmount,
                                                   ChangeAmount = returningAmount,
                                                   TenderedAmount = tenderedAmount
                                               });
            }
            return returningAmount;
        }
Ejemplo n.º 2
0
        public void UpdateTicketPayment(PaymentType paymentType, ChangePaymentType changeTemplate, decimal paymentDueAmount, decimal paidAmount, decimal tenderedAmount)
        {
            var paymentAccount = paymentType.Account ?? _ticketService.GetAccountForPayment(SelectedTicket, paymentType);

            if (paymentDueAmount > SelectedTicket.GetRemainingAmount() && paidAmount > SelectedTicket.GetRemainingAmount())
            {
                var account = _accountBalances.GetActiveAccount();
                if (account != null)
                {
                    var ticketAmount = SelectedTicket.GetRemainingAmount();
                    var accountAmount = paidAmount - ticketAmount;
                    var accountBalance = _accountBalances.GetAccountBalance(account.Id);
                    if (accountAmount > accountBalance) accountAmount = accountBalance;
                    if (ticketAmount > 0)
                        _ticketService.AddPayment(SelectedTicket, paymentType, paymentAccount, ticketAmount, tenderedAmount - accountAmount);
                    if (accountAmount > 0)
                        _ticketService.AddAccountTransaction(SelectedTicket, account, paymentAccount, accountAmount, ExchangeRate);
                }
                _accountBalances.Refresh();
            }
            else
            {
                _ticketService.AddPayment(SelectedTicket, paymentType, paymentAccount, paidAmount, tenderedAmount);
                if (paidAmount > paymentDueAmount && changeTemplate != null)
                {
                    _ticketService.AddChangePayment(SelectedTicket, changeTemplate, changeTemplate.Account,
                                                    paidAmount - paymentDueAmount);
                }
            }
        }
Ejemplo n.º 3
0
        public void AddChangePayment(ChangePaymentType changePaymentType, Account account, decimal amount, decimal exchangeRate, int userId)
        {
            var transaction = TransactionDocument.AddNewTransaction(changePaymentType.AccountTransactionType, GetTicketAccounts(account), amount, exchangeRate);
            var payment     = new ChangePayment {
                AccountTransaction = transaction, Amount = amount, Name = account.Name, ChangePaymentTypeId = changePaymentType.Id
            };

            ChangePayments.Add(payment);
        }
        public string GetChangeAmountCaption(decimal paymentDueAmount, decimal tenderedAmount, ChangePaymentType changeTemplate)
        {
            var returningAmount = (tenderedAmount - paymentDueAmount);
            if (changeTemplate != null)
            {
                var currency =_cacheService.GetCurrencyById(changeTemplate.Account.ForeignCurrencyId);

                if (currency != null)
                {
                    returningAmount = returningAmount / currency.ExchangeRate;
                    return string.Format(currency.CurrencySymbol, returningAmount);
                }
            }

            return returningAmount.ToString(LocalSettings.DefaultCurrencyFormat);
        }
Ejemplo n.º 5
0
 public void AddChangePayment(ChangePaymentType changePaymentType, Account account, decimal amount, decimal exchangeRate, int userId)
 {
     var transaction = TransactionDocument.AddNewTransaction(changePaymentType.AccountTransactionType, AccountTypeId, AccountId, account, amount, exchangeRate);
     var payment = new ChangePayment { AccountTransaction = transaction, Amount = amount, Name = account.Name, ChangePaymentTypeId = changePaymentType.Id };
     ChangePayments.Add(payment);
 }
Ejemplo n.º 6
0
 public void AddChangePayment(ChangePaymentType changePaymentType, Account account, decimal amount, decimal exchangeRate, int userId)
 {
     var transaction = TransactionDocument.AddNewTransaction(changePaymentType.AccountTransactionType, GetTicketAccounts(account), amount, exchangeRate);
     transaction.UpdateDescription(transaction.Name + " [" + account.Name + "]");
     var payment = new ChangePayment { AccountTransaction = transaction, Amount = amount, Name = account.Name, ChangePaymentTypeId = changePaymentType.Id, UserId = userId };
     ChangePayments.Add(payment);
 }
Ejemplo n.º 7
0
        private void SubmitPaymentAmount(PaymentType paymentType, ChangePaymentType changeTemplate, decimal paymentDueAmount, decimal tenderedAmount)
        {
            var returningAmount = _returningAmountViewModel.GetReturningAmount(tenderedAmount, paymentDueAmount, changeTemplate);

            if (changeTemplate == null) tenderedAmount -= returningAmount;
            _orderSelectorViewModel.UpdateSelectedTicketPaidItems();
            _paymentEditor.UpdateTicketPayment(paymentType, changeTemplate, paymentDueAmount, tenderedAmount);
            _numberPadViewModel.LastTenderedAmount = (tenderedAmount / _paymentEditor.ExchangeRate).ToString(LocalSettings.DefaultCurrencyFormat);
            _tenderedValueViewModel.UpdatePaymentAmount(_paymentEditor.GetRemainingAmount());

            if (returningAmount == 0 && _paymentEditor.GetRemainingAmount() == 0)
            {
                OnClosePaymentScreen("");
            }
            else
            {
                if (returningAmount > 0)
                {
                    _returningAmountViewModel.PublishEvent(EventTopicNames.Activate);
                }
                _orderSelectorViewModel.PersistSelectedItems();
                _numberPadViewModel.ResetValues();
                RaisePropertyChanged(() => SelectedTicketTitle);
            }
        }
Ejemplo n.º 8
0
 public void AddChangePayment(Ticket ticket, ChangePaymentType paymentType, Account account, decimal amount)
 {
     if (account == null) return;
     ticket.AddChangePayment(paymentType, account, amount, GetExchangeRate(account), _applicationState.CurrentLoggedInUser.Id);
 }
Ejemplo n.º 9
0
        private void SubmitPaymentAmount(PaymentType paymentType, ChangePaymentType changeTemplate, decimal paymentDueAmount, decimal tenderedAmount)
        {
            _applicationStateSetter.SetLastPaidItems(OrderSelector.GetSelectedItems());

            var returningAmount = DisplayReturningAmount(tenderedAmount, paymentDueAmount, changeTemplate);
            if (changeTemplate == null) tenderedAmount -= returningAmount;

            var paymentAccount = paymentType.Account ?? GetAccountForTransaction(paymentType, SelectedTicket.TicketResources);

            _ticketService.AddPayment(SelectedTicket, paymentType, paymentAccount, tenderedAmount);

            if (tenderedAmount > paymentDueAmount && changeTemplate != null)
            {
                _ticketService.AddChangePayment(SelectedTicket, changeTemplate, changeTemplate.Account, tenderedAmount - paymentDueAmount);
            }

            NumberPadViewModel.LastTenderedAmount = (tenderedAmount / ExchangeRate).ToString("#,#0.00");

            UpdatePaymentAmount(GetRemainingAmount());

            if (returningAmount == 0 && GetRemainingAmount() == 0)
            {
                ClosePaymentScreen();
            }
            else
            {
                OrderSelector.PersistSelectedItems();
                RefreshValues();
            }
        }
Ejemplo n.º 10
0
        private decimal DisplayReturningAmount(decimal tenderedAmount, decimal paymentDueAmount,
            ChangePaymentType changeTemplate)
        {
            var returningAmount = 0m;

            if (tenderedAmount > paymentDueAmount)
            {
                ReturningAmount = "";
                returningAmount = (tenderedAmount - paymentDueAmount);
                if (changeTemplate != null)
                {
                    var currency =
                        _cacheService.GetForeignCurrencies().SingleOrDefault(
                            x => x.Id == changeTemplate.Account.ForeignCurrencyId);

                    ReturningAmount = string.Format(Resources.ChangeAmount_f,
                            currency != null
                                ? string.Format(currency.CurrencySymbol, returningAmount / currency.ExchangeRate)
                                : returningAmount.ToString(LocalSettings.DefaultCurrencyFormat));
                }
            }

            if (string.IsNullOrEmpty(ReturningAmount))
                ReturningAmount = string.Format(Resources.ChangeAmount_f,
                    (returningAmount / ExchangeRate).ToString(LocalSettings.DefaultCurrencyFormat));

            ReturningAmountVisibility = returningAmount > 0 ? Visibility.Visible : Visibility.Collapsed;

            if (returningAmount != 0)
            {
                _automationService.NotifyEvent(RuleEventNames.ChangeAmountChanged,
                                               new
                                                   {
                                                       Ticket = SelectedTicket,
                                                       TicketAmount = SelectedTicket.TotalAmount,
                                                       ChangeAmount = returningAmount,
                                                       TenderedAmount = tenderedAmount
                                                   });
            }
            return returningAmount;
        }