Search in sources :

Example 21 with InvalidDateException

use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.

the class EditStatusActionForm method validateDate.

protected ActionErrors validateDate(String date, String fieldName) {
    ActionErrors errors = null;
    java.sql.Date sqlDate = null;
    if (date != null && !date.equals("")) {
        try {
            sqlDate = getDateAsSentFromBrowser(date);
            if (DateUtils.whichDirection(sqlDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
            }
        } catch (InvalidDateException ide) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
        }
    } else {
        errors = new ActionErrors();
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors) Date(java.sql.Date)

Example 22 with InvalidDateException

use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.

the class AccountApplyPaymentActionForm method validateDate.

protected ActionErrors validateDate(String date, String fieldName) {
    ActionErrors errors = null;
    java.sql.Date sqlDate = null;
    if (date != null && !date.equals("")) {
        try {
            sqlDate = getDateAsSentFromBrowser(date);
            if (DateUtils.whichDirection(sqlDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
            }
        } catch (InvalidDateException ide) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
        }
    } else {
        errors = new ActionErrors();
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors) Date(java.sql.Date)

Example 23 with InvalidDateException

use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.

the class ApplyAdjustmentActionForm method validateDate.

protected ActionErrors validateDate(String date, String fieldName) {
    ActionErrors errors = null;
    java.sql.Date sqlDate = null;
    if (date != null && !date.equals("")) {
        try {
            sqlDate = getDateAsSentFromBrowser(date);
            if (DateUtils.whichDirection(sqlDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
            } else if (previousPaymentDate != null && sqlDate.compareTo(previousPaymentDate) < 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_ADJUSTMENT_PREVIOUS_DATE, new ActionMessage(AccountConstants.ERROR_ADJUSTMENT_PREVIOUS_DATE, fieldName));
            } else if (nextPaymentDate != null && sqlDate.compareTo(nextPaymentDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_ADJUSTMENT_NEXT_DATE, new ActionMessage(AccountConstants.ERROR_ADJUSTMENT_NEXT_DATE, fieldName));
            }
        } catch (InvalidDateException ide) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
        }
    } else {
        errors = new ActionErrors();
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 24 with InvalidDateException

use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.

the class LoanPrdActionForm method validateStartDateForEditPreview.

private void validateStartDateForEditPreview(HttpServletRequest request, ActionErrors errors) {
    logger.debug("start validateStartDateForEditPreview method of Loan Product Action form method :" + startDate);
    request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    java.util.Date oldStartDate = null;
    Date changedStartDate = null;
    try {
        oldStartDate = (java.util.Date) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDSTARTDATE, request);
    } catch (PageExpiredException e) {
    }
    try {
        changedStartDate = getStartDateValue(getUserContext(request).getPreferredLocale());
    } catch (InvalidDateException ide) {
        addError(errors, "startdate", ProductDefinitionConstants.STARTDATEUPDATEEXCEPTION);
    }
    if (oldStartDate != null && changedStartDate != null) {
        if (LoanOfferingBO.isBackDatedLoanProductCreationAllowed() && DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime()).compareTo(DateUtils.getDateWithoutTimeStamp(changedStartDate.getTime())) != 0) {
            addError(errors, "startDate", ProductDefinitionConstants.STARTDATEUPDATEEXCEPTION);
        } else if (!LoanOfferingBO.isBackDatedLoanProductCreationAllowed() && DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime()).compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) <= 0 && (DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime()).compareTo(DateUtils.getDateWithoutTimeStamp(changedStartDate.getTime())) != 0)) {
            addError(errors, "startDate", ProductDefinitionConstants.STARTDATEUPDATEEXCEPTION);
        }
    } else if (changedStartDate != null && DateUtils.getDateWithoutTimeStamp(changedStartDate.getTime()).compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) > 0) {
        validateStartDate(request, errors);
    }
    logger.debug("validateStartDateForEditPreview method of Loan Product Action form method called :" + startDate + "---" + oldStartDate);
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) Date(java.sql.Date)

Example 25 with InvalidDateException

use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.

the class LoanPrdActionForm method reset.

@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    String method = request.getParameter(ProductDefinitionConstants.METHOD);
    logger.debug("start reset method of Savings Product Action form method :" + method);
    if (method != null && method.equals(Methods.load.toString())) {
        try {
            startDate = DateUtils.getCurrentDate(getUserContext(request).getPreferredLocale());
        } catch (InvalidDateException ide) {
            throw new MifosRuntimeException(ide);
        }
        recurAfter = "1";
        minNoInstallments = "1";
        minimumGapBetweenInstallments = 1;
    }
    if ((method != null) && method.equals(Methods.manage.toString())) {
        cashFlowValidation = null;
        cashFlowThreshold = null;
        cashFlowThresholdValue = null;
        repaymentCapacity = null;
        repaymentCapacityValue = null;
        indebtednessRatio = null;
        indebtednessRatioValue = null;
    }
    if (method != null && (method.equals(Methods.preview.toString()) || method.equals(Methods.editPreview.toString()))) {
        intDedDisbursementFlag = null;
        prinDueLastInstFlag = null;
        loanCounter = null;
        waiverInterest = null;
        prdOfferinFees = null;
        prdOfferinPenalties = null;
        loanOfferingFunds = null;
        gracePeriodType = null;
        gracePeriodDuration = null;
        loanOfferingQGs = null;
        canConfigureVariableInstallments = null;
        isFixedRepaymentSchedule = null;
        isRoundingDifferenceInFirstPayment = null;
        cashFlowValidation = null;
        cashFlowThreshold = null;
        cashFlowThresholdValue = null;
        repaymentCapacity = null;
        repaymentCapacityValue = null;
        indebtednessRatio = null;
        indebtednessRatioValue = null;
    }
    logger.debug("reset method of Savings Product Action form method called ");
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)46 ActionMessage (org.apache.struts.action.ActionMessage)22 ActionErrors (org.apache.struts.action.ActionErrors)20 Locale (java.util.Locale)12 Date (java.sql.Date)9 ResourceBundle (java.util.ResourceBundle)9 PersistenceException (org.mifos.framework.exceptions.PersistenceException)6 Date (java.util.Date)5 AccountException (org.mifos.accounts.exceptions.AccountException)5 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)5 SimpleDateFormat (java.text.SimpleDateFormat)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 CustomerException (org.mifos.customers.exceptions.CustomerException)4 ParseException (java.text.ParseException)3 LocalDate (org.joda.time.LocalDate)3 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 ArrayList (java.util.ArrayList)2 DateMidnight (org.joda.time.DateMidnight)2 DateTime (org.joda.time.DateTime)2