Search in sources :

Example 6 with MinMaxDefaultDto

use of org.mifos.dto.domain.MinMaxDefaultDto in project head by mifos.

the class LoanProductFormBeanAssembler method populateLoanAmountCalculationDetails.

private void populateLoanAmountCalculationDetails(LoanProductFormBean loanProductFormBean, LoanAmountDetailsDto loanAmountDetailsDto) {
    loanProductFormBean.setSelectedLoanAmountCalculationType(loanAmountDetailsDto.getCalculationType().toString());
    SameForAllLoanBean loanAmountSameForAllLoans = new SameForAllLoanBean();
    if (loanAmountDetailsDto.getSameForAllLoanRange() != null) {
        loanAmountSameForAllLoans.setMin(loanAmountDetailsDto.getSameForAllLoanRange().getMin().doubleValue());
        loanAmountSameForAllLoans.setMax(loanAmountDetailsDto.getSameForAllLoanRange().getMax().doubleValue());
        loanAmountSameForAllLoans.setTheDefault(loanAmountDetailsDto.getSameForAllLoanRange().getTheDefault().doubleValue());
    }
    ByLastLoanAmountBean[] loanAmountByLastLoanAmount = loanProductFormBean.createByLastLoanAmountBeans();
    int loanAmountByLastLoanAmountIndex = 0;
    for (LowerUpperMinMaxDefaultDto dto : loanAmountDetailsDto.getByLastLoanAmountList()) {
        ByLastLoanAmountBean bean = loanAmountByLastLoanAmount[loanAmountByLastLoanAmountIndex];
        bean.setLower(dto.getLower().doubleValue());
        bean.setUpper(dto.getUpper().doubleValue());
        bean.setMin(dto.getMin().doubleValue());
        bean.setMax(dto.getMax().doubleValue());
        bean.setTheDefault(dto.getTheDefault().doubleValue());
        loanAmountByLastLoanAmountIndex++;
    }
    ByLoanCycleBean[] loanAmountByLoanCycle = loanProductFormBean.createByLoanCycleBeans();
    int loanAmountCycleIndex = 0;
    for (MinMaxDefaultDto dto : loanAmountDetailsDto.getByLoanCycleList()) {
        ByLoanCycleBean bean = loanAmountByLoanCycle[loanAmountCycleIndex];
        bean.setMin(dto.getMin().doubleValue());
        bean.setMax(dto.getMax().doubleValue());
        bean.setTheDefault(dto.getTheDefault().doubleValue());
        loanAmountCycleIndex++;
    }
    loanProductFormBean.setLoanAmountSameForAllLoans(loanAmountSameForAllLoans);
    loanProductFormBean.setLoanAmountByLastLoanAmount(loanAmountByLastLoanAmount);
    loanProductFormBean.setLoanAmountByLoanCycle(loanAmountByLoanCycle);
}
Also used : MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto)

Example 7 with MinMaxDefaultDto

use of org.mifos.dto.domain.MinMaxDefaultDto in project head by mifos.

the class LoanProductFormBeanAssembler method toLoanProductDto.

