Search in sources :

Example 41 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class LoanPrdAction method setSelectedQuestionGroupsOnSession.

// Intentionally made public to aid testing !!!
public void setSelectedQuestionGroupsOnSession(HttpServletRequest request, LoanOfferingBO loanOffering, QuestionnaireServiceFacade questionnaireServiceFacade) throws PageExpiredException {
    Set<QuestionGroupReference> questionGroupReferences = loanOffering.getQuestionGroups();
    if (questionnaireServiceFacade != null && CollectionUtils.isNotEmpty(questionGroupReferences)) {
        List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
        for (QuestionGroupReference questionGroupReference : questionGroupReferences) {
            Integer questionGroupId = questionGroupReference.getQuestionGroupId();
            QuestionGroupDetail questionGroupDetail = questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(questionGroupId);
            if (questionGroupDetail != null && questionGroupDetail.isActive()) {
                questionGroupDetails.add(questionGroupDetail);
            }
        }
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.SELECTEDQGLIST, questionGroupDetails, request);
    }
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList)

Example 42 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class ImportLoansSavingsFacadeWebTier method saveLoans.

@Override
public ParsedLoansDto saveLoans(ParsedLoansDto parsedLoansDto) {
    List<CreateAccountFeeDto> defaultAccountFees = new ArrayList<CreateAccountFeeDto>();
    List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
    List<CreateAccountPenaltyDto> defaultPenalties = new ArrayList<CreateAccountPenaltyDto>();
    for (ImportedLoanDetail detail : parsedLoansDto.getSuccessfullyParsedRows()) {
        LoanCreationLoanDetailsDto lcldd = loanAccountServiceFacade.retrieveLoanDetailsForLoanAccountCreation(detail.getCustomerId(), detail.getPrdOfferingId(), false);
        RecurringSchedule recurringSchedule = null;
        MeetingDto meetingDto = lcldd.getCustomerMeetingDetail();
        int meetingEvery = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getEvery() : meetingDto.getMeetingDetailsDto().getEvery();
        int loanRecurrenceTypeId = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceTypeId() : meetingDto.getMeetingDetailsDto().getRecurrenceTypeId();
        if (loanRecurrenceTypeId == 1) {
            recurringSchedule = new WeeklySchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
        } else if (loanRecurrenceTypeId == 2) {
            if (meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth().equals(0)) {
                recurringSchedule = new MonthlyOnDayOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayNumber());
            } else {
                recurringSchedule = new MonthlyOnWeekOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth(), meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
            }
        } else if (loanRecurrenceTypeId == 3) {
            recurringSchedule = new DailySchedule(meetingEvery);
        }
        CreateLoanAccount cla = new CreateLoanAccount(detail.getCustomerId(), new Integer(detail.getPrdOfferingId()), new Integer(detail.getStatus()), detail.getLoanAmount(), lcldd.getMinLoanAmount(), lcldd.getMaxLoanAmount(), detail.getInterestRate().doubleValue(), new LocalDate(detail.getDisbursalDate().getTime()), null, detail.getNumberOfInstallments(), lcldd.getMinNumberOfInstallments(), lcldd.getMaxNumberOfInstallments(), detail.getGracePeriod(), detail.getSourceOfFundId(), detail.getLoanPurposeId(), detail.getCollateralTypeId(), detail.getCollateralNotes(), detail.getExternalId(), lcldd.isRepaymentIndependentOfMeetingEnabled(), recurringSchedule, defaultAccountFees, defaultPenalties);
        cla.setPredefinedAccountNumber(detail.getAccountNumber());
        cla.setFlagId(detail.getFlag());
        this.loanAccountServiceFacade.createLoan(cla, questionGroupDetails, null);
    }
    return null;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) WeeklySchedule(org.mifos.clientportfolio.loan.service.WeeklySchedule) LocalDate(org.joda.time.LocalDate) MeetingDto(org.mifos.dto.domain.MeetingDto) DailySchedule(org.mifos.clientportfolio.loan.service.DailySchedule) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) MonthlyOnDayOfMonthSchedule(org.mifos.clientportfolio.loan.service.MonthlyOnDayOfMonthSchedule) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) LoanCreationLoanDetailsDto(org.mifos.dto.screen.LoanCreationLoanDetailsDto) MonthlyOnWeekOfMonthSchedule(org.mifos.clientportfolio.loan.service.MonthlyOnWeekOfMonthSchedule) ImportedLoanDetail(org.mifos.dto.domain.ImportedLoanDetail)

Example 43 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class LoanAccountActionTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(String title, List<String> answerChoices) {
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail();
    questionGroupDetail.setTitle(title);
    questionGroupDetail.setId(123);
    questionGroupDetail.setSectionDetails(asList(getSectionDetail("Section1", "Question1", answerChoices)));
    return questionGroupDetail;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail)

Example 44 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail 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 45 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class QuestionnaireServiceImpl method removeInActiveSectionsAndQuestions.

private void removeInActiveSectionsAndQuestions(List<QuestionGroupDetail> questionGroupDetails) {
    for (Iterator<QuestionGroupDetail> questionGroupDetailIterator = questionGroupDetails.iterator(); questionGroupDetailIterator.hasNext(); ) {
        QuestionGroupDetail questionGroupDetail = questionGroupDetailIterator.next();
        removeInActiveSectionsAndQuestions(questionGroupDetail);
        if (questionGroupDetail.hasNoActiveSectionsAndQuestions()) {
            questionGroupDetailIterator.remove();
        }
    }
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail)

Aggregations

QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)74 Test (org.junit.Test)43 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)25 ArrayList (java.util.ArrayList)23 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)15 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)11 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)11 List (java.util.List)8 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)8 ValidationException (org.mifos.platform.validations.ValidationException)7 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)6 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)6 SystemException (org.mifos.framework.exceptions.SystemException)5 Arrays.asList (java.util.Arrays.asList)4 QuestionGroupReference (org.mifos.accounts.productdefinition.business.QuestionGroupReference)4 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)4 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)4 Transactional (org.springframework.transaction.annotation.Transactional)4 HashMap (java.util.HashMap)3