Search in sources :

Example 1 with LowerUpperMinMaxDefaultDto

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

the class LoanOfferingBO method toFullDto.

public LoanProductRequest toFullDto() {
    ProductDetailsDto details = super.toDetailsDto();
    Integer currencyId = super.getCurrency().getCurrencyId().intValue();
    String currencyCode = super.getCurrency().getCurrencyName();
    boolean includeInLoanCounter = YesNoFlag.YES.getValue().equals(this.loanCounter);
    boolean waiverInterestBool = YesNoFlag.YES.getValue().equals(this.waiverInterest);
    Integer frequencyType = this.loanOfferingMeeting.getMeeting().getRecurrenceType().getValue().intValue();
    Integer recurs = this.loanOfferingMeeting.getMeeting().getRecurAfter().intValue();
    Integer loanAmountCalculationType = LoanProductCalculationType.UNKNOWN.getValue();
    MinMaxDefaultDto loanAmountSameForAllLoanRange = null;
    List<LowerUpperMinMaxDefaultDto> loanAmountByLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
    List<MinMaxDefaultDto> loanAmountByLoanCycleList = new ArrayList<MinMaxDefaultDto>();
    if (!this.loanAmountSameForAllLoan.isEmpty()) {
        loanAmountCalculationType = LoanProductCalculationType.SAME_FOR_ALL_LOANS.getValue();
        LoanAmountSameForAllLoanBO sameForAllLoans = getEligibleLoanAmountSameForAllLoan();
        loanAmountSameForAllLoanRange = MinMaxDefaultDto.create(sameForAllLoans.getMinLoanAmount(), sameForAllLoans.getMaxLoanAmount(), sameForAllLoans.getDefaultLoanAmount());
    }
    if (!this.loanAmountFromLastLoan.isEmpty()) {
        loanAmountCalculationType = LoanProductCalculationType.BY_LAST_LOAN.getValue();
        for (LoanAmountFromLastLoanAmountBO loanCycle : this.loanAmountFromLastLoan) {
            LowerUpperMinMaxDefaultDto cycle = LowerUpperMinMaxDefaultDto.create(loanCycle.getStartRange(), loanCycle.getEndRange(), loanCycle.getMinLoanAmount(), loanCycle.getMaxLoanAmount(), loanCycle.getDefaultLoanAmount());
            loanAmountByLastLoanAmountList.add(cycle);
        }
    }
    if (!this.loanAmountFromLoanCycle.isEmpty()) {
        loanAmountCalculationType = LoanProductCalculationType.BY_LOAN_CYCLE.getValue();
        for (LoanAmountFromLoanCycleBO loanCycle : this.loanAmountFromLoanCycle) {
            MinMaxDefaultDto cycle = MinMaxDefaultDto.create(loanCycle.getMinLoanAmount(), loanCycle.getMaxLoanAmount(), loanCycle.getDefaultLoanAmount());
            loanAmountByLoanCycleList.add(cycle);
        }
    }
    LoanAmountDetailsDto loanAmountDetails = new LoanAmountDetailsDto(loanAmountCalculationType, loanAmountSameForAllLoanRange, loanAmountByLastLoanAmountList, loanAmountByLoanCycleList);
    Integer installmentCalculationType = LoanProductCalculationType.UNKNOWN.getValue();
    MinMaxDefaultDto installmentSameForAllLoanRange = null;
    List<LowerUpperMinMaxDefaultDto> installmentByLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
    List<MinMaxDefaultDto> installmentByLoanCycleList = new ArrayList<MinMaxDefaultDto>();
    if (!this.noOfInstallSameForAllLoan.isEmpty()) {
        installmentCalculationType = LoanProductCalculationType.SAME_FOR_ALL_LOANS.getValue();
        LoanOfferingInstallmentRange sameForAllLoans = getEligibleInstallmentSameForAllLoan();
        installmentSameForAllLoanRange = MinMaxDefaultDto.create(sameForAllLoans.getMinNoOfInstall(), sameForAllLoans.getMaxNoOfInstall(), sameForAllLoans.getDefaultNoOfInstall());
    }
    if (!this.noOfInstallFromLastLoan.isEmpty()) {
        installmentCalculationType = LoanProductCalculationType.BY_LAST_LOAN.getValue();
        for (NoOfInstallFromLastLoanAmountBO loanCycle : this.noOfInstallFromLastLoan) {
            LowerUpperMinMaxDefaultDto cycle = LowerUpperMinMaxDefaultDto.create(loanCycle.getStartRange(), loanCycle.getEndRange(), loanCycle.getMinNoOfInstall(), loanCycle.getMaxNoOfInstall(), loanCycle.getDefaultNoOfInstall());
            installmentByLastLoanAmountList.add(cycle);
        }
    }
    if (!this.noOfInstallFromLoanCycle.isEmpty()) {
        installmentCalculationType = LoanProductCalculationType.BY_LOAN_CYCLE.getValue();
        for (NoOfInstallFromLoanCycleBO loanCycle : this.noOfInstallFromLoanCycle) {
            MinMaxDefaultDto cycle = MinMaxDefaultDto.create(loanCycle.getMinNoOfInstall(), loanCycle.getMaxNoOfInstall(), loanCycle.getDefaultNoOfInstall());
            installmentByLoanCycleList.add(cycle);
        }
    }
    LoanAmountDetailsDto installmentCalculationDetails = new LoanAmountDetailsDto(installmentCalculationType, installmentSameForAllLoanRange, installmentByLastLoanAmountList, installmentByLoanCycleList);
    RepaymentDetailsDto repaymentDetails = new RepaymentDetailsDto(frequencyType, recurs, installmentCalculationDetails, this.gracePeriodType.getId().intValue(), this.gracePeriodDuration.intValue());
    Integer interestRateType = this.interestTypes.getId().intValue();
    MinMaxDefaultDto interestRateRange = MinMaxDefaultDto.create(this.minInterestRate, this.maxInterestRate, this.defInterestRate);
    List<String> fees = new ArrayList<String>();
    List<Integer> applicableFees = new ArrayList<Integer>();
    for (LoanOfferingFeesEntity fee : this.loanOfferingFees) {
        applicableFees.add(fee.getFees().getFeeId().intValue());
        fees.add(fee.getFees().getFeeName());
    }
    List<String> funds = new ArrayList<String>();
    List<Integer> applicableFunds = new ArrayList<Integer>();
    for (LoanOfferingFundEntity fund : this.loanOfferingFunds) {
        applicableFunds.add(fund.getFund().getFundId().intValue());
        funds.add(fund.getFund().getFundName());
    }
    List<String> penalties = new ArrayList<String>();
    List<Integer> applicablePenalties = new ArrayList<Integer>();
    for (PrdOfferingPenaltiesEntity penalty : this.loanOfferingPenalties) {
        applicablePenalties.add(penalty.getPenalty().getPenaltyId().intValue());
        penalties.add(penalty.getPenalty().getPenaltyName());
    }
    Integer interestGlCodeId = this.interestGLcode.getGlcodeId().intValue();
    String interestGlCodeValue = this.interestGLcode.getGlcode();
    Integer principalClCodeId = this.principalGLcode.getGlcodeId().intValue();
    String principalGlCodeValue = this.principalGLcode.getGlcode();
    AccountingDetailsDto accountDetails = new AccountingDetailsDto(applicableFunds, interestGlCodeId, principalClCodeId);
    LoanProductRequest loanProductDto = new LoanProductRequest(details, includeInLoanCounter, waiverInterestBool, currencyId, loanAmountDetails, interestRateType, interestRateRange, repaymentDetails, applicableFees, applicablePenalties, accountDetails);
    loanProductDto.setMultiCurrencyEnabled(false);
    loanProductDto.setCurrencyCode(currencyCode);
    loanProductDto.setInterestRateTypeName(this.interestTypes.getName());
    loanProductDto.setFees(fees);
    loanProductDto.setFunds(funds);
    loanProductDto.setPenalties(penalties);
    loanProductDto.setInterestGlCodeValue(interestGlCodeValue);
    loanProductDto.setPrincipalGlCodeValue(principalGlCodeValue);
    return loanProductDto;
}
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) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) RepaymentDetailsDto(org.mifos.dto.domain.RepaymentDetailsDto) LoanProductRequest(org.mifos.dto.domain.LoanProductRequest) AccountingDetailsDto(org.mifos.dto.screen.AccountingDetailsDto)

