use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistAllAreMarkedAsPaid.
@Test
public void whenUnpaidScheduledInstallmentsExistAllAreMarkedAsPaid() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
assertThat(unpaidSaving1.isPaid(), is(true));
assertThat(unpaidSaving2.isPaid(), is(true));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistAnyExcessPaymentOverDepositDueShouldBeReturnedAsRemainingAmount.
@Test
public void whenUnpaidScheduledInstallmentsExistAnyExcessPaymentOverDepositDueShouldBeReturnedAsRemainingAmount() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Money recommendedDepositDue = new Money(TestUtils.RUPEE, "36.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(recommendedDepositDue).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
final Money remainingAmount = paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
assertThat(remainingAmount, is(fullDepositAmount.subtract(recommendedDepositDue)));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistASavingsTrxnDetailIsCreatedWithLatestBalance.
@Test
public void whenUnpaidScheduledInstallmentsExistASavingsTrxnDetailIsCreatedWithLatestBalance() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Money recommendedDepositDue = new Money(TestUtils.RUPEE, "36.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(recommendedDepositDue).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
verify(savingsTransactionActivityHelper, times(1)).createSavingsTrxnForDeposit(accountPayment, recommendedDepositDue, payingCustomer, unpaidSaving2, balanceBeforeDeposit.add(recommendedDepositDue));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenNoUnpaidScheduledInstallmentsExistNoPaymentsAreMade.
@Test
public void whenNoUnpaidScheduledInstallmentsExistNoPaymentsAreMade() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList();
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
verify(accountPayment, times(0)).addAccountTrxn(any(AccountTrxnEntity.class));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday.
@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday() throws Exception {
buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT);
createClientSavingsAccount();
short installmentId = 1;
DateTime installmentDate = expectedFirstDepositDate;
for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
if (installmentId == 2) {
// only second installment pushed out one week.
assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
} else {
assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
}
assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
installmentId++;
installmentDate = installmentDate.plusWeeks(1);
}
}
Aggregations