Exemplo n.º 1
0
        public void AddPayment(PaymentTemplate paymentTemplate, decimal tenderedAmount)
        {
            foreach (var ticket in Tickets.OrderBy(x => x.Date))
            {
                var payingAmount = ticket.GetRemainingAmount();
                if (payingAmount == 0) continue;

                if (payingAmount > tenderedAmount)
                    payingAmount = tenderedAmount;

                _ticketService.AddPayment(ticket, paymentTemplate, payingAmount);

                tenderedAmount -= payingAmount;

                if (tenderedAmount == 0) break;
                Debug.Assert(tenderedAmount > 0);
            }
        }
Exemplo n.º 2
0
        public void AddPayment(PaymentTemplate paymentTemplate, decimal amount, int userId)
        {
            var transaction = AccountTransaction.Create(paymentTemplate.AccountTransactionTemplate);
            transaction.Amount = amount;
            transaction.SetTargetAccount(paymentTemplate.Account.AccountTemplateId, paymentTemplate.Account.Id);
            transaction.UpdateAccounts(AccountTemplateId, AccountId);
            AccountTransactions.AccountTransactions.Add(transaction);
            var payment = new Payment { AccountTransaction = transaction, Amount = amount, Name = paymentTemplate.Account.Name };
            Payments.Add(payment);

            LastPaymentDate = DateTime.Now;
            RemainingAmount = GetRemainingAmount();
            if (RemainingAmount == 0)
            {
                PaidItems.Clear();
            }
        }
 private void OnMakeFastPaymentExecute(PaymentTemplate obj)
 {
     _ticketService.PayTicket(SelectedTicket, obj);
     CloseTicket();
 }
 private bool CanMakeFastPayment(PaymentTemplate arg)
 {
     return SelectedTicket != Ticket.Empty && SelectedTicket.GetRemainingAmount() > 0;
 }
Exemplo n.º 5
0
        private void SubmitPayment(PaymentTemplate paymentTemplate)
        {
            var tenderedAmount = GetTenderedValue();
            var remainingTicketAmount = GetPaymentValue();
            var returningAmount = 0m;
            if (tenderedAmount == 0) tenderedAmount = remainingTicketAmount;

            if (tenderedAmount > remainingTicketAmount)
            {
                returningAmount = tenderedAmount - remainingTicketAmount;
                tenderedAmount = remainingTicketAmount;
            }

            if (tenderedAmount > 0)
            {
                if (tenderedAmount > SelectedTicket.GetRemainingAmount())
                    tenderedAmount = SelectedTicket.GetRemainingAmount();
                _ticketService.AddPayment(SelectedTicket, paymentTemplate, tenderedAmount);
                PaymentAmount = (GetPaymentValue() - tenderedAmount).ToString("#,#0.00");

                LastTenderedAmount = tenderedAmount <= SelectedTicket.GetRemainingAmount()
                    ? tenderedAmount.ToString("#,#0.00")
                    : SelectedTicket.GetRemainingAmount().ToString("#,#0.00");
            }

            ReturningAmount = string.Format(Resources.ChangeAmount_f, returningAmount.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 });
            }

            if (returningAmount == 0 && SelectedTicket.GetRemainingAmount() == 0)
            {
                ClosePaymentScreen();
            }
            else PersistMergedItems();
        }
Exemplo n.º 6
0
 private bool CanMakeFastPayment(PaymentTemplate arg)
 {
     return SelectedTicket != null && Totals.TicketRemainingValue > 0
         && _userService.IsUserPermittedFor(PermissionNames.MakeFastPayment);
 }
Exemplo n.º 7
0
 private void OnMakePayment(PaymentTemplate obj)
 {
     SubmitPayment(obj);
 }
Exemplo n.º 8
0
 private bool CanMakePayment(PaymentTemplate arg)
 {
     return SelectedTicket != null
         && GetTenderedValue() > 0
         && SelectedTicket.GetRemainingAmount() > 0;
 }
 private Account GetAccountForTransaction(PaymentTemplate paymentTemplate, IEnumerable<TicketResource> ticketResources)
 {
     var rt = _cacheService.GetResourceTemplates().Where(
         x => x.AccountTemplateId == paymentTemplate.AccountTransactionTemplate.TargetAccountTemplateId).Select(x => x.Id);
     var tr = ticketResources.Where(x => rt.Contains(x.ResourceTemplateId)).FirstOrDefault();
     return tr != null ? _accountService.GetAccountById(tr.AccountId) : null;
 }
Exemplo n.º 10
0
 private bool CanMakePayment(PaymentTemplate arg)
 {
     return SelectedTicket != null
         && GetTenderedValue() > 0
         && SelectedTicket.GetRemainingAmount() > 0
         && (arg.Account != null || SelectedTicket.TicketResources.Any(x => CanMakeAccountTransaction(x, arg)));
 }
Exemplo n.º 11
0
 private bool CanMakeAccountTransaction(TicketResource ticketResource, PaymentTemplate paymentTemplate)
 {
     if (ticketResource.AccountId == 0) return false;
     var resourceTemplate = _cacheService.GetResourceTemplateById(ticketResource.ResourceTemplateId);
     if (resourceTemplate.AccountTemplateId != paymentTemplate.AccountTransactionTemplate.TargetAccountTemplateId) return false;
     return true;
 }