示例#1
0
        public void GetPaymentFromRecurring_MonthlyPayment_CorrectMappedPayment()
        {
            var account = new AccountEntity {
                Id = 2
            };
            var dayOfMonth = 26;

            var recurringPayment = new RecurringPayment
            {
                Data =
                {
                    Id               =                         4,
                    Recurrence       = PaymentRecurrence.Monthly,
                    StartDate        = new DateTime(2015, 08, dayOfMonth),
                    ChargedAccountId =                         2,
                    ChargedAccount   = account,
                    Amount           = 105
                }
            };

            var result = RecurringPaymentHelper.GetPaymentFromRecurring(recurringPayment);

            result.Data.ChargedAccount.ShouldBe(account);
            result.Data.ChargedAccountId.ShouldBe(account.Id);
            result.Data.Amount.ShouldBe(105);
            result.Data.Date.ShouldBe(new DateTime(DateTime.Today.Year, DateTime.Today.Month, dayOfMonth));
        }
示例#2
0
        public void GetPaymentFromRecurring_CorrectMappedPayment(PaymentRecurrence recurrence)
        {
            var account = new AccountEntity {
                Id = 2
            };

            var recurringPayment = new RecurringPayment
            {
                Data =
                {
                    Id               =                 4,
                    Recurrence       = recurrence,
                    StartDate        = new DateTime(2015, 08, DateTime.Today.Day),
                    ChargedAccountId =                 2,
                    ChargedAccount   = account,
                    Amount           = 105
                }
            };

            var result = RecurringPaymentHelper.GetPaymentFromRecurring(recurringPayment);

            result.Data.ChargedAccount.ShouldBe(account);
            result.Data.ChargedAccountId.ShouldBe(account.Id);
            result.Data.Amount.ShouldBe(105);
            result.Data.Date.ShouldBe(DateTime.Today);
        }
示例#3
0
        /// <summary>
        ///     Checks if one of the recurring payment has to be repeated
        /// </summary>
        public void CheckRecurringPayments()
        {
            var paymentList = paymentRepository.LoadRecurringList();

            foreach (var payment in paymentList.Where(x => x.ChargedAccount != null))
            {
                var relatedPayment = GetLastOccurence(payment);

                if (RecurringPaymentHelper.CheckIfRepeatable(payment.RecurringPayment, relatedPayment))
                {
                    var newPayment = RecurringPaymentHelper.GetPaymentFromRecurring(payment.RecurringPayment);

                    paymentRepository.Save(newPayment);
                    accountRepository.AddPaymentAmount(newPayment);
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Checks if one of the recurring payment has to be repeated
        /// </summary>
        public void CheckRecurringPayments()
        {
            var paymentList = paymentManager.LoadRecurringPaymentList();

            foreach (var payment in paymentList.Where(x => x.ChargedAccount != null))
            {
                var relatedPayment = GetLastOccurence(payment);

                if (RecurringPaymentHelper.CheckIfRepeatable(payment.RecurringPayment, relatedPayment))
                {
                    var newPayment = RecurringPaymentHelper.GetPaymentFromRecurring(payment.RecurringPayment);

                    var paymentSucceded = paymentRepository.Save(newPayment);
                    var accountSucceded = paymentManager.AddPaymentAmount(newPayment);
                    if (paymentSucceded && accountSucceded)
                    {
                        settingsManager.LastDatabaseUpdate = DateTime.Now;
                    }
                }
            }
        }
示例#5
0
        public void GetPaymentFromRecurring_RecurringPayment_CorrectMappedFinancialTrans(
            PaymentRecurrence recurrence)
        {
            var account = new Account {
                Id = 2
            };

            var recurringPayment = new RecurringPayment
            {
                Id               = 4,
                Recurrence       = (int)recurrence,
                StartDate        = new DateTime(2015, 08, 25),
                ChargedAccountId = 2,
                ChargedAccount   = account,
                Amount           = 105
            };

            var result = RecurringPaymentHelper.GetPaymentFromRecurring(recurringPayment);

            result.ChargedAccount.ShouldBe(account);
            result.ChargedAccountId.ShouldBe(account.Id);
            result.Amount.ShouldBe(105);
            result.Date.ShouldBe(DateTime.Today);
        }