Example 2 with LowerUpperMinMaxDefaultDto

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

the class LoanProductCaluclationTypeAssembler method assembleLoanAmountCalculationFromDto.

public LoanAmountCalculation assembleLoanAmountCalculationFromDto(LoanAmountDetailsDto loanAmountDetails) {
    LoanProductCalculationType loanCalculation = LoanProductCalculationType.fromInt(loanAmountDetails.getCalculationType());
    LoanAmountSameForAllLoanBO sameForAll = null;
    Set<LoanAmountFromLastLoanAmountBO> loanAmountFromLastLoan = new HashSet<LoanAmountFromLastLoanAmountBO>();
    Set<LoanAmountFromLoanCycleBO> loanAmountFromLoanCycle = new HashSet<LoanAmountFromLoanCycleBO>();
    switch(loanCalculation) {
        case SAME_FOR_ALL_LOANS:
            MinMaxDefaultDto sameForAllLoan = loanAmountDetails.getSameForAllLoanRange();
            sameForAll = new LoanAmountSameForAllLoanBO(sameForAllLoan.getMin().doubleValue(), sameForAllLoan.getMax().doubleValue(), sameForAllLoan.getTheDefault().doubleValue(), null);
            break;
        case BY_LAST_LOAN:
            List<LowerUpperMinMaxDefaultDto> byLastAmount = loanAmountDetails.getByLastLoanAmountList();
            for (LowerUpperMinMaxDefaultDto bean : byLastAmount) {
                loanAmountFromLastLoan.add(new LoanAmountFromLastLoanAmountBO(bean.getMin().doubleValue(), bean.getMax().doubleValue(), bean.getTheDefault().doubleValue(), bean.getLower().doubleValue(), bean.getUpper().doubleValue(), null));
            }
            break;
        case BY_LOAN_CYCLE:
            List<MinMaxDefaultDto> byCycle = loanAmountDetails.getByLoanCycleList();
            Short rangeIndex = Short.valueOf("0");
            for (MinMaxDefaultDto bean : byCycle) {
                loanAmountFromLoanCycle.add(new LoanAmountFromLoanCycleBO(bean.getMin().doubleValue(), bean.getMax().doubleValue(), bean.getTheDefault().doubleValue(), rangeIndex, null));
                rangeIndex++;
            }
            break;
        default:
            break;
    }
    return new LoanAmountCalculation(sameForAll, loanAmountFromLastLoan, loanAmountFromLoanCycle);
}
Also used : LoanAmountFromLastLoanAmountBO(org.mifos.accounts.productdefinition.business.LoanAmountFromLastLoanAmountBO) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) LoanAmountFromLoanCycleBO(org.mifos.accounts.productdefinition.business.LoanAmountFromLoanCycleBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) HashSet(java.util.HashSet)

