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;
}
}
}
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);
}
}
}
}
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;
}
}
}
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));
}
}
}
}
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;
}
}
}
Aggregations