Search in sources :

Example 36 with ActionMessage

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());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) ActionMessages(org.apache.struts.action.ActionMessages) FeeDto(org.mifos.dto.domain.FeeDto) ActionMessage(org.apache.struts.action.ActionMessage) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 37 with ActionMessage

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;
}
Also used : Locale(java.util.Locale) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle) ActionErrors(org.apache.struts.action.ActionErrors)

Example 38 with ActionMessage

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;
}
Also used : Locale(java.util.Locale) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle) ActionErrors(org.apache.struts.action.ActionErrors)

Example 39 with ActionMessage

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;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 40 with ActionMessage

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;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)166 ActionErrors (org.apache.struts.action.ActionErrors)70 ActionMessages (org.apache.struts.action.ActionMessages)45 ResourceBundle (java.util.ResourceBundle)29 JspException (javax.servlet.jsp.JspException)22 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Iterator (java.util.Iterator)21 Locale (java.util.Locale)19 List (java.util.List)9 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 ArrayList (java.util.ArrayList)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)6 IOException (java.io.IOException)6 Date (java.sql.Date)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 UserPersistence (cn.edu.zju.acm.onlinejudge.persistence.UserPersistence)4