public void ResetValues()
        {
            _paymentEditor.UpdateCalculations();

            if (_tenderedValueViewModel.GetPaymentDueValue() <= 0)
            {
                _tenderedValueViewModel.UpdatePaymentAmount(0);
            }

            _paymentTotals.ResetCache();
            _paymentTotals.Refresh();
            _accountBalances.Refresh();
            _tenderedValueViewModel.TenderedAmount = "";
            RaisePropertyChanged(() => BalanceModeCaption);
        }
Пример #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);
                    }
                    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);
                }
            }
        }