Search in sources :

Example 86 with Calendar

use of java.util.Calendar in project head by mifos.

the class CreateLoanAccountReviewInstallmentPage method typeInstallmentDueDateByPicker.

public void typeInstallmentDueDateByPicker(Integer installment, Calendar dueDate) {
    selenium.click("//table[@id='installments']/tbody/tr[" + installment + "]/td[2]/img");
    Calendar calendar = Calendar.getInstance();
    calendar.set(getYearFromCalendar(), getMonthFromCalendar(), dueDate.get(Calendar.DATE));
    Integer months = 0;
    if (calendar.before(dueDate)) {
        if (calendar.get(Calendar.YEAR) == dueDate.get(Calendar.YEAR)) {
            months = dueDate.get(Calendar.MONTH) - calendar.get(Calendar.MONTH);
        } else {
            months = dueDate.get(Calendar.YEAR) - calendar.get(Calendar.YEAR) * 12 + (dueDate.get(Calendar.MONTH) + 1) + calendar.get(Calendar.MONTH);
        }
        for (int i = 0; i < months; i++) {
            clickNextMonth();
        }
    } else if (calendar.after(dueDate)) {
        if (calendar.get(Calendar.YEAR) == dueDate.get(Calendar.YEAR)) {
            months = calendar.get(Calendar.MONTH) - dueDate.get(Calendar.MONTH);
        } else {
            months = calendar.get(Calendar.YEAR) - dueDate.get(Calendar.YEAR) * 12 + (calendar.get(Calendar.MONTH) + 1) + dueDate.get(Calendar.MONTH);
        }
        for (int i = 0; i < months; i++) {
            clickPrevMonth();
        }
    }
    chooseDay(dueDate.get(Calendar.DATE));
    Assert.assertEquals(getDueDateForInstallment(installment), format.format(dueDate.getTime()));
}
Also used : Calendar(java.util.Calendar)

Example 87 with Calendar

use of java.util.Calendar in project head by mifos.

the class LegacyLoanDao method getLoanAccountsInArrearsInGoodStanding.

@SuppressWarnings("unchecked")
public List<Integer> getLoanAccountsInArrearsInGoodStanding(final Short latenessDays) throws PersistenceException, InvalidDateException {
    /*
         * TODO: refactor to use Joda Time This code appears to be trying to just get a date that is "latenessDays"
         * before the current date.
         */
    String systemDate = DateUtils.getCurrentDate();
    Date localDate = DateUtils.getLocaleDate(systemDate);
    Calendar currentDate = new GregorianCalendar();
    currentDate.setTime(localDate);
    int year = currentDate.get(Calendar.YEAR);
    int month = currentDate.get(Calendar.MONTH);
    int day = currentDate.get(Calendar.DAY_OF_MONTH);
    currentDate = new GregorianCalendar(year, month, day - latenessDays);
    Date date = new Date(currentDate.getTimeInMillis());
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("ACCOUNTTYPE_ID", AccountTypes.LOAN_ACCOUNT.getValue());
    queryParameters.put("PAYMENTSTATUS", Short.valueOf(PaymentStatus.UNPAID.getValue()));
    queryParameters.put("LOANACTIVEINGOODSTAND", Short.valueOf(AccountStates.LOANACC_ACTIVEINGOODSTANDING));
    queryParameters.put("CHECKDATE", date);
    return executeNamedQuery(NamedQueryConstants.GET_LOAN_ACOUNTS_IN_ARREARS_IN_GOOD_STANDING, queryParameters);
}
Also used : HashMap(java.util.HashMap) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Example 88 with Calendar

use of java.util.Calendar in project head by mifos.

the class MeetingBO method isValidMeetingDate.

