use of org.apache.struts.action.ActionMessage in project head by mifos.
the class LoanAccountActionForm method validateMaxPayableAmount.
private void validateMaxPayableAmount(HttpServletRequest request, ActionErrors errors) throws InvalidDateException {
Money totalAmount = Money.zero(getCurrencyFromLoanOffering(request));
Money paymentAmount = Money.zero(getCurrencyFromLoanOffering(request));
for (PaymentDataHtmlBean paymentDataHtmlBean : getPaymentDataBeans()) {
totalAmount = totalAmount.add(paymentDataHtmlBean.totalAsMoney());
paymentAmount = paymentAmount.add(paymentDataHtmlBean.paymentAmountAsMoney());
}
if (paymentAmount.isGreaterThan(totalAmount)) {
errors.add(LoanExceptionConstants.EXCESS_PAYMENT, new ActionMessage(LoanExceptionConstants.EXCESS_PAYMENT));
}
}
use of org.apache.struts.action.ActionMessage 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;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class MultipleLoanAccountsCreationActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
logger.debug("Inside validate method");
String method = request.getParameter(Methods.method.toString());
ActionErrors errors = new ActionErrors();
try {
if (method.equals(Methods.get.toString())) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
checkValidationForLoad(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
} else if (method.equals(Methods.create.toString())) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
validateLoanAmounts(errors, this.getUserContext(request).getPreferredLocale(), clientDetails);
checkValidationForCreate(errors, request);
} else if (method.equals(Methods.getLoanOfficers.toString())) {
checkValidationForBranchOffice(errors, getUserContext(request));
} else if (method.equals(Methods.getCenters.toString())) {
checkValidationForBranchOffice(errors, getUserContext(request));
checkValidationForLoanOfficer(errors);
} else if (method.equals(Methods.getPrdOfferings.toString())) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
checkValidationForBranchOffice(errors, getUserContext(request));
checkValidationForLoanOfficer(errors);
checkValidationForCenter(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
}
} catch (PageExpiredException e) {
errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
} catch (ServiceException e) {
errors.add(ExceptionConstants.SERVICEEXCEPTION, new ActionMessage(ExceptionConstants.SERVICEEXCEPTION));
}
if (!errors.isEmpty()) {
request.setAttribute("methodCalled", method);
}
logger.debug("outside validate method");
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class AccountApplyPaymentActionForm method validatePaymentDate.
//exposed for testing
public ActionErrors validatePaymentDate(String transactionDate, String fieldName) {
ActionErrors errors = null;
try {
if (lastPaymentDate != null && dateFallsBeforeDate(getDateAsSentFromBrowser(transactionDate), lastPaymentDate)) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, new ActionMessage(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, fieldName));
}
} catch (InvalidDateException ide) {
//dont add a message, since it was already added in validateDate()
errors = new ActionErrors();
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class AccountApplyPaymentActionForm method validateModeOfPaymentSecurity.
private void validateModeOfPaymentSecurity(HttpServletRequest request, ActionErrors errors) {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
AccountBO account = null;
Short personnelId = userContext.getId();
try {
if (accountId != null) {
account = new AccountBusinessService().getAccount(Integer.valueOf(accountId));
if (account.getPersonnel() != null) {
personnelId = account.getPersonnel().getPersonnelId();
}
}
} catch (NumberFormatException e) {
throw new MifosRuntimeException(e);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
if (getPaymentTypeId().equals("4") && !ActivityMapper.getInstance().isModeOfPaymentSecurity(userContext, personnelId)) {
errors.add(AccountConstants.LOAN_TRANSFER_PERMISSION, new ActionMessage(AccountConstants.LOAN_TRANSFER_PERMISSION, getLocalizedMessage("accounts.mode_of_payment_permission")));
}
}
Aggregations