use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LocalizationConverter method parseDoubleForInstallmentTotalAmount.
public DoubleConversionResult parseDoubleForInstallmentTotalAmount(String totalAmountStr) {
DoubleConversionResult result = new DoubleConversionResult();
if (totalAmountStr == null) {
List<ConversionError> errors = new ArrayList<ConversionError>();
errors.add(ConversionError.CONVERSION_ERROR);
result.setErrors(errors);
return result;
}
List<ConversionError> errors = checkDigits(digitsBeforeDecimalForMoney, digitsAfterDecimalForMoney, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_MONEY, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_MONEY, totalAmountStr, true);
result.setErrors(errors);
if (errors.size() > 0) {
return result;
}
try {
result.setDoubleValue(getDoubleValueForCurrentLocale(totalAmountStr));
} catch (Exception ex) {
// after all the checkings this is not likely to happen, but just in
// case
result.getErrors().add(ConversionError.CONVERSION_ERROR);
}
return result;
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LocalizationConverter method parseDoubleForMoney.
public DoubleConversionResult parseDoubleForMoney(String doubleStr) {
DoubleConversionResult result = new DoubleConversionResult();
if (doubleStr == null) {
List<ConversionError> errors = new ArrayList<ConversionError>();
errors.add(ConversionError.CONVERSION_ERROR);
result.setErrors(errors);
return result;
}
List<ConversionError> errors = checkDigits(digitsBeforeDecimalForMoney, digitsAfterDecimalForMoney, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_MONEY, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_MONEY, doubleStr, false);
result.setErrors(errors);
if (errors.size() > 0) {
return result;
}
try {
result.setDoubleValue(getDoubleValueForCurrentLocale(doubleStr));
} catch (Exception ex) {
// after all the checkings this is not likely to happen, but just in
// case
result.getErrors().add(ConversionError.CONVERSION_ERROR);
}
return result;
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LocalizationConverter method parseDoubleForInterest.
public DoubleConversionResult parseDoubleForInterest(String doubleStr) {
DoubleConversionResult result = new DoubleConversionResult();
if (doubleStr == null) {
List<ConversionError> errors = new ArrayList<ConversionError>();
errors.add(ConversionError.CONVERSION_ERROR);
result.setErrors(errors);
return result;
}
List<ConversionError> errors = checkDigits(digitsBeforeDecimalForInterest, digitsAfterDecimalForInterest, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_INTEREST, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_INTEREST, doubleStr, false);
result.setErrors(errors);
if (errors.size() > 0) {
return result;
}
return validateTheValueIsWithinTheRange(ConversionError.INTEREST_OUT_OF_RANGE, AccountingRules.getMinInterest(), AccountingRules.getMaxInterest(), result, errors, doubleStr);
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LocalizationConverter method parseDoubleForCashFlowValidations.
public DoubleConversionResult parseDoubleForCashFlowValidations(String doubleStr, ConversionError cashFlowValidationOutOfRange, Double minimumLimit, Double maximumLimit) {
DoubleConversionResult result = new DoubleConversionResult();
if (doubleStr == null) {
List<ConversionError> errors = new ArrayList<ConversionError>();
errors.add(ConversionError.CONVERSION_ERROR);
result.setErrors(errors);
return result;
}
List<ConversionError> errors = checkDigits(digitsBeforeDecimalForCashFlowValidations, digitsAfterDecimalForCashFlowValidations, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_CASHFLOW_VALIDATION, ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_CASHFLOW_VALIDATION, doubleStr, false);
result.setErrors(errors);
if (errors.size() > 0) {
return result;
}
return validateTheValueIsWithinTheRange(cashFlowValidationOutOfRange, minimumLimit, maximumLimit, result, errors, doubleStr);
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LoanAccountActionForm method validateAdditionalFee.
protected void validateAdditionalFee(ActionErrors errors, Locale locale, MifosCurrency currency, HttpServletRequest request) throws PageExpiredException {
Map<String, Boolean> addedFees = new HashMap<String, Boolean>();
List<FeeDto> additionalFeeList = (List<FeeDto>) SessionUtils.getAttribute(LoanConstants.ADDITIONAL_FEES_LIST, request);
for (FeeDto additionalFee : additionalFees) {
if (additionalFee.getAmount() != null && !additionalFee.getAmount().equals("")) {
FeeDto additionalFeeDetails = getAdditionalFeeType(additionalFeeList, additionalFee.getFeeId());
if (additionalFeeDetails.getFeeType().equals(RateAmountFlag.AMOUNT)) {
DoubleConversionResult conversionResult = validateAmount(additionalFee.getAmount(), currency, LoanConstants.LOAN_ADDITIONAL_FEE_KEY, errors, "");
if (validPositiveValue(errors, locale, conversionResult)) {
validateFeeTypeIfVariableInstallmentLoanType(errors, additionalFeeDetails);
}
} else {
DoubleConversionResult conversionResult = validateInterest(additionalFee.getAmount(), LoanConstants.LOAN_ADDITIONAL_FEE_KEY, errors);
if (validPositiveValue(errors, locale, conversionResult)) {
validateFeeTypeIfVariableInstallmentLoanType(errors, additionalFeeDetails);
}
}
if (!additionalFeeDetails.isPeriodic() && addedFees.get(additionalFeeDetails.getFeeId()) != null) {
addError(errors, "AdditionalFee", ProductDefinitionConstants.MULTIPLE_ONE_TIME_FEES_NOT_ALLOWED);
}
addedFees.put(additionalFeeDetails.getFeeId(), true);
}
}
}
Aggregations