use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistEarliestDueInstallmentsArePaidOffFirst.
@Test
public void whenUnpaidScheduledInstallmentsExistEarliestDueInstallmentsArePaidOffFirst() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "10.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));
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenSomeDepositIsPaidOnInstallmentTheSavingsTrxnDetailCreatedIsAddedToAccountPaymentTrxnss.
@Test
public void whenSomeDepositIsPaidOnInstallmentTheSavingsTrxnDetailCreatedIsAddedToAccountPaymentTrxnss() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "65.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, "40.0")).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
when(savingsTransactionActivityHelper.createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "25.0"), payingCustomer, unpaidSaving1, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "25.0")))).thenReturn(savingsTrxnDetail);
when(savingsTransactionActivityHelper.createSavingsTrxnForDeposit(accountPayment, new Money(TestUtils.RUPEE, "40.0"), payingCustomer, unpaidSaving2, balanceBeforeDeposit.add(new Money(TestUtils.RUPEE, "65.0")))).thenReturn(savingsTrxnDetail);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, balanceBeforeDeposit);
// verification
verify(accountPayment, times(2)).addAccountTrxn(savingsTrxnDetail);
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistTheLastScheduledPaymentDateIsUpdated.
@Test
public void whenUnpaidScheduledInstallmentsExistTheLastScheduledPaymentDateIsUpdated() {
// 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(unpaidSaving2.getPaymentDate(), is(dateOfDeposit));
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistTheCreatedSavingsTrxnDetailIsAddedToAccountPaymentTrxns.
@Test
public void whenUnpaidScheduledInstallmentsExistTheCreatedSavingsTrxnDetailIsAddedToAccountPaymentTrxns() {
// 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);
when(savingsTransactionActivityHelper.createSavingsTrxnForDeposit(accountPayment, recommendedDepositDue, payingCustomer, unpaidSaving2, balanceBeforeDeposit.add(recommendedDepositDue))).thenReturn(savingsTrxnDetail);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
verify(accountPayment, times(1)).addAccountTrxn(savingsTrxnDetail);
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistTheLastScheduledPaymentIsOnlyPaidOffTheRecommendedAmount.
@Test
public void whenUnpaidScheduledInstallmentsExistTheLastScheduledPaymentIsOnlyPaidOffTheRecommendedAmount() {
// 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
assertThat(unpaidSaving1.getDepositPaid(), is(TestUtils.createMoney()));
assertThat(unpaidSaving2.getDepositPaid(), is(recommendedDepositDue));
}
Aggregations