コード例 #1
0
        private void OnDivideValue(string obj)
        {
            var tenderedValue = _tenderedValueViewModel.GetTenderedValue();

            ResetAmount = true;
            var value = ConvertToDecimal(obj);
            var remainingTicketAmount = _tenderedValueViewModel.GetPaymentDueValue() / _paymentEditor.ExchangeRate;

            if (value > 0)
            {
                var amount = remainingTicketAmount / value;
                if (amount > remainingTicketAmount)
                {
                    amount = remainingTicketAmount;
                }
                _tenderedValueViewModel.TenderedAmount = amount.ToString(LocalSettings.ReportCurrencyFormat);
            }
            else
            {
                value = tenderedValue;
                if (value > 0)
                {
                    var amount = remainingTicketAmount / value;
                    if (amount > remainingTicketAmount)
                    {
                        amount = remainingTicketAmount;
                    }
                    _tenderedValueViewModel.TenderedAmount = (amount).ToString(LocalSettings.ReportCurrencyFormat);
                }
            }
            OnTypedValueChanged();
        }
コード例 #2
0
        public void UpdateCurrencyButtons()
        {
            _paymentButtonsViewModel.Update(ForeignCurrency);

            foreach (var commandButtonViewModel in ForeignCurrencyButtons)
            {
                var format = commandButtonViewModel.Parameter.CurrencySymbol;
                if (!format.Contains("{0"))
                {
                    format = format + " {0:N2}";
                }
                var pm = _tenderedValueViewModel.GetPaymentDueValue() / commandButtonViewModel.Parameter.ExchangeRate;
                commandButtonViewModel.Caption = string.Format(format, pm);
            }
            RaisePropertyChanged(() => ForeignCurrencyButtons);
        }
コード例 #3
0
 private bool CanMakePayment(PaymentType arg)
 {
     if (arg == null)
     {
         return(false);
     }
     if (_paymentEditor.AccountMode && _tenderedValueViewModel.GetTenderedValue() > _tenderedValueViewModel.GetPaymentDueValue())
     {
         return(false);
     }
     if (_paymentEditor.AccountMode && arg.Account == null)
     {
         return(false);
     }
     return(_paymentEditor.SelectedTicket != null &&
            !_paymentEditor.SelectedTicket.IsClosed &&
            _tenderedValueViewModel.GetTenderedValue() != 0 &&
            _paymentEditor.GetRemainingAmount() != 0 &&
            (arg.Account != null || _paymentEditor.SelectedTicket.TicketEntities.Any(x =>
                                                                                     _ticketService.CanMakeAccountTransaction(x, arg.AccountTransactionType, _accountBalances.GetAccountBalance(x.AccountId) + _tenderedValueViewModel.GetTenderedValue()))));
 }