Search in sources :

Example 6 with LoanAccountBuilder

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

the class GroupValidationTest method givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.

@Test
public void givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
    group.addChild(client);
    LoanBO loan = new LoanAccountBuilder().activeInGoodStanding().build();
    client.addAccount(loan);
    // 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) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 7 with LoanAccountBuilder

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

the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() throws Exception {
    databaseCleaner.clean();
    existingUser = IntegrationTestObjectMother.testUser();
    existingLoanOfficer = IntegrationTestObjectMother.testUser();
    existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
    existingMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(existingMeeting);
    existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    existingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingGroup, existingMeeting);
    existingActiveClient = new ClientBuilder().withName("activeClient").withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
    existingOnHoldClient = new ClientBuilder().withName("onHoldClient").withStatus(CustomerStatus.CLIENT_HOLD).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingOnHoldClient, existingMeeting);
    existingCancelledClient = new ClientBuilder().withName("cancelledClient").withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
    DateTime startDate = new DateTime().toDateMidnight().toDateTime();
    LoanOfferingBO groupLoanProduct = new LoanProductBuilder().appliesToGroupsOnly().active().withMeeting(existingMeeting).withName("Loandsdasd").withShortName("fsad").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(groupLoanProduct);
    account1 = new LoanAccountBuilder().withLoanProduct(groupLoanProduct).withCustomer(existingGroup).withOriginalLoanAmount(400.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account1);
    LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(clientLoanProduct);
    account2 = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account2);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Aggregations

LoanAccountBuilder (org.mifos.domain.builders.LoanAccountBuilder)7 Test (org.junit.Test)5 CenterBuilder (org.mifos.domain.builders.CenterBuilder)4 GroupBuilder (org.mifos.domain.builders.GroupBuilder)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 CenterBO (org.mifos.customers.center.business.CenterBO)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 GroupBO (org.mifos.customers.group.business.GroupBO)3 ClientBuilder (org.mifos.domain.builders.ClientBuilder)3 ArrayList (java.util.ArrayList)2 DateTime (org.joda.time.DateTime)2 Before (org.junit.Before)2 Ignore (org.junit.Ignore)2 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)2 Date (java.util.Date)1 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)1 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)1