use of org.mifos.domain.builders.SavingsScheduleBuilder 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.domain.builders.SavingsScheduleBuilder 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.domain.builders.SavingsScheduleBuilder 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);
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsBOTest method overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated.
@Ignore
@Test
public void overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated() throws AccountException {
// setup
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).build();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
final Money zero = new Money(defaultCurrency);
SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).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.MANDATORY, zero)).thenReturn(excessDepositAmount);
// exercise test
savingsAccount.deposit(accountPayment, payingCustomer);
// verification
verify(this.savingsTransactionActivityHelper).createSavingsTrxnForDeposit(accountPayment, excessDepositAmount, payingCustomer, null, expectedTotalBalance);
}
use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.
the class SavingsBOTest method shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount.
@Ignore
@Test
public void shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount() throws AccountException {
// setup
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).buildForUnitTests();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
final Money zero = new Money(defaultCurrency);
SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToDeposit);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
savingsAccount.deposit(accountPayment, payingCustomer);
// verification
verify(paymentStrategy).makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, zero);
}
Aggregations