Search in sources :

Example 1 with NoOfInstallSameForAllLoanBO

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

the class LoanPrdAction method setDataIntoActionForm.

private void setDataIntoActionForm(LoanOfferingBO loanProduct, LoanPrdActionForm loanPrdActionForm, HttpServletRequest request) throws Exception {
    logger.debug("start setDataIntoActionForm method of Loan Product Action ");
    loanPrdActionForm.setPrdOfferingId(getStringValue(loanProduct.getPrdOfferingId()));
    loanPrdActionForm.setPrdOfferingName(loanProduct.getPrdOfferingName());
    loanPrdActionForm.setPrdOfferingShortName(loanProduct.getPrdOfferingShortName());
    loanPrdActionForm.setPrdCategory(getStringValue(loanProduct.getPrdCategory().getProductCategoryID()));
    loanPrdActionForm.setPrdStatus(getStringValue(loanProduct.getStatus().getValue()));
    loanPrdActionForm.setPrdApplicableMaster(loanProduct.getPrdApplicableMasterEnum());
    loanPrdActionForm.setStartDate(DateUtils.getUserLocaleDate(getUserContext(request).getPreferredLocale(), DateUtils.toDatabaseFormat(loanProduct.getStartDate())));
    loanPrdActionForm.setEndDate(loanProduct.getEndDate() != null ? DateUtils.getUserLocaleDate(getUserContext(request).getPreferredLocale(), DateUtils.toDatabaseFormat(loanProduct.getEndDate())) : null);
    loanPrdActionForm.setDescription(loanProduct.getDescription());
    loanPrdActionForm.setGracePeriodType(getStringValue(loanProduct.getGracePeriodType().getId()));
    loanPrdActionForm.setGracePeriodDuration(getStringValue(loanProduct.getGracePeriodDuration()));
    loanPrdActionForm.setInterestTypes(getStringValue(loanProduct.getInterestTypes().getId()));
    loanPrdActionForm.setMaxInterestRate(getDoubleStringForInterest(loanProduct.getMaxInterestRate()));
    loanPrdActionForm.setMinInterestRate(getDoubleStringForInterest(loanProduct.getMinInterestRate()));
    loanPrdActionForm.setDefInterestRate(getDoubleStringForInterest(loanProduct.getDefInterestRate()));
    loanPrdActionForm.setIntDedDisbursementFlag(getStringValue(loanProduct.isIntDedDisbursement()));
    loanPrdActionForm.setPrinDueLastInstFlag(getStringValue(loanProduct.isPrinDueLastInst()));
    loanPrdActionForm.setLoanCounter(getStringValue(loanProduct.isIncludeInLoanCounter()));
    loanPrdActionForm.setWaiverInterest(getStringValue(loanProduct.isInterestWaived()));
    loanPrdActionForm.setRecurAfter(getStringValue(loanProduct.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter()));
    loanPrdActionForm.setFreqOfInstallments(getStringValue(loanProduct.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId()));
    loanPrdActionForm.setPrincipalGLCode(getStringValue(loanProduct.getPrincipalGLcode().getGlcodeId()));
    loanPrdActionForm.setInterestGLCode(getStringValue(loanProduct.getInterestGLcode().getGlcodeId()));
    setVariableInstallmentDetailsOnLoanProductForm(loanPrdActionForm, loanProduct);
    loanPrdActionForm.setIsFixedRepaymentSchedule(loanProduct.isFixedRepaymentSchedule());
    loanPrdActionForm.setIsRoundingDifferenceInFirstPayment(loanProduct.isRoundingDifferenceInFirstPayment());
    loanPrdActionForm.setCashFlowValidation(loanProduct.isCashFlowCheckEnabled());
    CashFlowDetail cashFlowDetail = loanProduct.getCashFlowDetail();
    if (cashFlowDetail != null) {
        Double cashFlowThreshold = cashFlowDetail.getCashFlowThreshold();
        if (cashFlowThreshold != null) {
            loanPrdActionForm.setCashFlowThreshold(String.valueOf(cashFlowThreshold));
        }
        Double indebtednessRatio = cashFlowDetail.getIndebtednessRatio();
        if (indebtednessRatio != null) {
            loanPrdActionForm.setIndebtednessRatio(String.valueOf(indebtednessRatio));
        }
        Double repaymentCapacity = cashFlowDetail.getRepaymentCapacity();
        if (repaymentCapacity != null) {
            loanPrdActionForm.setRepaymentCapacity(String.valueOf(repaymentCapacity));
        }
    }
    if (loanProduct.isLoanAmountTypeSameForAllLoan()) {
        loanPrdActionForm.setLoanAmtCalcType(getStringValue(ProductDefinitionConstants.LOANAMOUNTSAMEFORALLLOAN));
        Iterator<LoanAmountSameForAllLoanBO> loanAmountSameForAllItr = loanProduct.getLoanAmountSameForAllLoan().iterator();
        while (loanAmountSameForAllItr.hasNext()) {
            LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO = loanAmountSameForAllItr.next();
            loanPrdActionForm.setMaxLoanAmount(getDoubleStringForMoney(loanAmountSameForAllLoanBO.getMaxLoanAmount()));
            loanPrdActionForm.setMinLoanAmount(getDoubleStringForMoney(loanAmountSameForAllLoanBO.getMinLoanAmount()));
            loanPrdActionForm.setDefaultLoanAmount(getDoubleStringForMoney(loanAmountSameForAllLoanBO.getDefaultLoanAmount()));
        }
    }
    if (loanProduct.isLoanAmountTypeAsOfLastLoanAmount()) {
        loanPrdActionForm.setLoanAmtCalcType(getStringValue(ProductDefinitionConstants.LOANAMOUNTFROMLASTLOAN));
        Iterator<LoanAmountFromLastLoanAmountBO> loanAmountFromLastLoanAmountItr = loanProduct.getLoanAmountFromLastLoan().iterator();
        while (loanAmountFromLastLoanAmountItr.hasNext()) {
            LoanAmountFromLastLoanAmountBO loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt1(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt1(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt1(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt1(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt1(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
            loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt2(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt2(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt2(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt2(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt2(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
            loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt3(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt3(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt3(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt3(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt3(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
            loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt4(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt4(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt4(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt4(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt4(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
            loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt5(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt5(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt5(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt5(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt5(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
            loanAmountFromLastLoanAmountBO = loanAmountFromLastLoanAmountItr.next();
            loanPrdActionForm.setLastLoanMinLoanAmt6(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMinLoanAmount()));
            loanPrdActionForm.setLastLoanMaxLoanAmt6(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getMaxLoanAmount()));
            loanPrdActionForm.setLastLoanDefaultLoanAmt6(getDoubleStringForMoney(loanAmountFromLastLoanAmountBO.getDefaultLoanAmount()));
            loanPrdActionForm.setStartRangeLoanAmt6(loanAmountFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndRangeLoanAmt6(loanAmountFromLastLoanAmountBO.getEndRange().intValue());
        }
    }
    if (loanProduct.isLoanAmountTypeFromLoanCycle()) {
        loanPrdActionForm.setLoanAmtCalcType(getStringValue(ProductDefinitionConstants.LOANAMOUNTFROMLOANCYCLE));
        Iterator<LoanAmountFromLoanCycleBO> loanAmountFromLoanCycleItr = loanProduct.getLoanAmountFromLoanCycle().iterator();
        while (loanAmountFromLoanCycleItr.hasNext()) {
            LoanAmountFromLoanCycleBO loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt1(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt1(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt1(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
            loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt2(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt2(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt2(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
            loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt3(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt3(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt3(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
            loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt4(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt4(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt4(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
            loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt5(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt5(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt5(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
            loanAmountFromLoanCycleBO = loanAmountFromLoanCycleItr.next();
            loanPrdActionForm.setCycleLoanMinLoanAmt6(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMinLoanAmount()));
            loanPrdActionForm.setCycleLoanMaxLoanAmt6(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getMaxLoanAmount()));
            loanPrdActionForm.setCycleLoanDefaultLoanAmt6(getDoubleStringForMoney(loanAmountFromLoanCycleBO.getDefaultLoanAmount()));
        }
    }
    if (loanProduct.isNoOfInstallTypeSameForAllLoan()) {
        loanPrdActionForm.setCalcInstallmentType(getStringValue(ProductDefinitionConstants.NOOFINSTALLSAMEFORALLLOAN));
        Iterator<NoOfInstallSameForAllLoanBO> noOfInstallSameForAllLoanItr = loanProduct.getNoOfInstallSameForAllLoan().iterator();
        while (noOfInstallSameForAllLoanItr.hasNext()) {
            NoOfInstallSameForAllLoanBO noOfInstallSameForAllLoanBO = noOfInstallSameForAllLoanItr.next();
            loanPrdActionForm.setMaxNoInstallments(getStringValue(noOfInstallSameForAllLoanBO.getMaxNoOfInstall()));
            loanPrdActionForm.setMinNoInstallments(getStringValue(noOfInstallSameForAllLoanBO.getMinNoOfInstall()));
            loanPrdActionForm.setDefNoInstallments(getStringValue(noOfInstallSameForAllLoanBO.getDefaultNoOfInstall()));
        }
    }
    if (loanProduct.isNoOfInstallTypeFromLastLoan()) {
        loanPrdActionForm.setCalcInstallmentType(getStringValue(ProductDefinitionConstants.NOOFINSTALLFROMLASTLOAN));
        Iterator<NoOfInstallFromLastLoanAmountBO> noOfInstallFromLastAmountItr = loanProduct.getNoOfInstallFromLastLoan().iterator();
        while (noOfInstallFromLastAmountItr.hasNext()) {
            NoOfInstallFromLastLoanAmountBO noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment1(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment1(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment1(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange1(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange1(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
            noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment2(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment2(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment2(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange2(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange2(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
            noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment3(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment3(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment3(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange3(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange3(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
            noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment4(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment4(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment4(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange4(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange4(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
            noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment5(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment5(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment5(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange5(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange5(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
            noOfInstallFromLastLoanAmountBO = noOfInstallFromLastAmountItr.next();
            loanPrdActionForm.setMinLoanInstallment6(getStringValue(noOfInstallFromLastLoanAmountBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxLoanInstallment6(getStringValue(noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefLoanInstallment6(getStringValue(noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall()));
            loanPrdActionForm.setStartInstallmentRange6(noOfInstallFromLastLoanAmountBO.getStartRange().intValue());
            loanPrdActionForm.setEndInstallmentRange6(noOfInstallFromLastLoanAmountBO.getEndRange().intValue());
        }
    }
    if (loanProduct.isNoOfInstallTypeFromLoanCycle()) {
        loanPrdActionForm.setCalcInstallmentType(getStringValue(ProductDefinitionConstants.NOOFINSTALLFROMLOANCYCLLE));
        Iterator<NoOfInstallFromLoanCycleBO> noOfInstallFromLoanCycleItr = loanProduct.getNoOfInstallFromLoanCycle().iterator();
        while (noOfInstallFromLoanCycleItr.hasNext()) {
            NoOfInstallFromLoanCycleBO noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment1(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment1(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment1(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
            noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment2(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment2(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment2(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
            noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment3(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment3(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment3(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
            noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment4(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment4(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment4(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
            noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment5(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment5(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment5(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
            noOfInstallFromLoanCycleBO = noOfInstallFromLoanCycleItr.next();
            loanPrdActionForm.setMinCycleInstallment6(getStringValue(noOfInstallFromLoanCycleBO.getMinNoOfInstall()));
            loanPrdActionForm.setMaxCycleInstallment6(getStringValue(noOfInstallFromLoanCycleBO.getMaxNoOfInstall()));
            loanPrdActionForm.setDefCycleInstallment6(getStringValue(noOfInstallFromLoanCycleBO.getDefaultNoOfInstall()));
        }
    }
    SessionUtils.setAttribute(ProductDefinitionConstants.LOANPRDSTARTDATE, loanProduct.getStartDate(), request);
    logger.debug("setDataIntoActionForm method of Loan Product Action called");
}
Also used : CashFlowDetail(org.mifos.accounts.productdefinition.business.CashFlowDetail) NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) LoanAmountFromLastLoanAmountBO(org.mifos.accounts.productdefinition.business.LoanAmountFromLastLoanAmountBO) NoOfInstallFromLastLoanAmountBO(org.mifos.accounts.productdefinition.business.NoOfInstallFromLastLoanAmountBO) LoanAmountFromLoanCycleBO(org.mifos.accounts.productdefinition.business.LoanAmountFromLoanCycleBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) NoOfInstallFromLoanCycleBO(org.mifos.accounts.productdefinition.business.NoOfInstallFromLoanCycleBO)

Example 2 with NoOfInstallSameForAllLoanBO

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

the class LoanPrdActionStrutsTest method testManage.

@Test
public void testManage() throws Exception {
    loanOffering = createLoanOfferingBO("Loan Offering", "LOAN");
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    performNoErrors();
    verifyForward(ActionForwards.manage_success.toString());
    List<ProductCategoryBO> productCategories = (List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request);
    Assert.assertEquals("The size of master data for categories", 1, productCategories.size());
    for (ProductCategoryBO productCategory : productCategories) {
        Assert.assertNotNull(productCategory.getProductType());
    }
    Assert.assertEquals("The size of applicable list", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANAPPLFORLIST, request)).size());
    Assert.assertEquals("The size of grace period types list", 3, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, request)).size());
    Assert.assertEquals("The size of interest types list", 4, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.INTERESTTYPESLIST, request)).size());
    Assert.assertEquals("The size of applicable list", 10, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRICIPALGLCODELIST, request)).size());
    Assert.assertEquals("The size of applicable list", 3, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANINTERESTGLCODELIST, request)).size());
    List<FundBO> funds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request);
    Assert.assertNotNull(funds);
    List<FeeDto> fees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANFEESLIST, request);
    Assert.assertNull(fees);
    List<FeeBO> productFees = (List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request);
    Assert.assertNotNull(productFees);
    List<FeeDto> selectedFees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEESELECTEDLIST, request);
    Assert.assertNotNull(selectedFees);
    List<FundBO> selectedFunds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFUNDSELECTEDLIST, request);
    Assert.assertNotNull(selectedFunds);
    Assert.assertEquals("The size of applicable status list", 2, ((List<PrdStatusEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDSTATUSLIST, request)).size());
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) request.getSession().getAttribute(ProductDefinitionConstants.LOANPRODUCTACTIONFORM);
    Assert.assertNotNull(loanPrdActionForm);
    Assert.assertEquals(loanOffering.getPrdOfferingId().toString(), loanPrdActionForm.getPrdOfferingId());
    Assert.assertEquals(loanOffering.getPrdOfferingName(), loanPrdActionForm.getPrdOfferingName());
    Assert.assertEquals(loanOffering.getPrdOfferingShortName(), loanPrdActionForm.getPrdOfferingShortName());
    Assert.assertEquals(loanOffering.getPrdCategory().getProductCategoryID().toString(), loanPrdActionForm.getPrdCategory());
    Assert.assertEquals(loanOffering.getStatus().getValue().toString(), loanPrdActionForm.getPrdStatus());
    Assert.assertEquals(loanOffering.getPrdApplicableMasterEnum(), loanPrdActionForm.getPrdApplicableMasterEnum());
    Assert.assertEquals(DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loanOffering.getStartDate())), loanPrdActionForm.getStartDate());
    if (loanOffering.getEndDate() != null) {
        Assert.assertEquals(DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loanOffering.getEndDate())), loanPrdActionForm.getEndDate());
    } else {
        Assert.assertNull(loanPrdActionForm.getEndDate());
    }
    Assert.assertEquals(loanOffering.getDescription(), loanPrdActionForm.getDescription());
    Assert.assertEquals(loanOffering.getGracePeriodType().getId().toString(), loanPrdActionForm.getGracePeriodType());
    Assert.assertEquals(loanOffering.getGracePeriodDuration().toString(), loanPrdActionForm.getGracePeriodDuration());
    Assert.assertEquals(loanOffering.getInterestTypes().getId().toString(), loanPrdActionForm.getInterestTypes());
    Set<LoanAmountSameForAllLoanBO> loanAmountSameForAllLoan = loanOffering.getLoanAmountSameForAllLoan();
    Assert.assertNotNull(loanAmountSameForAllLoan);
    Set<NoOfInstallSameForAllLoanBO> noOfInstallSameForAllLoan = loanOffering.getNoOfInstallSameForAllLoan();
    Assert.assertNotNull(noOfInstallSameForAllLoan);
    Assert.assertEquals(loanOffering.getMaxInterestRate().toString(), loanPrdActionForm.getMaxInterestRate());
    Assert.assertEquals(loanOffering.getMinInterestRate().toString(), loanPrdActionForm.getMinInterestRate());
    Assert.assertEquals(loanOffering.getDefInterestRate().toString(), loanPrdActionForm.getDefInterestRate());
    Assert.assertEquals(loanOffering.isIntDedDisbursement(), loanPrdActionForm.isIntDedAtDisbValue());
    Assert.assertEquals(loanOffering.isPrinDueLastInst(), loanPrdActionForm.isPrinDueLastInstValue());
    Assert.assertEquals(loanOffering.isIncludeInLoanCounter(), loanPrdActionForm.isLoanCounterValue());
    Assert.assertEquals(loanOffering.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString(), loanPrdActionForm.getRecurAfter());
    Assert.assertEquals(loanOffering.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId().toString(), loanPrdActionForm.getFreqOfInstallments());
    Assert.assertEquals(loanOffering.getPrincipalGLcode().getGlcodeId().toString(), loanPrdActionForm.getPrincipalGLCode());
    Assert.assertEquals(loanOffering.getInterestGLcode().getGlcodeId().toString(), loanPrdActionForm.getInterestGLCode());
    Assert.assertEquals(loanOffering.getLoanOfferingFees().size(), (selectedFees).size());
    Assert.assertEquals(loanOffering.getLoanOfferingFunds().size(), (selectedFunds).size());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) FeeDto(org.mifos.accounts.fees.business.FeeDto) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) List(java.util.List) FeeBO(org.mifos.accounts.fees.business.FeeBO) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

Example 3 with NoOfInstallSameForAllLoanBO

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

the class LoanAccountActionFormTest method testShouldNotErrorIfInstallmentBetweenSpecifiedValues.

public void testShouldNotErrorIfInstallmentBetweenSpecifiedValues() throws Exception {
    new LoanAccountActionForm().checkForMinMax(actionErrors, "2", new NoOfInstallSameForAllLoanBO((short) 1, (short) 3, (short) 2, null), INTEREST_ERROR_KEY);
    Assert.assertEquals(0, actionErrors.size());
}
Also used : NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)

Example 4 with NoOfInstallSameForAllLoanBO

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

the class LoanAccountActionFormTest method assertForInterestError.

private void assertForInterestError(String inputValue) {
    new LoanAccountActionForm().checkForMinMax(actionErrors, inputValue, new NoOfInstallSameForAllLoanBO((short) 1, (short) 3, (short) 2, null), INTEREST_ERROR_KEY);
    Assert.assertEquals(1, actionErrors.size());
    ActionMessage message = (ActionMessage) actionErrors.get(INTEREST_ERROR_KEY).next();
    Assert.assertNotNull(message);
    Assert.assertEquals(LoanExceptionConstants.INVALIDMINMAX, message.getKey());
}
Also used : NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) ActionMessage(org.apache.struts.action.ActionMessage)

Example 5 with NoOfInstallSameForAllLoanBO

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

the class LoanProductCaluclationTypeAssembler method assembleLoanInstallmentCalculationFromDto.

public LoanInstallmentCalculation assembleLoanInstallmentCalculationFromDto(LoanAmountDetailsDto installmentCalculationDetails) {
    NoOfInstallSameForAllLoanBO sameForAll = null;
    Set<NoOfInstallFromLastLoanAmountBO> fromLastLoan = new HashSet<NoOfInstallFromLastLoanAmountBO>();
    Set<NoOfInstallFromLoanCycleBO> fromLoanCycle = new HashSet<NoOfInstallFromLoanCycleBO>();
    LoanProductCalculationType installmentCalculation = LoanProductCalculationType.fromInt(installmentCalculationDetails.getCalculationType());
    switch(installmentCalculation) {
        case SAME_FOR_ALL_LOANS:
            sameForAll = new NoOfInstallSameForAllLoanBO(installmentCalculationDetails.getSameForAllLoanRange().getMin().shortValue(), installmentCalculationDetails.getSameForAllLoanRange().getMax().shortValue(), installmentCalculationDetails.getSameForAllLoanRange().getTheDefault().shortValue(), null);
            break;
        case BY_LAST_LOAN:
            List<LowerUpperMinMaxDefaultDto> byLastAmount = installmentCalculationDetails.getByLastLoanAmountList();
            for (LowerUpperMinMaxDefaultDto bean : byLastAmount) {
                fromLastLoan.add(new NoOfInstallFromLastLoanAmountBO(bean.getMin().shortValue(), bean.getMax().shortValue(), bean.getTheDefault().shortValue(), bean.getLower().doubleValue(), bean.getUpper().doubleValue(), null));
            }
            break;
        case BY_LOAN_CYCLE:
            List<MinMaxDefaultDto> byCycle = installmentCalculationDetails.getByLoanCycleList();
            Short rangeIndex = Short.valueOf("0");
            for (MinMaxDefaultDto bean : byCycle) {
                fromLoanCycle.add(new NoOfInstallFromLoanCycleBO(bean.getMin().shortValue(), bean.getMax().shortValue(), bean.getTheDefault().shortValue(), rangeIndex, null));
                rangeIndex++;
            }
            break;
        default:
            break;
    }
    return new LoanInstallmentCalculation(sameForAll, fromLastLoan, fromLoanCycle);
}
Also used : NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) NoOfInstallFromLastLoanAmountBO(org.mifos.accounts.productdefinition.business.NoOfInstallFromLastLoanAmountBO) NoOfInstallFromLoanCycleBO(org.mifos.accounts.productdefinition.business.NoOfInstallFromLoanCycleBO) HashSet(java.util.HashSet)

Aggregations

NoOfInstallSameForAllLoanBO (org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)7 LoanAmountSameForAllLoanBO (org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)4 Test (org.junit.Test)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 NoOfInstallFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLastLoanAmountBO)2 NoOfInstallFromLoanCycleBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLoanCycleBO)2 HashSet (java.util.HashSet)1 List (java.util.List)1 ActionMessage (org.apache.struts.action.ActionMessage)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)1 FundBO (org.mifos.accounts.fund.business.FundBO)1 CashFlowDetail (org.mifos.accounts.productdefinition.business.CashFlowDetail)1 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)1 LoanAmountFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLastLoanAmountBO)1 LoanAmountFromLoanCycleBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLoanCycleBO)1 PrdOfferingMeetingEntity (org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity)1 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)1 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)1