Search in sources :

Example 6 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)

Example 7 with NoOfInstallSameForAllLoanBO

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

the class LoanPrdActionStrutsTest method testGet.

@Test
public void testGet() throws PageExpiredException {
    loanOffering = createLoanOfferingBO("Loan Offering", "LOAN");
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "get");
    addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.get_success.toString());
    LoanOfferingBO loanOffering1 = (LoanOfferingBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    loanOffering1 = (LoanOfferingBO) StaticHibernateUtil.getSessionTL().get(LoanOfferingBO.class, loanOffering1.getPrdOfferingId());
    // TODO: the need to pass a locale id in to the getName methods below
    // points out something that may be a bug which will show up elsewhere.
    // In these cases, an object is loaded into the http session which is
    // associated with a given Hibernate session. When it is loaded, somehow
    // it seems to have the locale set (in MasterDataEntity). However the
    // locale is not persisted. When the object is accessed after the
    // Hibernate
    // session has been closed, then it needs to be reloaded or reattached
    // to the session. But in reloaded, the locale that has been set is
    // lost.
    Assert.assertNotNull(loanOffering1.getPrdOfferingId());
    Assert.assertNotNull(loanOffering1.getPrdOfferingName());
    Assert.assertNotNull(loanOffering1.getPrdOfferingShortName());
    Assert.assertNotNull(loanOffering1.getPrdCategory().getProductCategoryName());
    Assert.assertNotNull(loanOffering1.getPrdStatus().getPrdState().getName());
    Assert.assertNotNull(loanOffering1.getPrdApplicableMasterEnum());
    Assert.assertNotNull(loanOffering1.getStartDate());
    Assert.assertNotNull(loanOffering1.getGracePeriodType().getName());
    Assert.assertNotNull(loanOffering1.getGracePeriodDuration());
    Assert.assertNotNull(loanOffering1.getInterestTypes().getName());
    for (LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO : loanOffering1.getLoanAmountSameForAllLoan()) {
        Assert.assertNotNull(loanAmountSameForAllLoanBO.getMaxLoanAmount());
        Assert.assertNotNull(loanAmountSameForAllLoanBO.getMinLoanAmount());
        Assert.assertNotNull(loanAmountSameForAllLoanBO.getDefaultLoanAmount());
    }
    Assert.assertNotNull(loanOffering1.getMaxInterestRate());
    Assert.assertNotNull(loanOffering1.getMinInterestRate());
    Assert.assertNotNull(loanOffering1.getDefInterestRate());
    for (NoOfInstallSameForAllLoanBO noOfInstallSameForAllLoanBO : loanOffering1.getNoOfInstallSameForAllLoan()) {
        Assert.assertNotNull(noOfInstallSameForAllLoanBO.getMaxNoOfInstall());
        Assert.assertNotNull(noOfInstallSameForAllLoanBO.getMinNoOfInstall());
        Assert.assertNotNull(noOfInstallSameForAllLoanBO.getDefaultNoOfInstall());
    }
    Assert.assertNotNull(loanOffering1.isIntDedDisbursement());
    Assert.assertNotNull(loanOffering1.isPrinDueLastInst());
    Assert.assertNotNull(loanOffering1.isIncludeInLoanCounter());
    Assert.assertNotNull(loanOffering1.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter());
    Assert.assertNotNull(loanOffering1.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
    Assert.assertNotNull(loanOffering1.getPrincipalGLcode().getGlcode());
    Assert.assertNotNull(loanOffering1.getInterestGLcode().getGlcode());
    Assert.assertNotNull(loanOffering1.getLoanOfferingFees());
    Assert.assertNotNull(loanOffering1.getLoanOfferingFunds());
    StaticHibernateUtil.flushSession();
}
Also used : NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

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