use of org.apache.struts.action.ActionMessage in project head by mifos.
the class FeeAction method editPreview.
@TransactionDemarcate(joinToken = true)
public ActionForward editPreview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
Short feeId = ((FeeActionForm) form).getFeeIdValue();
FeeDto feeDto = this.feeDao.findDtoById(feeId);
Short appliedFeeId = this.feeDao.findFeeAppliedToLoan(feeId);
boolean isInProducts = appliedFeeId == null ? true : false;
List<Short> feesAppliedLoanAccountList = this.feeDao.getAllUsedLoansWithAttachedFee();
boolean isFeeAppliedToLoan = feesAppliedLoanAccountList.contains(feeId);
Short feeInSchedule = this.feeDao.findFeeInSchedule(feeId);
boolean isFeeInSchedule = feeInSchedule == null ? false : true;
ActionMessages messages = new ActionMessages();
if (!(((FeeActionForm) form).isToRemove() && feeDto.getFeeStatus().getId().equalsIgnoreCase("2"))) {
form.reset(mapping, request);
}
if (((FeeActionForm) form).isToRemove()) {
if (!isInProducts && !isFeeAppliedToLoan) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemoved"));
} else if (isFeeAppliedToLoan) {
if (!isFeeInSchedule) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrd"));
((FeeActionForm) form).setCantBeRemoved(true);
} else {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdButNotDeleted"));
}
} else {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeNotUsedRemove"));
}
} else {
if (((FeeActionForm) form).getFeeStatusValue().getValue() == 2) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdWhenInActive"));
}
}
saveErrors(request, messages);
request.getSession().setAttribute("feeModel", feeDto);
return mapping.findForward(ActionForwards.editPreview_success.toString());
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ConsolidatedTransactionActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
String officeId = resources.getString(SimpleAccountingConstants.OFFICE);
ActionErrors errors = new ActionErrors();
if (branch == null || "".equals(branch.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, officeId));
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ProcessAccountingTransactionsActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String last_process_date = resources.getString(SimpleAccountingConstants.LASTPROCESSDATE);
String process_till_date = resources.getString(SimpleAccountingConstants.PROCESSTILLDATE);
String groupBy = resources.getString(SimpleAccountingConstants.GROUPBY);
ActionErrors errors = new ActionErrors();
java.sql.Date currentDate = null;
try {
currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE));
}
java.sql.Date trxnDate = null;
if (getProcessTillDate() == null || "".equals(getProcessTillDate())) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, process_till_date));
} else if (getProcessTillDate() != null && !getProcessTillDate().equals("") && !DateUtils.isValidDate(getProcessTillDate())) {
errors = processTillDateValidate(errors, locale);
} else if (DateUtils.isValidDate(getProcessTillDate())) {
try {
trxnDate = DateUtils.getDateAsSentFromBrowser(getProcessTillDate());
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, process_till_date));
}
if (trxnDate.compareTo(currentDate) > 0) {
errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, process_till_date));
}
} else if (DateUtils.isValidDate(getProcessTillDate())) {
try {
trxnDate = DateUtils.getDateAsSentFromBrowser(getProcessTillDate());
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, process_till_date));
}
if (trxnDate.compareTo(currentDate) < 0 && trxnDate.compareTo(DateUtils.getDate(getLastProcessDate())) < 0) {
errors.add(SimpleAccountingConstants.INVALID_PAST, new ActionMessage(SimpleAccountingConstants.INVALID_PAST, process_till_date, last_process_date));
}
}
if (groupBy == null || "".equals(groupBy.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, groupBy));
}
if (getLastProcessDate() == null) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, last_process_date));
}
if (getLastProcessDate() != null && !getLastProcessDate().equals("") && !DateUtils.isValidDate(getLastProcessDate()))
errors = lastProcessDateValidate(errors, locale);
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ProcessAccountingTransactionsActionForm method processTillDateValidate.
private ActionErrors processTillDateValidate(ActionErrors errors, Locale locale) {
if (StringUtils.isNotBlank(getProcessTillDate()) && !DateUtils.isValidDate(getProcessTillDate())) {
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String processTillDate = resources.getString(SimpleAccountingConstants.PROCESSTILLDATE);
errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE, processTillDate));
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class SingleGeneralLedgerActionForm method trxnDateValidate.
private ActionErrors trxnDateValidate(ActionErrors errors, Locale locale) {
if (StringUtils.isNotBlank(getTrxnDate()) && !DateUtils.isValidDate(getTrxnDate())) {
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String trxnDate = resources.getString(SimpleAccountingConstants.TRXNDATE);
errors.add(SimpleAccountingConstants.INVALID_TRXN_DATE, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxnDate));
}
return errors;
}
Aggregations