Search in sources :

Example 11 with ConversionError

use of org.mifos.framework.util.helpers.ConversionError in project head by mifos.

the class LoanPrdActionForm method validateCashFlowThreshold.

private void validateCashFlowThreshold(ActionErrors actionErrors, Locale locale) {
    Double cashFlowThreshold = null;
    if (getCashFlowValidation()) {
        if (StringUtils.isNotBlank(this.cashFlowThreshold)) {
            DoubleConversionResult cashFlowThresholdResult = parseDoubleForCashFlowThreshold(this.cashFlowThreshold);
            List<ConversionError> errorList = cashFlowThresholdResult.getErrors();
            if (errorList.size() > 0) {
                for (ConversionError anErrorList : errorList) {
                    addError(actionErrors, ProductDefinitionConstants.CASHFLOW_WARNING_THRESHOLD_INVALID_FORMAT, ProductDefinitionConstants.CASHFLOW_WARNING_THRESHOLD_INVALID_FORMAT, getConversionErrorText(anErrorList));
                }
            } else {
                cashFlowThreshold = cashFlowThresholdResult.getDoubleValue();
            }
        }
        if (cashFlowThreshold != null) {
            if (cashFlowThreshold >= getMaxCashFlowThreshold()) {
                addError(actionErrors, "cashFlowThreshold", ProductDefinitionConstants.CASHFLOW_THRESHOLD_INVALID, String.valueOf(getMaxCashFlowThreshold()));
            }
            cashFlowThresholdValue = cashFlowThreshold;
        }
    }
}
Also used : ConversionError(org.mifos.framework.util.helpers.ConversionError) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult)

Example 12 with ConversionError

use of org.mifos.framework.util.helpers.ConversionError in project head by mifos.

the class LoanPrdActionForm method validateMinMaxDefLoanAmounts.

private void validateMinMaxDefLoanAmounts(ActionErrors errors, String maxLoanAmountStr, String minLoanAmountStr, String defLoanAmountStr, String error, String rownum) {
    DoubleConversionResult minLoanResult = null;
    DoubleConversionResult maxLoanResult = null;
    DoubleConversionResult defaultLoanResult = null;
    List<ConversionError> errorList = null;
    Double maxLoanAmt = null;
    Double minLoanAmt = null;
    Double defLoanAmt = null;
    if (!StringUtils.isNotBlank(minLoanAmountStr)) {
        addError(errors, ProductDefinitionConstants.ERRORMINIMUMLOANAMOUNT, ProductDefinitionConstants.ERRORMINIMUMLOANAMOUNT, error, rownum);
    } else {
        minLoanResult = parseDoubleForMoney(minLoanAmountStr);
        errorList = minLoanResult.getErrors();
        if (errorList.size() > 0) {
            for (int i = 0; i < errorList.size(); i++) {
                addError(errors, ProductDefinitionConstants.ERRORMINIMUMLOANAMOUNTINVALIDFORMAT, ProductDefinitionConstants.ERRORMINIMUMLOANAMOUNTINVALIDFORMAT, error, rownum, getConversionErrorText(errorList.get(i)));
            }
        } else {
            minLoanAmt = minLoanResult.getDoubleValue();
        }
    }
    if (!StringUtils.isNotBlank(maxLoanAmountStr)) {
        addError(errors, ProductDefinitionConstants.ERRORMAXIMUMLOANAMOUNT, ProductDefinitionConstants.ERRORMAXIMUMLOANAMOUNT, error, rownum);
    } else {
        maxLoanResult = parseDoubleForMoney(maxLoanAmountStr);
        errorList = maxLoanResult.getErrors();
        if (errorList.size() > 0) {
            for (int i = 0; i < errorList.size(); i++) {
                addError(errors, ProductDefinitionConstants.ERRORMAXIMUMLOANAMOUNTINVALIDFORMAT, ProductDefinitionConstants.ERRORMAXIMUMLOANAMOUNTINVALIDFORMAT, error, rownum, getConversionErrorText(errorList.get(i)));
            }
        } else {
            maxLoanAmt = maxLoanResult.getDoubleValue();
        }
    }
    if (!StringUtils.isNotBlank(defLoanAmountStr)) {
        addError(errors, ProductDefinitionConstants.ERRORDEFLOANAMOUNT, ProductDefinitionConstants.ERRORDEFLOANAMOUNT, error, rownum);
    } else {
        defaultLoanResult = parseDoubleForMoney(defLoanAmountStr);
        errorList = defaultLoanResult.getErrors();
        if (errorList.size() > 0) {
            for (int i = 0; i < errorList.size(); i++) {
                addError(errors, ProductDefinitionConstants.ERRORDEFAULTLOANAMOUNTINVALIDFORMAT, ProductDefinitionConstants.ERRORDEFAULTLOANAMOUNTINVALIDFORMAT, error, rownum, getConversionErrorText(errorList.get(i)));
            }
        } else {
            defLoanAmt = defaultLoanResult.getDoubleValue();
        }
    }
    if ((minLoanAmt != null) && (maxLoanAmt != null)) {
        if (minLoanAmt > maxLoanAmt) {
            addError(errors, ProductDefinitionConstants.ERRORMAXMINLOANAMOUNT, ProductDefinitionConstants.ERRORMAXMINLOANAMOUNT, error, rownum);
        }
        if (defLoanAmt != null) {
            if ((defLoanAmt < minLoanAmt) || (defLoanAmt > maxLoanAmt)) {
                addError(errors, ProductDefinitionConstants.ERRORDEFLOANAMOUNT, ProductDefinitionConstants.ERRORDEFLOANAMOUNT, error, rownum);
            } else {
                setLoanAmounts(minLoanAmt, maxLoanAmt, defLoanAmt, rownum);
            }
        }
    }
}
Also used : ConversionError(org.mifos.framework.util.helpers.ConversionError) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult)

