use of org.apache.struts.action.ActionErrors in project head by mifos.
the class SavingsApplyAdjustmentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
try {
if (method != null && method.equals("preview")) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AccountPaymentEntity payment = savings.findPaymentById(this.paymentId);
if (payment == null || savings.getLastPmntAmnt() == 0 || !(new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue()) || new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue()))) {
errors.add(SavingsConstants.INVALID_LAST_PAYMENT, new ActionMessage(SavingsConstants.INVALID_LAST_PAYMENT));
} else {
if (StringUtils.isBlank(getLastPaymentAmount())) {
errors.add(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT, new ActionMessage(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT));
}
if (StringUtils.isNotBlank(getLastPaymentAmount())) {
Locale locale = getUserContext(request).getPreferredLocale();
validateAmount(errors, locale);
}
if (StringUtils.isNotBlank(getNote()) && getNote().length() > CustomerConstants.COMMENT_LENGTH) {
errors.add(AccountConstants.MAX_NOTE_LENGTH, new ActionMessage(AccountConstants.MAX_NOTE_LENGTH, AccountConstants.COMMENT_LENGTH));
}
validateDate(errors);
errors.add(super.validate(mapping, request));
}
}
} catch (ApplicationException ae) {
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class SavingsClosureActionForm method validate.
@Override
public ActionErrors validate(@SuppressWarnings("unused") ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (method.equals("load") || method.equals("previous") || method.equals("validate") || method.equals("close") || method.equals("cancel")) {
} else {
String amount = getAmount();
if (!("0.0".equals(amount))) {
if (StringUtils.isNotBlank(amount)) {
if (StringUtils.isBlank(getPaymentTypeId())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.paymentType")));
}
}
}
if (this.getReceiptDate() != null && !this.getReceiptDate().equals("")) {
ActionErrors dateError = validateDate(this.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 (StringUtils.isBlank(getNotes())) {
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, getLocalizedMessage("Savings.notes")));
}
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class SavingsDepositWithdrawalActionForm method validateDate.
private ActionErrors validateDate(String date, String fieldName) {
ActionErrors errors = null;
java.sql.Date sqlDate = null;
if (date != null && !date.equals("")) {
try {
sqlDate = DateUtils.getDateAsSentFromBrowser(date);
if (DateUtils.whichDirection(sqlDate) > 0) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
}
} catch (InvalidDateException e) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
}
} else {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
}
return errors;
}
use of org.apache.struts.action.ActionErrors 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.apache.struts.action.ActionErrors in project head by mifos.
the class LoanDisbursementActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
ActionErrors errors1 = super.validate(mapping, request);
if (errors1 != null) {
errors.add(errors1);
}
String method = request.getParameter(MethodNameConstants.METHOD);
if (isPreviewMethod(method) && getPaymentAmountGreaterThanZero() && StringUtils.isBlank(paymentModeOfPayment)) {
String errorMessage = this.getLocalizedMessage("loan.paymentid");
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, errorMessage));
}
if (isPreviewMethod(method) && getPaymentAmountGreaterThanZero() && !StringUtils.isBlank(paymentModeOfPayment) && Short.valueOf(paymentModeOfPayment).equals(transferPaymentTypeId) && StringUtils.isBlank(accountForTransfer)) {
String errorMessage = this.getLocalizedMessage("loan.accountForTransfer");
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, errorMessage));
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
Aggregations