Search in sources :

Example 6 with SavingsScheduleBuilder

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")));
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 7 with SavingsScheduleBuilder

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")));
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 8 with SavingsScheduleBuilder

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);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with SavingsScheduleBuilder

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);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with SavingsScheduleBuilder

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);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)20 Money (org.mifos.framework.util.helpers.Money)19 Date (java.util.Date)18 DateTime (org.joda.time.DateTime)18 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)18 LocalDate (org.joda.time.LocalDate)4 Ignore (org.junit.Ignore)4 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2