use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class ApplyChargeActionForm method validateAmount.
protected void validateAmount(ActionErrors errors, Locale locale) {
if (StringUtils.isBlank(getChargeType())) {
addError(errors, FilePaths.ACCOUNTS_UI_RESOURCE_PROPERTYFILE, "errors.mandatoryselect", getLocalizedMessage("account.chargetype"));
return;
}
DoubleConversionResult conversionResult = null;
String chargeAmount = getCharge();
if (StringUtils.isBlank(chargeAmount)) {
Double amount = 0.0;
for (Map.Entry<Integer, String> entry : individualValues.entrySet()) {
amount += Double.valueOf(entry.getValue());
}
chargeAmount = amount.toString();
}
if (!StringUtils.isBlank(chargeAmount)) {
if (isRateType()) {
conversionResult = validateInterest(getCharge(), AccountConstants.ACCOUNT_AMOUNT, errors);
} else {
conversionResult = validateAmount(getCharge(), getChargeCurrency(), AccountConstants.ACCOUNT_AMOUNT, errors, "");
}
} else {
addError(errors, AccountConstants.ACCOUNT_AMOUNT, "errors.mandatory", "amount");
}
if (conversionResult != null && conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
}
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class SavingsDepositWithdrawalActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = null;
if (method != null && method.equals(Methods.preview.toString())) {
errors = new ActionErrors();
if (StringUtils.isBlank(getTrxnTypeId())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.paymentType")));
}
if (StringUtils.isBlank(getAmount())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.amount")));
}
if (StringUtils.isNotBlank(getAmount())) {
Locale locale = getUserContext(request).getPreferredLocale();
DoubleConversionResult conversionResult = validateAmount(getAmount(), AccountConstants.ACCOUNT_AMOUNT, errors);
if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
}
}
if (StringUtils.isBlank(getPaymentTypeId())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.modeOfPayment")));
}
ActionErrors dateError = validateDate(this.trxnDate, getLocalizedMessage("Savings.dateOfTrxn"));
if (dateError != null && !dateError.isEmpty()) {
errors.add(dateError);
}
dateError = validateTrxnDate(this.trxnDate, getLocalizedMessage("Savings.dateOfTrxn"));
if (dateError != null && !dateError.isEmpty()) {
errors.add(dateError);
}
if (this.getReceiptDate() != null && !this.getReceiptDate().equals("")) {
dateError = validateDate(getReceiptDate(), getLocalizedMessage("Savings.receiptDate"));
if (dateError != null && !dateError.isEmpty()) {
errors.add(dateError);
}
}
if (StringUtils.isBlank(getCustomerId())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.ClientName")));
}
}
if (null != errors && !errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class LoanAccountActionForm method validateTotalAmount.
protected void validateTotalAmount(ActionErrors errors, Locale locale, MifosCurrency currency, PaymentDataHtmlBean bean) {
String installmentNo = bean.getInstallment().getInstallmentNumberAsString();
DoubleConversionResult conversionResult = validateAmount(bean.getAmount(), currency, LoanConstants.LOAN_AMOUNT_KEY, errors, " " + installmentNo);
if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, LoanConstants.LOAN_AMOUNT_KEY, LoanConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(LoanConstants.LOAN_AMOUNT_KEY), installmentNo);
}
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class AccountApplyPaymentActionForm method validateAmount.
protected void validateAmount(ActionErrors errors) {
MifosCurrency currency = null;
if (getCurrencyId() != null && AccountingRules.isMultiCurrencyEnabled()) {
currency = AccountingRules.getCurrencyByCurrencyId(getCurrencyId());
}
DoubleConversionResult conversionResult = validateAmount(getAmount(), currency, AccountConstants.ACCOUNT_AMOUNT, errors, "");
if (amountCannotBeZero() && conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
}
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class ApplyAdjustmentActionForm method validateAmount.
protected void validateAmount(ActionErrors errors) {
MifosCurrency currency = null;
if (getCurrencyId() != null && AccountingRules.isMultiCurrencyEnabled()) {
currency = AccountingRules.getCurrencyByCurrencyId(getCurrencyId());
}
DoubleConversionResult conversionResult = validateAmount(getAmount(), currency, AccountConstants.ACCOUNT_AMOUNT, errors, "");
if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
}
}
Aggregations