Search in sources :

Example 31 with SavingsAccountBuilder

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

the class GroupValidationTest method givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.

@Test
public void givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
    group.addChild(client);
    SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
    client.addAccount(savings);
    // exercise test
    try {
        group.validateNoActiveAccountsExist();
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 32 with SavingsAccountBuilder

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

the class SavingsScheduleIntegrationTest method createClientSavingsAccount.

public void createClientSavingsAccount() throws Exception {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Holiday(org.mifos.application.holiday.business.Holiday) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 33 with SavingsAccountBuilder

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

the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions.

@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("100")).withWithdrawalOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysBefore.size(), is(1));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysAfter.size(), is(3));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) Test(org.junit.Test)

Example 34 with SavingsAccountBuilder

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

the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions.

@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("0")).withDepositOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysBefore.size(), is(1));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysAfter.size(), is(3));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) Test(org.junit.Test)

Example 35 with SavingsAccountBuilder

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

the class SavingsAdjustmentTest method cannotAdjustLastTransactionToSameMonetaryAmount.

@Test
public void cannotAdjustLastTransactionToSameMonetaryAmount() {
    Money amountAdjustedTo = TestUtils.createMoney("15");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withDepositOf("15").build();
    // exercise test
    boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountAdjustedTo, savingsAccount.getLastPmnt());
    // verification
    assertFalse(result);
}
Also used : Money(org.mifos.framework.util.helpers.Money) 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