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