public boolean isValidMeetingDate(final Date meetingDate, final Date endDate) throws MeetingException {
    validateMeetingDate(meetingDate);
    validateEndDate(endDate);
    DateTime currentScheduleDateTime = findNearestMatchingDate(new DateTime(this.meetingStartDate));
    Date currentScheduleDate = currentScheduleDateTime.toDate();
    Calendar c = Calendar.getInstance();
    c.setTime(currentScheduleDate);
    currentScheduleDate = getNextWorkingDay(c).getTime();
    Date meetingDateWOTimeStamp = DateUtils.getDateWithoutTimeStamp(meetingDate.getTime());
    Date endDateWOTimeStamp = DateUtils.getDateWithoutTimeStamp(endDate.getTime());
    if (meetingDateWOTimeStamp.compareTo(endDateWOTimeStamp) > 0) {
        return false;
    }
    while (currentScheduleDate.compareTo(meetingDateWOTimeStamp) < 0 && currentScheduleDate.compareTo(endDateWOTimeStamp) < 0) {
        currentScheduleDate = findNextMatchingDate(new DateTime(currentScheduleDate)).toDate();
        c.setTime(currentScheduleDate);
        currentScheduleDate = getNextWorkingDay(c).getTime();
    }
    boolean isRepaymentIndepOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
    if (isRepaymentIndepOfMeetingEnabled) {
        return currentScheduleDate.compareTo(endDateWOTimeStamp) <= 0;
    }
    // match
    return currentScheduleDate.compareTo(endDateWOTimeStamp) <= 0 && currentScheduleDate.compareTo(meetingDateWOTimeStamp) == 0;
}
Also used : ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) Calendar(java.util.Calendar) DateTime(org.joda.time.DateTime) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 89 with Calendar

use of java.util.Calendar in project head by mifos.

the class AccountingServiceFacadeWebTier method updateFinancialYear.

@Override
public FinancialYearBO updateFinancialYear(FinancialYearBO oldFinancialYearBO, UserContext context) {
    FinancialYearBO newFinancialYearBO = null;
    //updating current financial year as Inactive
    accountingDao.savingFinancialYearBO(oldFinancialYearBO);
    this.hibernateTransactionHelper.flushSession();
    //creating new Finincial year
    Calendar calendar = new GregorianCalendar();
    newFinancialYearBO = new FinancialYearBO();
    newFinancialYearBO.setFinancialYearStartDate(nextYear(oldFinancialYearBO.getFinancialYearStartDate(), calendar));
    newFinancialYearBO.setFinancialYearEndDate(nextYear(oldFinancialYearBO.getFinancialYearEndDate(), calendar));
    try {
        newFinancialYearBO.setCreatedDate(DateUtils.getLocaleDate(context.getPreferredLocale(), DateUtils.getCurrentDate(context.getPreferredLocale())));
    } catch (InvalidDateException e) {
        throw new MifosRuntimeException(e);
    }
    newFinancialYearBO.setCreatedBy(context.getId());
    newFinancialYearBO.setStatus(SimpleAccountingConstants.ACTIVE);
    calendar.setTime(newFinancialYearBO.getFinancialYearStartDate());
    newFinancialYearBO.setFinancialYearId(Integer.parseInt(calendar.get(calendar.YEAR) + "" + calendar.get(calendar.YEAR)));
    newFinancialYearBO = accountingDao.savingFinancialYearBO(newFinancialYearBO);
    this.hibernateTransactionHelper.flushSession();
    return newFinancialYearBO;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) FinancialYearBO(org.mifos.application.accounting.business.FinancialYearBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 90 with Calendar

use of java.util.Calendar in project head by mifos.

the class AccountingServiceFacadeWebTier method processMisPostings.

@Override
public boolean processMisPostings(Date lastProcessDate, Date processTillDate, Short createdBy) {
    boolean flag = false;
    while (lastProcessDate.compareTo(processTillDate) < 0) {
        Calendar c = Calendar.getInstance();
        c.setTime(lastProcessDate);
        c.add(Calendar.DATE, 1);
        Date newDate = c.getTime();
        lastProcessDate = newDate;
        processListOfTransactions(accountingDao.processMisPostings(lastProcessDate), createdBy);
        accountingDao.updateLastProcessDate(lastProcessDate);
    }
    return flag;
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Aggregations

Calendar (java.util.Calendar)9446 Date (java.util.Date)2436 GregorianCalendar (java.util.GregorianCalendar)2130 Test (org.junit.Test)1735 SimpleDateFormat (java.text.SimpleDateFormat)889 ArrayList (java.util.ArrayList)476 ParseException (java.text.ParseException)353 HashMap (java.util.HashMap)270 TimeZone (java.util.TimeZone)270 IOException (java.io.IOException)235 DateFormat (java.text.DateFormat)224 Timestamp (java.sql.Timestamp)194 List (java.util.List)187 File (java.io.File)167 Map (java.util.Map)149 BigDecimal (java.math.BigDecimal)134 Locale (java.util.Locale)134 Test (org.testng.annotations.Test)118 Identity (org.olat.core.id.Identity)112 Date (java.sql.Date)110