Example 13 with ConversionError

use of org.mifos.framework.util.helpers.ConversionError in project head by mifos.

the class LoanPrdActionForm method validateRepaymentCapacity.

private void validateRepaymentCapacity(ActionErrors actionErrors, Locale locale) {
    Double repaymentCapacity = null;
    if (getCashFlowValidation()) {
        if (StringUtils.isNotBlank(this.repaymentCapacity)) {
            DoubleConversionResult repaymentCapacityResult = parseDoubleForRepaymentCapacity(this.repaymentCapacity);
            List<ConversionError> errorList = repaymentCapacityResult.getErrors();
            if (errorList.size() > 0) {
                for (ConversionError anErrorList : errorList) {
                    addError(actionErrors, ProductDefinitionConstants.REPAYMENT_CAPACITY_INVALID_FORMAT, ProductDefinitionConstants.REPAYMENT_CAPACITY_INVALID_FORMAT, getConversionErrorText(anErrorList));
                }
            } else {
                repaymentCapacity = repaymentCapacityResult.getDoubleValue();
            }
        }
        if (repaymentCapacity != null) {
            if (repaymentCapacity >= getMaxRepaymentCapacity()) {
                addError(actionErrors, "repaymentCapacity", ProductDefinitionConstants.REPAYMENT_CAPACITY_INVALID, String.valueOf(getMaxRepaymentCapacity()));
            }
            repaymentCapacityValue = repaymentCapacity;
        }
    }
}
Also used : ConversionError(org.mifos.framework.util.helpers.ConversionError) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult)

Example 14 with ConversionError

use of org.mifos.framework.util.helpers.ConversionError in project head by mifos.

the class LoanPrdActionForm method validateMinimumInstallmentAmountForValriableInstallments.

private void validateMinimumInstallmentAmountForValriableInstallments(ActionErrors actionErrors, Locale locale) {
    if (StringUtils.isNotEmpty(minimumInstallmentAmount)) {
        DoubleConversionResult conversionResult = parseDoubleForMoney(minimumInstallmentAmount);
        List<ConversionError> errorList = conversionResult.getErrors();
        if (errorList.isEmpty()) {
            minimumInstallmentAmountValue = conversionResult.getDoubleValue();
        } else {
            for (ConversionError error : errorList) {
                addError(actionErrors, "minimumInstallmentAmount", ProductDefinitionConstants.VARIABLE_INSTALLMENT_MIN_AMOUNT_INVALID_FORMAT, getConversionErrorText(error));
            }
        }
    }
}
Also used : ConversionError(org.mifos.framework.util.helpers.ConversionError) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult)

Example 15 with ConversionError

use of org.mifos.framework.util.helpers.ConversionError in project head by mifos.

the class LoanPrdActionForm method validateIndebtednessRatio.

private void validateIndebtednessRatio(ActionErrors actionErrors, Locale locale) {
    Double indebtednessRatio = null;
    if (getCashFlowValidation()) {
        if (StringUtils.isNotBlank(this.indebtednessRatio)) {
            DoubleConversionResult indebtednessRatioResult = parseDoubleForIndebtednessRatio(this.indebtednessRatio);
            List<ConversionError> errorList = indebtednessRatioResult.getErrors();
            if (errorList.size() > 0) {
                for (ConversionError anErrorList : errorList) {
                    addError(actionErrors, ProductDefinitionConstants.INDEBTEDNESS_RATIO_INVALID_FORMAT, ProductDefinitionConstants.INDEBTEDNESS_RATIO_INVALID_FORMAT, getConversionErrorText(anErrorList));
                }
            } else {
                indebtednessRatio = indebtednessRatioResult.getDoubleValue();
            }
        }
        if (indebtednessRatio != null) {
            if (indebtednessRatio >= getMaxIndebtednessRatio()) {
                addError(actionErrors, "indebtednessRatio", ProductDefinitionConstants.INDEBTEDNESS_RATIO_INVALID, String.valueOf(getMaxIndebtednessRatio()));
            }
            indebtednessRatioValue = indebtednessRatio;
        }
    }
}
Also used : ConversionError(org.mifos.framework.util.helpers.ConversionError) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult)

Aggregations

ConversionError (org.mifos.framework.util.helpers.ConversionError)22 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)20 ArrayList (java.util.ArrayList)6 LocalizationConverter (org.mifos.framework.util.LocalizationConverter)1 ErrorEntry (org.mifos.platform.validations.ErrorEntry)1