Search in sources :

Example 96 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class CloseLoanActionStrutsTest method getLoanAccount.

private LoanBO getLoanAccount() {
    Date startDate = new DateTimeService().getCurrentJavaDateTime();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date)

Example 97 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class RepayLoanActionStrutsTest method getLoanAccount.

private AccountBO getLoanAccount() {
    Date startDate = new DateTimeService().getCurrentJavaDateTime();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date)

Example 98 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class ProductMixValidatorIntegrationTest method testShouldDetectProductMixConflicts.

@Test
public void testShouldDetectProductMixConflicts() throws Exception {
    short PRD_OFFERING_ID_TWO = (short) 2;
    LoanBO loanMock1 = createMock(LoanBO.class);
    LoanBO loanMock2 = createMock(LoanBO.class);
    LoanOfferingBO loanOfferingMock1 = createMock(LoanOfferingBO.class);
    LoanOfferingBO loanOfferingMock2 = createMock(LoanOfferingBO.class);
    expect(loanMock2.getLoanOffering()).andReturn(loanOfferingMock2);
    expect(loanMock1.getLoanOffering()).andReturn(loanOfferingMock1);
    expect(loanOfferingMock2.getPrdOfferingId()).andReturn(PRD_OFFERING_ID_TWO);
    expect(productMixBusinessServiceMock.canProductsCoExist(loanOfferingMock2, loanOfferingMock1)).andReturn(false);
    replay(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
    try {
        new ProductMixValidator(configServiceMock, productMixBusinessServiceMock) {

            @Override
            void handleConflict(LoanBO newloan, LoanBO loan) throws AccountException {
                throw new AccountException("Some exception code");
            }
        }.validateProductMix(loanMock2, Arrays.asList(loanMock1));
        Assert.fail("Product mix conflict not detected");
        verify(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
    } catch (AccountException e) {
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 99 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class MultipleLoanAccountsCreationActionStrutsTest method testCreate.

@SuppressWarnings("unchecked")
@Test
public void testCreate() throws Exception {
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    EntityMasterData.getInstance().init();
    FieldConfig fieldConfig = FieldConfig.getInstance();
    fieldConfig.init();
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createInitialCustomers();
    LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "get");
    addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
    addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
    addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
    SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
    addRequestParameter("centerId", center.getCustomerId().toString());
    addRequestParameter("centerSearchId", center.getSearchId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("clientDetails[0].loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("stateSelected", "1");
    addRequestParameter("clientDetails[0].selected", "true");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("method", "create");
    addRequestParameter("stateSelected", "1");
    actionPerform();
    verifyActionErrors(new String[] { LoanExceptionConstants.CUSTOMER_PURPOSE_OF_LOAN_FIELD });
    addRequestParameter("clientDetails[0].businessActivity", "0001");
    performNoErrors();
    verifyForward(ActionForwards.create_success.toString());
    List<String> accountNumbers = ((List<String>) request.getAttribute(LoanConstants.ACCOUNTS_LIST));
    Assert.assertEquals(1, accountNumbers.size());
    LoanBO loan = ApplicationContextProvider.getBean(LoanBusinessService.class).findBySystemId(accountNumbers.get(0));
    Assert.assertEquals(loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString(), loan.getLoanAmount().toString());
    Assert.assertEquals(loanOffering.getDefInterestRate(), loan.getInterestRate());
    Assert.assertEquals(loanOffering.getEligibleInstallmentSameForAllLoan().getDefaultNoOfInstall(), loan.getNoOfInstallments());
    Assert.assertEquals(Short.valueOf("1"), loan.getGracePeriodDuration());
    Assert.assertEquals(Short.valueOf("1"), loan.getAccountState().getId());
    Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    loan = null;
}
Also used : SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) LoanBusinessService(org.mifos.accounts.loan.business.service.LoanBusinessService) Authentication(org.springframework.security.core.Authentication) FieldConfig(org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) SecurityContext(org.springframework.security.core.context.SecurityContext) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Example 100 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class MultipleLoanAccountsCreationActionStrutsTest method testCreateWithouSelectingClient.

@Test
public void testCreateWithouSelectingClient() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createInitialCustomers();
    LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    // loanOffering.updateLoanOfferingSameForAllLoan(loanOffering);
    LoanAmountSameForAllLoanBO eligibleLoanAmountRange = loanOffering.getEligibleLoanAmountSameForAllLoan();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "get");
    addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
    addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
    addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
    SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
    addRequestParameter("centerId", center.getCustomerId().toString());
    addRequestParameter("centerSearchId", center.getSearchId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("clientDetails[0].loanAmount", eligibleLoanAmountRange.getDefaultLoanAmount().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("stateSelected", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("method", "create");
    addRequestParameter("stateSelected", "1");
    actionPerform();
    verifyActionErrors(new String[] { LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD });
    verifyInputForward();
    TestObjectFactory.removeObject(loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

Aggregations

LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)135 MeetingBO (org.mifos.application.meeting.business.MeetingBO)44 Date (java.util.Date)37 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)26 Date (java.sql.Date)21 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 LocalDate (org.joda.time.LocalDate)17 CustomerBO (org.mifos.customers.business.CustomerBO)12 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)11 UserContext (org.mifos.security.util.UserContext)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 Money (org.mifos.framework.util.helpers.Money)8 MifosUser (org.mifos.security.MifosUser)8 BusinessRuleException (org.mifos.service.BusinessRuleException)8 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 BigDecimal (java.math.BigDecimal)6 AccountException (org.mifos.accounts.exceptions.AccountException)6 FeeBO (org.mifos.accounts.fees.business.FeeBO)6