Search in sources :

Example 6 with LoanPrdActionForm

use of org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm 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 7 with LoanPrdActionForm

use of org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm in project head by mifos.

the class LoanPrdAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) form;
    logger.debug("start get method of Loan Product Action" + loanPrdActionForm.getPrdOfferingId());
    LoanOfferingBO loanOffering = loanPrdBusinessService.getLoanOffering(loanPrdActionForm.getPrdOfferingIdValue(), getUserContext(request).getLocaleId());
    SessionUtils.setAttribute(ProductDefinitionConstants.LOANAMOUNTTYPE, loanOffering.checkLoanAmountType(), request);
    SessionUtils.setAttribute(ProductDefinitionConstants.INSTALLTYPE, loanOffering.checkNoOfInstallType(), request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loanOffering, request);
    loanPrdActionForm.clear();
    loanPrdActionForm.setPrdOfferingId(getStringValue(loanOffering.getPrdOfferingId()));
    request.getSession().setAttribute("isMultiCurrencyEnabled", AccountingRules.isMultiCurrencyEnabled());
    request.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
    setSelectedQuestionGroupsOnSession(request, loanOffering, getQuestionnaireServiceFacade(request));
    logger.debug("get method of Loan Product Action called" + loanOffering.getPrdOfferingId());
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with LoanPrdActionForm

use of org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm in project head by mifos.

the class LoanPrdAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) form;
    logger.debug("start manage of Loan Product Action " + loanPrdActionForm.getPrdOfferingId());
    Short prdOfferingId = loanPrdActionForm.getPrdOfferingIdValue();
    loanPrdActionForm.clear();
    LoanOfferingBO loanOffering = getLoanOffering(prdOfferingId);
    loadMasterData(request);
    loadSelectedFeesPenaltiesAndFunds(getFeesSelected(request, loanOffering), getFundsSelected(loanOffering), getPenaltiesSelected(loanOffering), request);
    loadStatusList(request);
    setDataIntoActionForm(loanOffering, loanPrdActionForm, request);
    setSelectedQuestionGroupsOnSession(request, loanOffering, getQuestionnaireServiceFacade(request));
    setCurrencyOnSession(request, loanOffering);
    setRepaymentIndepOfMeetingEnabledFlag(request);
    request.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
    logger.debug("manage of Loan Product Action called" + prdOfferingId);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with LoanPrdActionForm

use of org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm in project head by mifos.

the class LoanPrdAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("start create method of Loan Product Action");
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) form;
    UserContext userContext = getUserContext(request);
    Locale locale = getLocale(userContext);
    LoanOfferingBO loanOffering = new LoanOfferingBO(userContext, loanPrdActionForm.getPrdOfferingName(), loanPrdActionForm.getPrdOfferingShortName(), getProductCategory(((List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request)), loanPrdActionForm.getPrdCategoryValue()), (PrdApplicableMasterEntity) findMasterEntity(request, ProductDefinitionConstants.LOANAPPLFORLIST, loanPrdActionForm.getPrdApplicableMasterEnum().getValue()), loanPrdActionForm.getStartDateValue(locale), loanPrdActionForm.getEndDateValue(locale), loanPrdActionForm.getDescription(), (GracePeriodTypeEntity) findMasterEntity(request, ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, loanPrdActionForm.getGracePeriodTypeValue()), loanPrdActionForm.getGracePeriodDurationValue(), (InterestTypesEntity) findMasterEntity(request, ProductDefinitionConstants.INTERESTTYPESLIST, loanPrdActionForm.getInterestTypesValue()), loanPrdActionForm.getMaxInterestRateValue(), loanPrdActionForm.getMinInterestRateValue(), loanPrdActionForm.getDefInterestRateValue(), loanPrdActionForm.isLoanCounterValue(), loanPrdActionForm.isIntDedAtDisbValue(), loanPrdActionForm.isPrinDueLastInstValue(), getFundsFromList((List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request), loanPrdActionForm.getLoanOfferingFunds()), getFeeList((List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request), loanPrdActionForm.getPrdOfferinFees()), getPenaltyList((List<PenaltyBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDPENALTY, request), loanPrdActionForm.getPrdOfferinPenalties()), new MeetingBO(RecurrenceType.fromInt(loanPrdActionForm.getFreqOfInstallmentsValue()), loanPrdActionForm.getRecurAfterValue(), loanPrdActionForm.getStartDateValue(locale), MeetingType.LOAN_INSTALLMENT), findGLCodeEntity(request, ProductDefinitionConstants.LOANPRICIPALGLCODELIST, loanPrdActionForm.getPrincipalGLCode()), findGLCodeEntity(request, ProductDefinitionConstants.LOANINTERESTGLCODELIST, loanPrdActionForm.getInterestGLCode()), loanPrdActionForm, loanPrdActionForm.shouldWaiverInterest());
    loanOffering.setQuestionGroups(getQuestionGroups(request));
    loanOffering.setCurrency(getCurrency(loanPrdActionForm.getCurrencyId()));
    loanOffering.setRoundingDifferenceInFirstPayment(loanPrdActionForm.isRoundingDifferenceInFirstPayment());
    mapCashFlowDetail(loanPrdActionForm, loanOffering);
    mapVariableInstallmentDetails(loanOffering, loanPrdActionForm);
    loanOffering.setFixedRepaymentSchedule(loanPrdActionForm.isFixedRepaymentSchedule());
    loanOffering.save();
    request.setAttribute(ProductDefinitionConstants.LOANPRODUCTID, loanOffering.getPrdOfferingId());
    request.setAttribute(ProductDefinitionConstants.LOANPRDGLOBALOFFERINGNUM, loanOffering.getGlobalPrdOfferingNum());
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : Locale(java.util.Locale) LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) List(java.util.List) ArrayList(java.util.ArrayList) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

LoanPrdActionForm (org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm)9 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 Date (java.sql.Date)3 List (java.util.List)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)3 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)3 Locale (java.util.Locale)2 UserContext (org.mifos.security.util.UserContext)2 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)1 FundBO (org.mifos.accounts.fund.business.FundBO)1 LoanAmountSameForAllLoanBO (org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)1 NoOfInstallSameForAllLoanBO (org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)1 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)1 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1