Search in sources :

Example 6 with InvalidDateException

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

the class EditStatusActionForm method validatePaymentDate.

public ActionErrors validatePaymentDate(String transactionDate, String fieldName) {
    ActionErrors errors = null;
    if (transactionDate != null && !transactionDate.equals("")) {
        try {
            if (lastPaymentDate != null && dateFallsBeforeDate(getDateAsSentFromBrowser(transactionDate), lastPaymentDate)) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, new ActionMessage(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, fieldName));
            }
        } catch (InvalidDateException ide) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, 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 7 with InvalidDateException

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

the class SavingsDepositWithdrawalActionForm method validateDate.

private ActionErrors validateDate(String date, String fieldName) {
    ActionErrors errors = null;
    java.sql.Date sqlDate = null;
    if (date != null && !date.equals("")) {
        try {
            sqlDate = DateUtils.getDateAsSentFromBrowser(date);
            if (DateUtils.whichDirection(sqlDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
            }
        } catch (InvalidDateException e) {
            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 8 with InvalidDateException

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

the class AccountApplyPaymentActionForm method validatePaymentDate.

//exposed for testing
public ActionErrors validatePaymentDate(String transactionDate, String fieldName) {
    ActionErrors errors = null;
    try {
        if (lastPaymentDate != null && dateFallsBeforeDate(getDateAsSentFromBrowser(transactionDate), lastPaymentDate)) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, new ActionMessage(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, fieldName));
        }
    } catch (InvalidDateException ide) {
        //dont add a message, since it was already added in validateDate()
        errors = new ActionErrors();
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 9 with InvalidDateException

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

the class LoanBO method updateLoan.

public void updateLoan(final Boolean interestDeductedAtDisbursement, final Money loanAmount, final Double interestRate, final Short noOfInstallments, final Date disbursementDate, final Short gracePeriodDuration, final Integer businessActivityId, final String collateralNote, final Integer collateralTypeId, final List<CustomFieldDto> customFields, final boolean isRepaymentIndepOfMeetingEnabled, final MeetingBO newMeetingForRepaymentDay, final FundBO fund) throws AccountException {
    if (interestDeductedAtDisbursement) {
        try {
            if (noOfInstallments <= 1) {
                throw new AccountException(LoanExceptionConstants.INVALIDNOOFINSTALLMENTS);
            }
            setGracePeriodType(legacyMasterDao.findMasterDataEntityWithLocale(GracePeriodTypeEntity.class, GraceType.NONE.getValue()));
        } catch (PersistenceException e) {
            throw new AccountException(e);
        }
    } else {
        setGracePeriodType(getLoanOffering().getGracePeriodType());
    }
    setLoanAmount(loanAmount);
    setInterestRate(interestRate);
    setNoOfInstallments(noOfInstallments);
    setGracePeriodDuration(gracePeriodDuration);
    setInterestDeductedAtDisbursement(interestDeductedAtDisbursement);
    setBusinessActivityId(businessActivityId);
    setCollateralNote(collateralNote);
    setCollateralTypeId(collateralTypeId);
    setFund(fund);
    if (getAccountState().getId().equals(AccountState.LOAN_APPROVED.getValue()) || getAccountState().getId().equals(AccountState.LOAN_DISBURSED_TO_LOAN_OFFICER.getValue()) || getAccountState().getId().equals(AccountState.LOAN_PARTIAL_APPLICATION.getValue()) || getAccountState().getId().equals(AccountState.LOAN_PENDING_APPROVAL.getValue())) {
        // only check the disbursement date if it has changed
        if (disbursementDate != null && !disbursementDate.equals(getDisbursementDate()) && isDisbursementDateLessThanCurrentDate(disbursementDate)) {
            throw new AccountException(LoanExceptionConstants.ERROR_INVALIDDISBURSEMENTDATE);
        }
        setDisbursementDate(disbursementDate);
        regeneratePaymentSchedule(isRepaymentIndepOfMeetingEnabled, newMeetingForRepaymentDay);
    }
    try {
        updateCustomFields(customFields);
    } catch (InvalidDateException ide) {
        throw new AccountException(ide);
    }
    loanSummary.setOriginalPrincipal(loanAmount);
    update();
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)

Example 10 with InvalidDateException

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

the class DateUtils method convertUserToDbFmt.

public static String convertUserToDbFmt(String userDate, String userPattern) throws InvalidDateException {
    try {
        SimpleDateFormat userFormat = new SimpleDateFormat(userPattern, dateLocale);
        // userFormat.setLenient(false);
        java.util.Date date = userFormat.parse(userDate);
        return toDatabaseFormat(date);
    } catch (ParseException e) {
        throw new InvalidDateException(userDate);
    }
}
Also used : Date(java.util.Date) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

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