Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class SingleGeneralLedgerActionForm 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 trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
    String office_Hierarchy = resources.getString(SimpleAccountingConstants.OFFICE_HIERARCHY);
    String officeId = resources.getString(SimpleAccountingConstants.OFFICE);
    String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
    String subAccount = resources.getString(SimpleAccountingConstants.ACCOUNT_HEAD);
    String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
    String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
    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 (getTrxnDate() == null || "".equals(getTrxnDate())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
    } else if (getTrxnDate() != null && !getTrxnDate().equals("") && !DateUtils.isValidDate(getTrxnDate())) {
        errors = trxnDateValidate(errors, locale);
    } else if (DateUtils.isValidDate(getTrxnDate())) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTrxnDate());
        } catch (InvalidDateException ide) {
            errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxn_Date));
        }
        if (trxnDate.compareTo(currentDate) > 0) {
            errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, trxn_Date));
        }
    }
    if (trxnType == null || "".equals(trxnType.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
    }
    if (officeHierarchy == null || "".equals(officeHierarchy.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, office_Hierarchy));
    }
    if (office == null || "".equals(office.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, officeId));
    }
    if (mainAccount == null || "".equals(mainAccount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
    }
    if (accountHead == null || "".equals(accountHead.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, subAccount));
    }
    if (amount == null || "".equals(amount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Amount));
    }
    if (memberId.length() != 10 && memberId.length() > 0) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.ENTER_GRETERTHAN, memberId));
    }
    if (StringUtils.isNotBlank(getAmount())) {
        DoubleConversionResult conversionResult = validateAmount(getAmount(), Amount, errors);
        if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
            addError(errors, SimpleAccountingConstants.AMOUNT, SimpleAccountingConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, Amount);
        }
    }
    if (notes == null || "".equals(notes.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
    }
    if (getChequeDate() != null && !getChequeDate().equals("") && !DateUtils.isValidDate(getChequeDate()))
        errors = chequeDateValidate(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) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)146 ActionErrors (org.apache.struts.action.ActionErrors)68 ActionMessages (org.apache.struts.action.ActionMessages)31 ResourceBundle (java.util.ResourceBundle)29 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Locale (java.util.Locale)18 JspException (javax.servlet.jsp.JspException)11 Iterator (java.util.Iterator)10 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 List (java.util.List)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 ArrayList (java.util.ArrayList)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)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 UserSecurity (cn.edu.zju.acm.onlinejudge.security.UserSecurity)4