Example 3 with LowerUpperMinMaxDefaultDto

use of org.mifos.dto.domain.LowerUpperMinMaxDefaultDto 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 4 with LowerUpperMinMaxDefaultDto

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

the class LoanProductFormBeanAssembler method translateToInstallmentDetails.

private LoanAmountDetailsDto translateToInstallmentDetails(LoanProductFormBean loanProductFormBean) {
    Integer calculationType = Integer.valueOf(loanProductFormBean.getSelectedInstallmentsCalculationType());
    MinMaxDefaultDto sameForAllLoanRange = null;
    List<LowerUpperMinMaxDefaultDto> byLastLoanAmountList = new ArrayList<LowerUpperMinMaxDefaultDto>();
    List<MinMaxDefaultDto> byLoanCycleList = new ArrayList<MinMaxDefaultDto>();
    if (Integer.valueOf(1).equals(calculationType)) {
        sameForAllLoanRange = translateSameForAllLoanBeanToMinMaxDefaultDto(loanProductFormBean.getInstallmentsSameForAllLoans());
    }
    if (Integer.valueOf(2).equals(calculationType)) {
        byLastLoanAmountList = translateByLastLoanAmountBeanToLowerUpperMinMaxDefaultDto(loanProductFormBean.getInstallmentsByLastLoanAmount());
    }
    if (Integer.valueOf(3).equals(calculationType)) {
        byLoanCycleList = translateLoanCycleBeanToMinMaxDefaultDto(loanProductFormBean.getInstallmentsByLoanCycle());
    }
    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)

