Search in sources :

Example 21 with ActionErrors

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

the class ViewStageTransactionActionForm method mandatoryCheckForAudit.

private ActionErrors mandatoryCheckForAudit(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    String audit = resources.getString(SimpleAccountingConstants.AUDIT);
    String audit_comments = resources.getString(SimpleAccountingConstants.AUDIT_COMMENTS);
    ActionErrors errors = new ActionErrors();
    if (getAudit() == null || "".equals(getAudit())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit));
    } else if (getAuditComments() == null || "".equals(getAuditComments())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit_comments));
    }
    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 22 with ActionErrors

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

the class VoucherBranchMappingActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    ActionErrors errors = new ActionErrors();
    String branchname = resources.getString(SimpleAccountingConstants.BRANCH_NAME);
    String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
    String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
    String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
    String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
    String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
    String[] amts = getAmount();
    String[] trannotes = getTransactionnotes();
    // String[] canames=getCoaname();
    List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
    if (amts.length < 0 || "".equals(amts)) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
    }
    for (int i = 0; i < amts.length; i++) {
        if (amts[i].equalsIgnoreCase("0")) {
            errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
        }
    }
    if (trannotes == null || "".equals(trannotes)) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
    }
    {
        for (int i = 0; i < getAmount().length; i++) {
            CoaNamesDto coanamesob = new CoaNamesDto();
            coanamesob.setAmount(amts[i]);
            coanamesob.setTrxnnotes(trannotes[i]);
            // coanamesob.setCoaName(canames[i]);
            coaNamesDtolist.add(coanamesob);
        }
    }
    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 (getTransactiondate() == null || "".equals(getTransactiondate())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
    } else if (getTransactiondate() != null && !getTransactiondate().equals("") && !DateUtils.isValidDate(getTransactiondate())) {
        errors = trxnDateValidate(errors, locale);
    } else if (DateUtils.isValidDate(getTransactiondate())) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactiondate());
        } 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 (getBranch() == null || "".equals(getBranch())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, branchname));
    }
    if (transactiontype == null || "".equals(transactiontype.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
    }
    if (mainAccount == null || "".equals(mainAccount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) ActionErrors(org.apache.struts.action.ActionErrors) CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 23 with ActionErrors

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

the class VoucherBranchMappingActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    logger.debug("VoucherBranchMappingActionForm.validate");
    // request.setAttribute(Constants.CURRENTFLOWKEY,
    // request.getParameter(Constants.CURRENTFLOWKEY));
    ActionErrors errors = new ActionErrors();
    if (request.getParameter(SimpleAccountingConstants.METHOD).equalsIgnoreCase(SimpleAccountingConstants.PREVIEW)) {
        return mandatoryCheck(getUserContext(request));
    }
    return errors;
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors)

Example 24 with ActionErrors

use of org.apache.struts.action.ActionErrors 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 25 with ActionErrors

use of org.apache.struts.action.ActionErrors 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)

Aggregations

ActionErrors (org.apache.struts.action.ActionErrors)144 ActionMessage (org.apache.struts.action.ActionMessage)68 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)20 Locale (java.util.Locale)19 ResourceBundle (java.util.ResourceBundle)13 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)12 Test (org.junit.Test)9 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 Date (java.sql.Date)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)4 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)4 DateTime (org.joda.time.DateTime)3 PaymentDataHtmlBean (org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean)3 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)3 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)2 ArrayList (java.util.ArrayList)2 ServletContext (javax.servlet.ServletContext)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpSession (javax.servlet.http.HttpSession)2