Search in sources :

Example 1 with LoanAmountDetailsDto

use of org.mifos.dto.screen.LoanAmountDetailsDto 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 LoanAmountDetailsDto

use of org.mifos.dto.screen.LoanAmountDetailsDto in project head by mifos.

the class LoanProductFormBeanAssembler method populateWithLoanProductDetails.

public void populateWithLoanProductDetails(LoanProductFormBean loanProductFormBean, LoanProductRequest loanProductRequest) {
    ProductDetailsDto productDto = loanProductRequest.getProductDetails();
    GeneralProductBean productBean = new GeneralProductBeanAssembler().assembleFrom(loanProductFormBean.getGeneralDetails(), productDto);
    loanProductFormBean.setGeneralDetails(productBean);
    loanProductFormBean.setSelectedCurrency(loanProductRequest.getCurrencyId().toString());
    loanProductFormBean.setIncludeInLoanCycleCounter(loanProductRequest.isIncludeInLoanCycleCounter());
    loanProductFormBean.setWaiverInterest(loanProductRequest.isWaiverInterest());
    LoanAmountDetailsDto loanAmountDetailsDto = loanProductRequest.getLoanAmountDetails();
    populateLoanAmountCalculationDetails(loanProductFormBean, loanAmountDetailsDto);
    loanProductFormBean.setSelectedInterestRateCalculationType(loanProductRequest.getInterestRateType().toString());
    loanProductFormBean.setMinInterestRate(loanProductRequest.getInterestRateRange().getMin().doubleValue());
    loanProductFormBean.setMaxInterestRate(loanProductRequest.getInterestRateRange().getMax().doubleValue());
    loanProductFormBean.setDefaultInterestRate(loanProductRequest.getInterestRateRange().getTheDefault().doubleValue());
    loanProductFormBean.setInstallmentFrequencyPeriod(loanProductRequest.getRepaymentDetails().getFrequencyType().toString());
    loanProductFormBean.setInstallmentFrequencyRecurrenceEvery(loanProductRequest.getRepaymentDetails().getRecurs());
    LoanAmountDetailsDto installmentDetailsDto = loanProductRequest.getRepaymentDetails().getInstallmentCalculationDetails();
    populateInstallmentCalculationDetails(loanProductFormBean, installmentDetailsDto);
    loanProductFormBean.setSelectedGracePeriodType(loanProductRequest.getRepaymentDetails().getGracePeriodType().toString());
    loanProductFormBean.setGracePeriodDurationInInstallments(loanProductRequest.getRepaymentDetails().getGracePeriodDuration());
    populateFeesAndFundsMultiSelectBoxes(loanProductFormBean, loanProductRequest);
    loanProductFormBean.setSelectedInterest(loanProductRequest.getAccountDetails().getInterestGlCodeId().toString());
    loanProductFormBean.setSelectedPrincipal(loanProductRequest.getAccountDetails().getPrincipalClCodeId().toString());
}
Also used : LoanAmountDetailsDto(org.mifos.dto.screen.LoanAmountDetailsDto) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto)

Example 3 with LoanAmountDetailsDto

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

use of org.mifos.dto.screen.LoanAmountDetailsDto in project head by mifos.

the class LoanProductFormBeanAssembler method translateToRepaymentDetails.

private RepaymentDetailsDto translateToRepaymentDetails(LoanProductFormBean loanProductFormBean) {
    Integer frequencyType = Integer.valueOf(loanProductFormBean.getInstallmentFrequencyPeriod());
    Integer recurs = Integer.valueOf(loanProductFormBean.getInstallmentFrequencyRecurrenceEvery());
    LoanAmountDetailsDto installmentCalculationDetails = translateToInstallmentDetails(loanProductFormBean);
    Integer gracePeriodType = Integer.valueOf(loanProductFormBean.getSelectedGracePeriodType());
    Integer gracePeriodDuration = loanProductFormBean.getGracePeriodDurationInInstallments();
    RepaymentDetailsDto details = new RepaymentDetailsDto(frequencyType, recurs, installmentCalculationDetails, gracePeriodType, gracePeriodDuration);
    return details;
}
Also used : LoanAmountDetailsDto(org.mifos.dto.screen.LoanAmountDetailsDto) RepaymentDetailsDto(org.mifos.dto.domain.RepaymentDetailsDto)

Example 5 with LoanAmountDetailsDto

use of org.mifos.dto.screen.LoanAmountDetailsDto 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)

Aggregations

LoanAmountDetailsDto (org.mifos.dto.screen.LoanAmountDetailsDto)6 ArrayList (java.util.ArrayList)4 LowerUpperMinMaxDefaultDto (org.mifos.dto.domain.LowerUpperMinMaxDefaultDto)4 MinMaxDefaultDto (org.mifos.dto.domain.MinMaxDefaultDto)4 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)3 RepaymentDetailsDto (org.mifos.dto.domain.RepaymentDetailsDto)3 LoanProductRequest (org.mifos.dto.domain.LoanProductRequest)2 AccountingDetailsDto (org.mifos.dto.screen.AccountingDetailsDto)2