Search in sources :

Example 21 with SavingsProductBuilder

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

the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForActiveClientsOfCenter.

@Test
public void shouldGenerateSavingsAccountSchedulesForActiveClientsOfCenter() throws Exception {
    createCenterGroupClientHierarchy(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToCentersOnly().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(center).withMember(client).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    for (AccountActionDateEntity savingSchedule : savingSchedules) {
        assertThat("saving schedule should be generated for active client belong to center savings account", savingSchedule.getCustomer().getCustomerId(), is(client.getCustomerId()));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 22 with SavingsProductBuilder

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

the class SavingsAdjustmentTest method cannotAdjustLastTransactionWhenItsAWithdrawalThatExceedsAccountBalance.

@Test
public void cannotAdjustLastTransactionWhenItsAWithdrawalThatExceedsAccountBalance() {
    savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").withMaxWithdrawalAmount(TestUtils.createMoney("600")).appliesToClientsOnly().buildForUnitTests();
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("100")).withWithdrawalOf("15").build();
    Money amountGreaterThanSavingsBalance = savingsAccount.getSavingsBalance().add(TestUtils.createMoney("20"));
    // exercise test
    boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountGreaterThanSavingsBalance, savingsAccount.getLastPmnt());
    // verification
    assertFalse(result);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 23 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder 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 24 with SavingsProductBuilder

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

the class SavingsWithdrawalTest method whenSingleWithdrawalThenOneSavingsTrxnDetailIsAddedToAccountPayment.

@Test
public void whenSingleWithdrawalThenOneSavingsTrxnDetailIsAddedToAccountPayment() throws AccountException {
    // setup
    final Money startingBalance = new Money(TestUtils.RUPEE, "80.0");
    savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(startingBalance).buildForUnitTests();
    final Money amountToWithdraw = new Money(TestUtils.RUPEE, "25.0");
    // stubbing
    when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
    when(savingsTransactionActivityHelper.createSavingsTrxnForWithdrawal(accountPayment, amountToWithdraw, payingCustomer, startingBalance.subtract(amountToWithdraw))).thenReturn(savingsTrxnDetail);
    // exercise test
    savingsAccount.withdraw(accountPayment, payingCustomer);
    // verification
    verify(accountPayment).addAccountTrxn(savingsTrxnDetail);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Test(org.junit.Test)

Example 25 with SavingsProductBuilder

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

the class SavingsWithdrawalTest method whenSingleWithdrawalThenOneSavingsActivityIsCreated.

@Test
public void whenSingleWithdrawalThenOneSavingsActivityIsCreated() throws AccountException {
    // setup
    final Money startingBalance = new Money(TestUtils.RUPEE, "80.0");
    savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(startingBalance).buildForUnitTests();
    final Money amountToWithdraw = new Money(TestUtils.RUPEE, "25.0");
    // stubbing
    when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
    when(savingsTransactionActivityHelper.createSavingsActivityForWithdrawal(accountPayment, startingBalance, savingsAccount)).thenReturn(savingsActivityDetail);
    // exercise test
    savingsAccount.withdraw(accountPayment, payingCustomer);
    // verification
    assertThat(savingsAccount.getSavingsActivityDetails().size(), is(1));
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Test(org.junit.Test)

Aggregations

SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)32 Test (org.junit.Test)26 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)19 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)14 Money (org.mifos.framework.util.helpers.Money)14 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)9 LocalDate (org.joda.time.LocalDate)6 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 DateTime (org.joda.time.DateTime)5 Before (org.junit.Before)4 CollectionSheetCustomerSavingDto (org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto)4 ClientBuilder (org.mifos.domain.builders.ClientBuilder)4 Date (java.util.Date)3 Ignore (org.junit.Ignore)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)3 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 Holiday (org.mifos.application.holiday.business.Holiday)1