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(); } }
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); } } }