use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOTest method generateNextSetOfMeetingDatesMoratoriumOn12thInstallment.
@Ignore
@Test
public void generateNextSetOfMeetingDatesMoratoriumOn12thInstallment() throws Exception {
// setup
Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(11)).to(new DateMidnight().toDateTime().plusWeeks(11)).withRepaymentMoratoriumRule().build();
List<Holiday> withMoratorium = new ArrayList<Holiday>();
withMoratorium.add(moratorium);
when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
// exercise test
savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, withMoratorium);
// verify
List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
assertThat(sortedSavingsSchedules.size(), is(20));
DateTime installmentDate = new DateMidnight().toDateTime();
int installmentId = 1;
for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
if (installmentId < 12) {
assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.toDate()));
} else {
// Second and later deposits are pushed out one week by the moratorium
assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.plusWeeks(1).toDate()));
}
assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
installmentDate = installmentDate.plusWeeks(1);
installmentId++;
}
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOTest method depositScheduleIsGeneratedOnCreationWithMoratoriumOnSecondScheduledDeposit.
/**
* passing locally on eclipse but not on maven.
*/
@Ignore
@Test
public void depositScheduleIsGeneratedOnCreationWithMoratoriumOnSecondScheduledDeposit() {
// setup
Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(1)).to(new DateMidnight().toDateTime().plusWeeks(1)).withRepaymentMoratoriumRule().build();
when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
// exercise test
savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
// verify
List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
assertThat(sortedSavingsSchedules.size(), is(10));
DateTime installmentDate = new DateMidnight().toDateTime();
int installmentId = 1;
for (SavingsScheduleEntity savingsScheduleEntity : sortedSavingsSchedules) {
if (installmentId < 2) {
assertThat("Installment " + installmentId, new LocalDate(savingsScheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
} else {
// Second and later deposits are pushed out one week by the moratorium
assertThat("Installment " + installmentId, new LocalDate(savingsScheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
}
assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
installmentDate = installmentDate.plusWeeks(1);
installmentId++;
}
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenSomeDepositIsPaidOnInstallmentASavingsTrxnDetailIsCreatedWithLatestBalance.
@Test
public void whenSomeDepositIsPaidOnInstallmentASavingsTrxnDetailIsCreatedWithLatestBalance() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "60.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "25.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "36.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
verify(savingsTransactionActivityHelper, times(1)).createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "25.0"), payingCustomer, unpaidSaving1, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "25.0")));
verify(savingsTransactionActivityHelper, times(1)).createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "35.0"), payingCustomer, unpaidSaving2, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "60.0")));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenAllDepositIsPaidOnInstallmentASavingsTrxnDetailIsCreatedWithLatestBalance.
@Test
public void whenAllDepositIsPaidOnInstallmentASavingsTrxnDetailIsCreatedWithLatestBalance() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "70.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "25.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "36.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
verify(savingsTransactionActivityHelper, times(1)).createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "25.0"), payingCustomer, unpaidSaving1, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "25.0")));
verify(savingsTransactionActivityHelper, times(1)).createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "36.0"), payingCustomer, unpaidSaving2, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "61.0")));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOTest method overpayingMandatoryOrVoluntaryDepositAmountResultsInASavingsTrxnDetailForExcessAmountToBeAddedToAccountPaymentTransactions.
@Ignore
@Test
public void overpayingMandatoryOrVoluntaryDepositAmountResultsInASavingsTrxnDetailForExcessAmountToBeAddedToAccountPaymentTransactions() throws AccountException {
// setup
savingsAccount = savingsAccountBuilder.build();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
final Money zero = new Money(defaultCurrency);
savingsAccount = savingsAccountBuilder.withBalanceOf(zero).completeGroup().withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final Money excessDepositAmount = new Money(TestUtils.RUPEE, "25.0");
final Money expectedTotalBalance = amountToDeposit.add(zero);
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToDeposit);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
when(paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, zero)).thenReturn(excessDepositAmount);
when(savingsTransactionActivityHelper.createSavingsTrxnForDeposit(accountPayment, excessDepositAmount, payingCustomer, null, expectedTotalBalance)).thenReturn(savingsTrxnDetail);
// exercise test
savingsAccount.deposit(accountPayment, payingCustomer);
// verification
verify(accountPayment).addAccountTrxn(savingsTrxnDetail);
}
Aggregations