Search in sources :

Example 31 with Date

use of java.sql.Date in project head by mifos.

the class LoanPrdActionForm method validateEndDate.

private void validateEndDate(HttpServletRequest request, ActionErrors errors) {
    logger.debug("start validateEndDate method of Loan Product Action form method :" + startDate + "---" + endDate);
    Date startingDate = null;
    Date endingDate = null;
    try {
        startingDate = getStartDateValue(getUserContext(request).getPreferredLocale());
    } catch (InvalidDateException ide) {
        addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATE);
    }
    try {
        endingDate = getEndDateValue(getUserContext(request).getPreferredLocale());
    } catch (InvalidDateException ide) {
        addError(errors, "endDate", ProductDefinitionConstants.INVALIDENDDATE);
    }
    if (startingDate != null && endingDate != null && startingDate.compareTo(endingDate) >= 0) {
        addError(errors, "endDate", ProductDefinitionConstants.INVALIDENDDATE);
    }
    logger.debug("validateEndDate method of Loan Product Action form method called :" + startDate + "---" + endDate);
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) Date(java.sql.Date)

Example 32 with Date

use of java.sql.Date in project head by mifos.

the class LoanPrdActionForm method validateStartDate.

private void validateStartDate(HttpServletRequest request, ActionErrors errors) {
    logger.debug("start validateStartDate method of Loan Product Action form method :" + startDate);
    Date startingDate = null;
    try {
        startingDate = getStartDateValue(getUserContext(request).getPreferredLocale());
    } catch (InvalidDateException ide) {
        if (LoanOfferingBO.isBackDatedLoanProductCreationAllowed()) {
            addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATEWITHBACKDATE);
        } else {
            addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATE);
        }
    }
    if (LoanOfferingBO.isBackDatedLoanProductCreationAllowed() && (startingDate != null && (DateUtils.getDateWithoutTimeStamp(startingDate.getTime()).compareTo(DateUtils.getCurrentDateOfNextYearWithOutTimeStamp()) > 0))) {
        addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATEWITHBACKDATE);
    } else if (!LoanOfferingBO.isBackDatedLoanProductCreationAllowed() && (startingDate != null && ((DateUtils.getDateWithoutTimeStamp(startingDate.getTime()).compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) < 0) || (DateUtils.getDateWithoutTimeStamp(startingDate.getTime()).compareTo(DateUtils.getCurrentDateOfNextYearWithOutTimeStamp()) > 0)))) {
        addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATE);
    }
    logger.debug("validateStartDate method of Loan Product Action form method called :" + startDate);
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) Date(java.sql.Date)

Example 33 with Date

use of java.sql.Date in project head by mifos.

the class PersonnelServiceFacadeWebTier method retrieveUserSettings.

@Override
public UserSettingsDto retrieveUserSettings() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    PersonnelBO personnel = this.personnelDao.findPersonnelById(userContext.getId());
    String gender = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getGender());
    String martialStatus = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getMaritalStatus());
    String language = Localization.getInstance().getDisplayName(personnel.getPreferredLocale());
    String sitePreference = SitePreferenceType.getSitePreference(personnel.getSitePreference()).name();
    List<ValueListElement> genders = this.customerDao.retrieveGenders();
    List<ValueListElement> martialStatuses = this.customerDao.retrieveMaritalStatuses();
    List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
    List<ValueListElement> sitePreferenceTypes = new ArrayList<ValueListElement>();
    for (short i = 0; i < SitePreferenceType.values().length; i++) {
        SitePreferenceType sitePreferenceType = SitePreferenceType.values()[i];
        ValueListElement valueListElement = new BusinessActivityEntity(sitePreferenceType.getValue().intValue(), sitePreferenceType.name(), sitePreferenceType.name());
        sitePreferenceTypes.add(valueListElement);
    }
    int age = DateUtils.DateDiffInYears(((Date) personnel.getPersonnelDetails().getDob()));
    if (age < 0) {
        age = 0;
    }
    return new UserSettingsDto(gender, martialStatus, language, age, sitePreference, genders, martialStatuses, languages, sitePreferenceTypes);
}
Also used : SitePreferenceType(org.mifos.config.SitePreferenceType) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) UserContext(org.mifos.security.util.UserContext) UserSettingsDto(org.mifos.dto.screen.UserSettingsDto) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) Date(java.sql.Date) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 34 with Date

use of java.sql.Date in project head by mifos.

the class BulkEntryActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(Date meetingDate, UserContext userContext, short isCenterHierarchyExists) {
    String loanOfficer = getLocalizedMessage(CollectionSheetEntryConstants.LOANOFFICERS);
    String modeOfPayment = getLocalizedMessage(CollectionSheetEntryConstants.MODE_OF_PAYMENT);
    String dateOfTransaction = getLocalizedMessage(CollectionSheetEntryConstants.DATEOFTRXN);
    ActionErrors errors = receiptDateValidate(new ActionErrors());
    java.sql.Date currentDate = null;
    try {
        currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    } catch (InvalidDateException ide) {
        errors.add(CollectionSheetEntryConstants.INVALIDDATE, new ActionMessage(CollectionSheetEntryConstants.INVALIDDATE));
    }
    java.sql.Date trxnDate = null;
    String customerLabel = isCenterHierarchyExists == Constants.YES ? ConfigurationConstants.CENTER : ConfigurationConstants.GROUP;
    if (officeId == null || "".equals(officeId.trim())) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, getMessageText(ConfigurationConstants.BRANCHOFFICE)));
    }
    if (loanOfficerId == null || "".equals(loanOfficerId.trim())) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, loanOfficer));
    }
    if (customerId == null || "".equals(customerId.trim())) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, getLabel(customerLabel)));
    }
    if (getTransactionDate() != null && !getTransactionDate().equals("")) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactionDate());
        } catch (InvalidDateException ide) {
            errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(AccountConstants.ERROR_INVALID_TRXN));
        }
    } else {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYENTER, dateOfTransaction));
    }
    if (currentDate != null && meetingDate != null && trxnDate != null && (meetingDate.compareTo(trxnDate) > 0 || trxnDate.compareTo(currentDate) > 0)) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.INVALIDENDDATE, dateOfTransaction));
    } else if (meetingDate == null && trxnDate != null && trxnDate.compareTo(currentDate) != 0) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MEETINGDATEEXCEPTION, dateOfTransaction));
    }
    if (paymentId == null || "".equals(paymentId.trim())) {
        errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, modeOfPayment));
    }
    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 35 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithEndDateLessThanStartDate.

@Test
public void testBuildloanOfferingWithEndDateLessThanStartDate() throws SystemException, ApplicationException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(-2);
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), null, 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, null, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

Date (java.sql.Date)689 Test (org.junit.Test)286 PreparedStatement (java.sql.PreparedStatement)127 ResultSet (java.sql.ResultSet)122 Timestamp (java.sql.Timestamp)117 Connection (java.sql.Connection)107 Money (org.mifos.framework.util.helpers.Money)83 ArrayList (java.util.ArrayList)66 SQLException (java.sql.SQLException)60 Properties (java.util.Properties)60 Time (java.sql.Time)55 PDate (org.apache.phoenix.schema.types.PDate)55 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)50 LocalDate (java.time.LocalDate)42 BigDecimal (java.math.BigDecimal)41 MeetingBO (org.mifos.application.meeting.business.MeetingBO)39 Test (org.testng.annotations.Test)39 Calendar (java.util.Calendar)36 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)30 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)28