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()));
}
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);
}
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;
}
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;
}
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;
}
Aggregations