use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOTest method getSortedSavingsScheduleEntities.
private List<SavingsScheduleEntity> getSortedSavingsScheduleEntities() {
List<SavingsScheduleEntity> sortedSavingsScheduleEntities = new ArrayList<SavingsScheduleEntity>();
for (AccountActionDateEntity actionDateEntity : savingsAccount.getAccountActionDates()) {
sortedSavingsScheduleEntities.add((SavingsScheduleEntity) actionDateEntity);
}
Collections.sort(sortedSavingsScheduleEntities);
return sortedSavingsScheduleEntities;
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenSomeDepositAmountIsPaidScheduledInstallmentsHaveTheirDateUpdated.
@Test
public void whenSomeDepositAmountIsPaidScheduledInstallmentsHaveTheirDateUpdated() {
// 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).withDepositDue(new Money(TestUtils.RUPEE, "10.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "10.0")).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.MANDATORY, balanceBeforeDeposit);
// verification
assertThat(unpaidSaving2.getPaymentDate(), is(dateOfDeposit));
assertThat(unpaidSaving2.getPaymentDate(), is(dateOfDeposit));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenDepositAmountIsNotEnoughToPayOffAllScheduledPaymentsThenPayAsMuchAsPossibleOfEarliestScheduledPayments.
@Test
public void whenDepositAmountIsNotEnoughToPayOffAllScheduledPaymentsThenPayAsMuchAsPossibleOfEarliestScheduledPayments() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "30.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "10.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "50.0")).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.MANDATORY, balanceBeforeDeposit);
// verification
assertThat(unpaidSaving1.isPaid(), is(true));
assertThat(unpaidSaving2.isPaid(), is(false));
assertThat(unpaidSaving2.getDepositPaid(), is(new Money(TestUtils.RUPEE, "20.0")));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenDepositAmountIsInExcessOfTotalDepositDueAllScheduledPaymentsShouldBeMarkedAsPaid.
@Test
public void whenDepositAmountIsInExcessOfTotalDepositDueAllScheduledPaymentsShouldBeMarkedAsPaid() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "80.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "10.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "50.0")).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.MANDATORY, 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 SavingsScheduleIntegrationTest method createWeeklySavingScheduleNoHoliday.
@Ignore
@Test
public void createWeeklySavingScheduleNoHoliday() throws Exception {
createClientSavingsAccount();
short installmentId = 1;
DateTime installmentDate = expectedFirstDepositDate;
for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
installmentId++;
installmentDate = installmentDate.plusWeeks(1);
}
}
Aggregations