Search in sources :

Example 1 with LoanAccountBuilder

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

the class StandardAccountServiceTest method setup.

@Before
public void setup() {
    standardAccountService = new StandardAccountService(legacyAccountDao, legacyLoanDao, acceptedPaymentTypePersistence, personnelDao, customerDao, loanBusinessService, transactionHelper, legacyMasterDao, monthClosingServiceFacade, savingsServiceFacade, groupLoanAccountServiceFacade);
    Money.setDefaultCurrency(TestUtils.RUPEE);
    accountBO = new LoanAccountBuilder().withCustomer(customerBO).build();
    accountBO.setlegacyAccountDao(legacyAccountDao);
}
Also used : LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) Before(org.junit.Before)

Example 2 with LoanAccountBuilder

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

the class LoanBOTest method testCopyInstallmentSchedule.

/**
     * does't work when changing applicatonConfiguration.custom.properties file.
     * Need to pull out static references to AccountingRules in used classes.
     */
@Ignore
@Test
public void testCopyInstallmentSchedule() {
    Money.setDefaultCurrency(rupee);
    LoanBO loanBO = new LoanAccountBuilder().build();
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 10, 2010), "100", "10", "1", Money.zero(rupee)));
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 11, 2010), "100", "10", "2", Money.zero(rupee)));
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 12, 2010), "100", "10", "3", Money.zero(rupee)));
    List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
    installments.add(getRepaymentScheduleInstallment("24-Oct-2010", 1, "123", "12"));
    installments.add(getRepaymentScheduleInstallment("24-Nov-2010", 2, "231", "23"));
    installments.add(getRepaymentScheduleInstallment("24-Dec-2010", 3, "312", "31"));
    loanBO.updateInstallmentSchedule(installments);
    Set<LoanScheduleEntity> loanScheduleEntities = loanBO.getLoanScheduleEntities();
    LoanScheduleEntity[] loanScheduleEntitiesArr = loanScheduleEntities.toArray(new LoanScheduleEntity[loanScheduleEntities.size()]);
    assertLoanScheduleEntity(loanScheduleEntitiesArr[0], "123.0", "12.0", "2010-10-24");
    assertLoanScheduleEntity(loanScheduleEntitiesArr[1], "231.0", "23.0", "2010-11-24");
    assertLoanScheduleEntity(loanScheduleEntitiesArr[2], "312.0", "31.0", "2010-12-24");
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) ArrayList(java.util.ArrayList) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with LoanAccountBuilder

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

the class LoanBOTest method testLoanSummaryShouldBeUpdateOnInstallmentScheduleUpdate.

/**
     * does't work when changing applicatonConfiguration.custom.properties file.
     * Need to pull out static references to AccountingRules in used classes.
     */
@Ignore
@Test
public void testLoanSummaryShouldBeUpdateOnInstallmentScheduleUpdate() {
    Money.setDefaultCurrency(rupee);
    LoanBO loanBO = new LoanAccountBuilder().build();
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 10, 2010), "100", "10", "1", Money.zero(rupee)));
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 11, 2010), "100", "10", "2", Money.zero(rupee)));
    loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 12, 2010), "100", "10", "3", Money.zero(rupee)));
    List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
    installments.add(getRepaymentScheduleInstallment("24-Oct-2010", 1, "123", "12"));
    installments.add(getRepaymentScheduleInstallment("24-Nov-2010", 2, "231", "23"));
    installments.add(getRepaymentScheduleInstallment("24-Dec-2010", 3, "312", "31"));
    loanBO.updateInstallmentSchedule(installments);
    Set<LoanScheduleEntity> loanScheduleEntities = loanBO.getLoanScheduleEntities();
    LoanScheduleEntity[] loanScheduleEntitiesArr = loanScheduleEntities.toArray(new LoanScheduleEntity[loanScheduleEntities.size()]);
    assertLoanScheduleEntity(loanScheduleEntitiesArr[0], "123.0", "12.0", "2010-10-24");
    assertLoanScheduleEntity(loanScheduleEntitiesArr[1], "231.0", "23.0", "2010-11-24");
    assertLoanScheduleEntity(loanScheduleEntitiesArr[2], "312.0", "31.0", "2010-12-24");
    LoanSummaryEntity loanSummary = loanBO.getLoanSummary();
    assertEquals("666.0", loanSummary.getOriginalPrincipal().toString());
    assertEquals("66.0", loanSummary.getOriginalInterest().toString());
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) ArrayList(java.util.ArrayList) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with LoanAccountBuilder

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

the class ClientStatusChangeIntegrationTest method givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed.

@Test
public void givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
    ClientBO existingActiveClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
    StaticHibernateUtil.flushAndClearSession();
    DateTime startDate = new DateTime().minusDays(14);
    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);
    LoanBO clientLoan = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
    IntegrationTestObjectMother.saveLoanAccount(clientLoan);
    existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
    existingActiveClient = this.customerDao.findClientBySystemId(existingActiveClient.getGlobalCustNum());
    existingActiveClient.setUserContext(TestUtils.makeUser());
    CustomerStatusFlag customerStatusFlag = null;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingActiveClient.getPersonnel(), existingActiveClient);
    // exercise test
    try {
        customerService.updateClientStatus(existingActiveClient, existingActiveClient.getStatus(), CustomerStatus.CLIENT_CLOSED, customerStatusFlag, customerNote);
        fail("should fail validation");
    } catch (CustomerException expected) {
        assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_HAS_ACTIVE_ACCOUNTS_EXCEPTION));
        assertThat(existingActiveClient.getStatus(), is(CustomerStatus.CLIENT_ACTIVE));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) 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) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) DateTime(org.joda.time.DateTime) Date(java.util.Date) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 5 with LoanAccountBuilder

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

the class GroupValidationTest method givenAnActiveLoanAccountExistsGroupTransferToCenterShouldFailValidation.

@Test
public void givenAnActiveLoanAccountExistsGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    LoanBO loan = new LoanAccountBuilder().activeInGoodStanding().build();
    group.addAccount(loan);
    // exercise test
    try {
        group.validateNoActiveAccountsExist();
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) 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) Test(org.junit.Test)

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