Search in sources :

Example 11 with SavingsScheduleBuilder

use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.

the class SavingsBOTest method shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndVoluntarySavingsAccount.

@Ignore
@Test
public void shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndVoluntarySavingsAccount() throws AccountException {
    // setup
    savingsAccount = savingsAccountBuilder.build();
    final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
    final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
    SavingsOfferingBO volSavingsProduct = new SavingsProductBuilder().voluntary().buildForUnitTests();
    final Money zero = new Money(defaultCurrency);
    savingsAccount = savingsAccountBuilder.withSavingsProduct(volSavingsProduct).withBalanceOf(zero).completeGroup().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.VOLUNTARY, 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)

Example 12 with SavingsScheduleBuilder

use of org.mifos.domain.builders.SavingsScheduleBuilder in project head by mifos.

the class SavingsScheduleTest method whenASavingsScheduleForAnActiveSavingsAccountIsCreatedDepositEqualsTheAccountRecommendedAmount.

@Test
public void whenASavingsScheduleForAnActiveSavingsAccountIsCreatedDepositEqualsTheAccountRecommendedAmount() {
    AccountStateEntity savingsAccountState = new AccountStateEntity(AccountState.SAVINGS_ACTIVE);
    // stubbing
    when(savingsAccount.getAccountState()).thenReturn(savingsAccountState);
    // exercise
    savingsSchedule = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(recommendedAmount).build();
    // verification
    assertThat(savingsSchedule.getDeposit(), is(recommendedAmount));
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 13 with SavingsScheduleBuilder

use of org.mifos.domain.builders.SavingsScheduleBuilder 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));
}
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 14 with SavingsScheduleBuilder

use of org.mifos.domain.builders.SavingsScheduleBuilder 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")));
}
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 15 with SavingsScheduleBuilder

use of org.mifos.domain.builders.SavingsScheduleBuilder 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));
}
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)

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