Search in sources :

Example 1 with LoanAmountSameForAllLoanBO

use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO 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 LoanAmountSameForAllLoanBO

use of org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO 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 LoanAmountSameForAllLoanBO

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

the class LoanPrdActionStrutsTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    FeeBO fee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100.0", RecurrenceType.MONTHLY, (short) 1);
    LoanOfferingBO product = createLoanOfferingBO("Loan Offering", "LOAN");
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("prdOfferingId", product.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "editPreview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("prdOfferingName", "Loan Product");
    addRequestParameter("prdOfferingShortName", "LOAP");
    addRequestParameter("prdCategory", "1");
    addRequestParameter("startDate", offSetCurrentDate(0, userContext.getPreferredLocale()));
    addRequestParameter("endDate", offSetCurrentDate(1, userContext.getPreferredLocale()));
    addRequestParameter("prdApplicableMaster", "1");
    addRequestParameter("minLoanAmount", "2000");
    addRequestParameter("maxLoanAmount", "11000");
    addRequestParameter("defaultLoanAmount", "5000");
    addRequestParameter("interestTypes", "1");
    addRequestParameter("maxInterestRate", "12");
    addRequestParameter("minInterestRate", "1");
    addRequestParameter("defInterestRate", "4");
    addRequestParameter("freqOfInstallments", "2");
    addRequestParameter("prdOfferinFees", new String[] { fee.getFeeId().toString() });
    addRequestParameter("loanOfferingFunds", new String[] { "1" });
    addRequestParameter("recurAfter", "1");
    addRequestParameter("maxNoInstallments", "14");
    addRequestParameter("minNoInstallments", "2");
    addRequestParameter("defNoInstallments", "11");
    addRequestParameter("intDedDisbursementFlag", "1");
    addRequestParameter("prdStatus", "2");
    addRequestParameter("loanAmtCalcType", "1");
    addRequestParameter("calcInstallmentType", "1");
    actionPerform();
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "update");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.update_success.toString());
    StaticHibernateUtil.flushSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Product", product.getPrdOfferingName());
    Assert.assertEquals("LOAP", product.getPrdOfferingShortName());
    Assert.assertEquals(PrdStatus.SAVINGS_ACTIVE, product.getStatus());
    for (LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO : product.getLoanAmountSameForAllLoan()) {
        Assert.assertEquals(new Double("11000"), loanAmountSameForAllLoanBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountSameForAllLoanBO.getMinLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountSameForAllLoanBO.getDefaultLoanAmount());
    }
    Assert.assertEquals(Short.valueOf("1"), product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter());
    Assert.assertEquals(Short.valueOf("2"), product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
    Assert.assertEquals(1, product.getLoanOfferingFees().size());
    Assert.assertNull(((FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER)).getFlow(flowKey));
    TestObjectFactory.removeObject(product);
    fee = null;
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

Example 4 with LoanAmountSameForAllLoanBO

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

the class LoanAccountActionFormTest method testShouldValidateIfIndividualLoanAmountIsNotZero.

public void testShouldValidateIfIndividualLoanAmountIsNotZero() throws Exception {
    AmountRange loanAmountRange = new LoanAmountSameForAllLoanBO();
    loanAmountRange.setMinLoanAmount(100d);
    loanAmountRange.setMaxLoanAmount(1000d);
    form.setClientDetails(asList(LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_100));
    form.setLoanAmountRange(loanAmountRange);
    form.setClients(asList("1"));
    form.validateSumOfTheAmountsSpecified(actionErrors);
    Assert.assertEquals(0, actionErrors.size());
}
Also used : AmountRange(org.mifos.accounts.productdefinition.business.AmountRange) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)

Example 5 with LoanAmountSameForAllLoanBO

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

the class LoanAccountActionFormTest method testShouldNotErrorIfAmountBetweenSpecifiedValues.

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

Aggregations

LoanAmountSameForAllLoanBO (org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)10 Test (org.junit.Test)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)4 NoOfInstallSameForAllLoanBO (org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 LoanAmountFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLastLoanAmountBO)2 LoanAmountFromLoanCycleBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLoanCycleBO)2 HashSet (java.util.HashSet)1 List (java.util.List)1 ActionMessage (org.apache.struts.action.ActionMessage)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 AmountRange (org.mifos.accounts.productdefinition.business.AmountRange)1 CashFlowDetail (org.mifos.accounts.productdefinition.business.CashFlowDetail)1 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)1 NoOfInstallFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLastLoanAmountBO)1 NoOfInstallFromLoanCycleBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLoanCycleBO)1 PrdOfferingMeetingEntity (org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity)1 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)1