Search in sources :

Example 41 with SavingsAccountBuilder

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

the class SavingsPostInterestTest method whenPostingInterestSavingsPerformanceDetailsForInterestIsUpdatedWithAmountToBePosted.

@Test
public void whenPostingInterestSavingsPerformanceDetailsForInterestIsUpdatedWithAmountToBePosted() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertThat(savingsAccount.getSavingsPerformance().getTotalInterestEarned(), is(TestUtils.createMoney("0")));
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    assertThat(savingsAccount.getSavingsPerformance().getTotalInterestEarned(), is(TestUtils.createMoney("100")));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 42 with SavingsAccountBuilder

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindOnlyVoluntarySavingsAccountsForIndividualClientsOfTheVoluntaryCentersOrVoluntaryGroupsWithPerIndividualStatus.

@Test
public void testShouldFindOnlyVoluntarySavingsAccountsForIndividualClientsOfTheVoluntaryCentersOrVoluntaryGroupsWithPerIndividualStatus() {
    // setup
    savingsProduct = new SavingsProductBuilder().voluntary().withShortName("SP1").appliesToGroupsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().completeGroup().perIndividual().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    secondSavingsProduct = new SavingsProductBuilder().mandatory().withShortName("SP2").appliesToCentersOnly().withName("testSavingPrd2").buildForIntegrationTests();
    secondSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(secondSavingsProduct).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(secondSavingsProduct, secondSavingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> voluntarySavingAccountsForPaymentByIndividuals = savingsDao.findAllVoluntarySavingAccountsForIndividualChildrenOfCentersOrGroupsWithPerIndividualStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(voluntarySavingAccountsForPaymentByIndividuals.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 43 with SavingsAccountBuilder

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindExistingMandatorySavingsAccountsForGroupsWithCompleteGroupStatusWhenCenterIsTopOfCustomerHierarchy.

@Test
public void testShouldFindExistingMandatorySavingsAccountsForGroupsWithCompleteGroupStatusWhenCenterIsTopOfCustomerHierarchy() {
    // setup
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToGroupsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForClientsOrGroupsWithCompleteGroupStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 44 with SavingsAccountBuilder

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindExistingMandatorySavingsAccountsForClientsWhenCenterIsTopOfCustomerHierarchy.

@Test
public void testShouldFindExistingMandatorySavingsAccountsForClientsWhenCenterIsTopOfCustomerHierarchy() {
    // setup
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForClientsOrGroupsWithCompleteGroupStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 45 with SavingsAccountBuilder

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

the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method shouldGetTotalSavingsBalance.

@Test
public void shouldGetTotalSavingsBalance() throws Exception {
    // setup
    SavingsOfferingBO groupSavingsProduct = new SavingsProductBuilder().appliesToGroupsOnly().voluntary().withName("groupSavings").withShortName("GSP").buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(groupSavingsProduct);
    SavingsBO groupSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(groupSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "200.0")).build();
    IntegrationTestObjectMother.saveSavingsAccount(groupSavingsAccount);
    SavingsOfferingBO clientSavingsProduct = new SavingsProductBuilder().appliesToClientsOnly().voluntary().withName("clientSavings").withShortName("CSP").buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(clientSavingsProduct);
    SavingsBO clientSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(clientSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "550.0")).build();
    IntegrationTestObjectMother.saveSavingsAccount(clientSavingsAccount);
    existingGroup = customerDao.findGroupBySystemId(existingGroup.getGlobalCustNum());
    // exercise test
    Money savingsAmount = existingGroup.getGroupPerformanceHistory().getTotalSavingsAmount();
    // verification
    assertThat(savingsAmount.getAmountDoubleValue(), is(750.0));
}
Also used : Money(org.mifos.framework.util.helpers.Money) 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)

Aggregations

SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)45 Test (org.junit.Test)41 Money (org.mifos.framework.util.helpers.Money)21 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)18 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)18 DateTime (org.joda.time.DateTime)11 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)10 LocalDate (org.joda.time.LocalDate)8 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)8 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 ClientBuilder (org.mifos.domain.builders.ClientBuilder)7 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 ArrayList (java.util.ArrayList)5