Example 5 with LowerUpperMinMaxDefaultDto

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

the class LoanProductFormBeanAssembler method populateInstallmentCalculationDetails.

private void populateInstallmentCalculationDetails(LoanProductFormBean loanProductFormBean, LoanAmountDetailsDto installmentDetailsDto) {
    loanProductFormBean.setSelectedInstallmentsCalculationType(installmentDetailsDto.getCalculationType().toString());
    SameForAllLoanBean installmentsSameForAllLoans = new SameForAllLoanBean();
    if (installmentDetailsDto.getSameForAllLoanRange() != null) {
        installmentsSameForAllLoans.setMin(installmentDetailsDto.getSameForAllLoanRange().getMin().doubleValue());
        installmentsSameForAllLoans.setMax(installmentDetailsDto.getSameForAllLoanRange().getMax().doubleValue());
        installmentsSameForAllLoans.setTheDefault(installmentDetailsDto.getSameForAllLoanRange().getTheDefault().doubleValue());
    }
    ByLastLoanAmountBean[] installmentsByLastLoanAmount = loanProductFormBean.createByLastLoanAmountBeans();
    int installmentsByLastLoanAmountIndex = 0;
    for (LowerUpperMinMaxDefaultDto dto : installmentDetailsDto.getByLastLoanAmountList()) {
        ByLastLoanAmountBean bean = installmentsByLastLoanAmount[installmentsByLastLoanAmountIndex];
        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());
        installmentsByLastLoanAmountIndex++;
    }
    ByLoanCycleBean[] installmentsByLoanCycle = loanProductFormBean.createByLoanCycleBeans();
    int installIndex = 0;
    for (MinMaxDefaultDto dto : installmentDetailsDto.getByLoanCycleList()) {
        ByLoanCycleBean bean = installmentsByLoanCycle[installIndex];
        bean.setMin(dto.getMin().doubleValue());
        bean.setMax(dto.getMax().doubleValue());
        bean.setTheDefault(dto.getTheDefault().doubleValue());
        installIndex++;
    }
    loanProductFormBean.setInstallmentsSameForAllLoans(installmentsSameForAllLoans);
    loanProductFormBean.setInstallmentsByLastLoanAmount(installmentsByLastLoanAmount);
    loanProductFormBean.setInstallmentsByLoanCycle(installmentsByLoanCycle);
}
Also used : 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)7 MinMaxDefaultDto (org.mifos.dto.domain.MinMaxDefaultDto)7 ArrayList (java.util.ArrayList)3 LoanAmountDetailsDto (org.mifos.dto.screen.LoanAmountDetailsDto)3 HashSet (java.util.HashSet)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 LoanProductRequest (org.mifos.dto.domain.LoanProductRequest)1 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)1 RepaymentDetailsDto (org.mifos.dto.domain.RepaymentDetailsDto)1 AccountingDetailsDto (org.mifos.dto.screen.AccountingDetailsDto)1