public LoanProductRequest toLoanProductDto(LoanProductFormBean loanProductFormBean) {
    ProductDetailsDto loanProductDetails = translateToLoanProductDetails(loanProductFormBean);
    LoanAmountDetailsDto loanAmountDetails = translateToLoanAmountDetails(loanProductFormBean);
    Integer interestRateType = Integer.valueOf(loanProductFormBean.getSelectedInterestRateCalculationType());
    Double maxInterest = Double.valueOf(loanProductFormBean.getMaxInterestRate());
    Double minInterest = Double.valueOf(loanProductFormBean.getMinInterestRate());
    Double defaultInterest = Double.valueOf(loanProductFormBean.getDefaultInterestRate());
    MinMaxDefaultDto interestRateRange = MinMaxDefaultDto.create(minInterest, maxInterest, defaultInterest);
    RepaymentDetailsDto repaymentDetails = translateToRepaymentDetails(loanProductFormBean);
    List<Integer> applicableFees = new ArrayList<Integer>();
    if (loanProductFormBean.getSelectedFees() != null) {
        for (String feeId : loanProductFormBean.getSelectedFees()) {
            applicableFees.add(Integer.valueOf(feeId));
        }
    }
    List<Integer> applicablePenalties = new ArrayList<Integer>();
    if (loanProductFormBean.getSelectedPenalties() != null) {
        for (String penaltyId : loanProductFormBean.getSelectedPenalties()) {
            applicablePenalties.add(Integer.valueOf(penaltyId));
        }
    }
    AccountingDetailsDto accountDetails = translateToAccountingDetails(loanProductFormBean);
    Integer currencyId = null;
    if (StringUtils.isNotBlank(loanProductFormBean.getSelectedCurrency())) {
        currencyId = Integer.valueOf(loanProductFormBean.getSelectedCurrency());
    }
    return new LoanProductRequest(loanProductDetails, loanProductFormBean.isIncludeInLoanCycleCounter(), loanProductFormBean.isWaiverInterest(), currencyId, loanAmountDetails, interestRateType, interestRateRange, repaymentDetails, applicableFees, applicablePenalties, accountDetails);
}
Also used : LoanAmountDetailsDto(org.mifos.dto.screen.LoanAmountDetailsDto) ArrayList(java.util.ArrayList) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) AccountingDetailsDto(org.mifos.dto.screen.AccountingDetailsDto) RepaymentDetailsDto(org.mifos.dto.domain.RepaymentDetailsDto) LoanProductRequest(org.mifos.dto.domain.LoanProductRequest)

Example 8 with MinMaxDefaultDto

use of org.mifos.dto.domain.MinMaxDefaultDto in project head by mifos.

the class LoanProductFormBeanAssembler method translateToLoanAmountDetails.

private LoanAmountDetailsDto translateToLoanAmountDetails(LoanProductFormBean loanProductFormBean) {
    Integer calculationType = Integer.valueOf(loanProductFormBean.getSelectedLoanAmountCalculationType());
    MinMaxDefaultDto sameForAllLoanRange = null;
    List<LowerUpperMinMaxDefaultDto> byLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
    List<MinMaxDefaultDto> byLoanCycleList = new ArrayList<MinMaxDefaultDto>();
    if (Integer.valueOf(1).equals(calculationType)) {
        sameForAllLoanRange = translateSameForAllLoanBeanToMinMaxDefaultDto(loanProductFormBean.getLoanAmountSameForAllLoans());
    }
    if (Integer.valueOf(2).equals(calculationType)) {
        byLastLoanAmountList = translateByLastLoanAmountBeanToLowerUpperMinMaxDefaultDto(loanProductFormBean.getLoanAmountByLastLoanAmount());
    }
    if (Integer.valueOf(3).equals(calculationType)) {
        byLoanCycleList = translateLoanCycleBeanToMinMaxDefaultDto(loanProductFormBean.getLoanAmountByLoanCycle());
    }
    return new LoanAmountDetailsDto(calculationType, sameForAllLoanRange, byLastLoanAmountList, byLoanCycleList);
}
Also used : LoanAmountDetailsDto(org.mifos.dto.screen.LoanAmountDetailsDto) ArrayList(java.util.ArrayList) MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto)

Aggregations

LowerUpperMinMaxDefaultDto (org.mifos.dto.domain.LowerUpperMinMaxDefaultDto)8 MinMaxDefaultDto (org.mifos.dto.domain.MinMaxDefaultDto)8 ArrayList (java.util.ArrayList)4 LoanAmountDetailsDto (org.mifos.dto.screen.LoanAmountDetailsDto)4 HashSet (java.util.HashSet)2 LoanProductRequest (org.mifos.dto.domain.LoanProductRequest)2 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)2 RepaymentDetailsDto (org.mifos.dto.domain.RepaymentDetailsDto)2 AccountingDetailsDto (org.mifos.dto.screen.AccountingDetailsDto)2 LoanAmountFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLastLoanAmountBO)1 LoanAmountFromLoanCycleBO (org.mifos.accounts.productdefinition.business.LoanAmountFromLoanCycleBO)1 LoanAmountSameForAllLoanBO (org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO)1 NoOfInstallFromLastLoanAmountBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLastLoanAmountBO)1 NoOfInstallFromLoanCycleBO (org.mifos.accounts.productdefinition.business.NoOfInstallFromLoanCycleBO)1 NoOfInstallSameForAllLoanBO (org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO)1