Search in sources :

Example 6 with LoanProductBuilder

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

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct.

@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct() throws Exception {
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct1 = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").withoutLoanAmountSameForAllLoans().buildForUnitTests();
    LoanOfferingBO loanProduct2 = new LoanProductBuilder().withGlobalProductNumber("xxxx-222").buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(true);
    when(loanAccount.getLoanOffering()).thenReturn(loanProduct2);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct1);
    assertThat(isDisbursalPrevented, is(false));
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 7 with LoanProductBuilder

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

the class LoanAdjustmentsIntegrationTest method createLoan.

private LoanBO createLoan() throws Exception {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    LoanOfferingBO loanOffering = new LoanProductBuilder().withName("Adjust Loan Product").withMeeting(weeklyMeeting).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(loanOffering);
    AmountFeeBO periodicFee = new FeeBuilder().appliesToLoans().periodic().withFeeAmount("10.0").withName("Periodic Fee").with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(periodicFee);
    BigDecimal loanAmount = BigDecimal.valueOf(Double.valueOf("1000.0"));
    BigDecimal minAllowedLoanAmount = loanAmount;
    BigDecimal maxAllowedLoanAmount = loanAmount;
    Double interestRate = loanOffering.getDefInterestRate();
    LocalDate disbursementDate = new LocalDate();
    int numberOfInstallments = 10;
    int minAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
    int maxAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
    int graceDuration = 0;
    Integer sourceOfFundId = null;
    Integer loanPurposeId = null;
    Integer collateralTypeId = null;
    String collateralNotes = null;
    String externalId = null;
    boolean repaymentScheduleIndependentOfCustomerMeeting = false;
    RecurringSchedule recurringSchedule = null;
    List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
    accountFees.add(new CreateAccountFeeDto(periodicFee.getFeeId().intValue(), periodicFee.getFeeAmount().toString()));
    CreateLoanAccount createLoanAccount = new CreateLoanAccount(client.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
    return IntegrationTestObjectMother.createClientLoan(createLoanAccount);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) BigDecimal(java.math.BigDecimal) FeeBuilder(org.mifos.domain.builders.FeeBuilder) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 8 with LoanProductBuilder

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

the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoQuestionGroupDetails.

@Test
public void shouldDoFilterForNoQuestionGroupDetails() {
    QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
    LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
    loanOfferingBO.setQuestionGroups(getQustionGroups(2, 4));
    questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
    List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(null, null);
    assertThat(filteredQuestionGroupDetails, is(nullValue()));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Test(org.junit.Test)

Example 9 with LoanProductBuilder

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

the class LoanPrdActionTest method shouldSetSelectedQuestionGroupsOnSession.

@Test
public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", false));
    when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(1)).thenReturn(questionGroupDetails.get(0));
    when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(2)).thenReturn(questionGroupDetails.get(1));
    when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(3)).thenReturn(questionGroupDetails.get(2));
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    Flow flow = new Flow();
    when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
    loanOfferingBO.setQuestionGroups(getQustionGroups(1, 2, 3));
    loanPrdAction.setSelectedQuestionGroupsOnSession(request, loanOfferingBO, questionnaireServiceFacade);
    List<QuestionGroupDetail> questionGroupDetailList = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
    assertThat(questionGroupDetailList, is(notNullValue()));
    assertThat(questionGroupDetailList.size(), is(2));
    assertQuestionGroup(questionGroupDetailList.get(0), 1, "QG1");
    assertQuestionGroup(questionGroupDetailList.get(1), 2, "QG2");
    verify(questionnaireServiceFacade, times(3)).getQuestionGroupDetailForLoanPrd(anyInt());
    verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
    verify(request, times(1)).getSession();
    verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 10 with LoanProductBuilder

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

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans.

@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans() throws Exception {
    // Same for all loans is the default in the LoanProductBuilder
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct = new LoanProductBuilder().active().buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(true);
    when(loanAccount.getLoanOffering()).thenReturn(loanProduct);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct);
    assertThat(isDisbursalPrevented, is(false));
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)13 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)11 Test (org.junit.Test)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)7 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 CenterBuilder (org.mifos.domain.builders.CenterBuilder)3 GroupBuilder (org.mifos.domain.builders.GroupBuilder)3 DateTime (org.joda.time.DateTime)2 Before (org.junit.Before)2 LoanAccountBuilder (org.mifos.domain.builders.LoanAccountBuilder)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Date (java.util.Date)1 List (java.util.List)1 LocalDate (org.joda.time.LocalDate)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 QuestionGroupReference (org.mifos.accounts.productdefinition.business.QuestionGroupReference)1