use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class JpaEventAggregationManagementDaoTest method testAcademicTermDetails.
@Test
public void testAcademicTermDetails() throws Exception {
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
assertEquals(0, academicTermDetail.size());
List<AcademicTermDetail> academicTermDetails = new ArrayList<AcademicTermDetail>();
academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2012, 6, 1), "Spring 2012"));
academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 6, 1), new DateMidnight(2012, 9, 1), "Summer 2012"));
academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 9, 1), new DateMidnight(2013, 1, 1), "Fall 2012"));
eventAggregationManagementDao.setAcademicTermDetails(academicTermDetails);
}
});
try {
this.executeInTransaction(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
assertEquals(3, academicTermDetail.size());
academicTermDetail.add(new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2013, 6, 1), "Spring 2013"));
try {
eventAggregationManagementDao.setAcademicTermDetails(academicTermDetail);
fail();
} catch (IllegalArgumentException e) {
// expected
}
}
});
fail();
} catch (TransactionSystemException e) {
// Expected
}
this.executeInTransaction(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
assertEquals(3, academicTermDetail.size());
academicTermDetail.get(0).setTermName("New Term");
academicTermDetail.remove(2);
eventAggregationManagementDao.setAcademicTermDetails(academicTermDetail);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
assertEquals(2, academicTermDetail.size());
}
});
}
use of org.joda.time.DateMidnight in project OpenClinica by OpenClinica.
the class OpenClinicaBeanVariableNode method calculateVariable.
private Object calculateVariable() {
if (number.equals("_CURRENT_DATE")) {
String ssTimeZone = getExpressionBeanService().getSSTimeZone();
if (ssTimeZone.equals("") || ssTimeZone == null)
ssTimeZone = TimeZone.getDefault().getID();
DateTimeZone ssZone = DateTimeZone.forID(ssTimeZone);
DateMidnight dm = new DateMidnight(ssZone);
DateTimeFormatter fmt = ISODateTimeFormat.date();
return fmt.print(dm);
}
return null;
}
use of org.joda.time.DateMidnight in project OpenClinica by OpenClinica.
the class ArithmeticOpNode method calculateDaysBetween.
private String calculateDaysBetween(String value1, String value2) {
DateMidnight dm1 = new DateMidnight(ExpressionTreeHelper.getDate(value1).getTime());
DateMidnight dm2 = new DateMidnight(ExpressionTreeHelper.getDate(value2).getTime());
switch(op) {
case MINUS:
{
Days d = Days.daysBetween(dm1, dm2);
int days = d.getDays();
return String.valueOf(Math.abs(days));
}
default:
// Bad operator!
return null;
}
}
use of org.joda.time.DateMidnight in project head by mifos.
the class InterestPostingAccountingEntryTest method testBuildAccountEntryForAction.
@Test
public void testBuildAccountEntryForAction() throws FinancialException {
// setup
DateMidnight savingsTrxnDetailActionDate = new DateMidnight(2009, 9, 9);
DateMidnight savingsTrxnDetailCreationDate = new DateMidnight(2009, 1, 1);
MifosCurrency currency = TestUtils.RUPEE;
// stubbing
when(savingsTrxnDetail.getAccount()).thenReturn(savingsBO);
when(savingsTrxnDetail.getInterestAmount()).thenReturn(new Money(currency, interestAmount));
when(savingsTrxnDetail.getActionDate()).thenReturn(savingsTrxnDetailActionDate.toDate());
when(savingsTrxnDetail.getTrxnCreatedDate()).thenReturn(new Timestamp(savingsTrxnDetailCreationDate.getMillis()));
when(savingsTrxnDetail.getPersonnel()).thenReturn(transactionCreator);
when(savingsBO.getSavingsOffering()).thenReturn(savingsOffering);
when(savingsOffering.getInterestGLCode()).thenReturn(coaSavingsInterestPayable.getAssociatedGlcode());
when(savingsOffering.getDepositGLCode()).thenReturn(coaClientsSavings.getAssociatedGlcode());
SavingsInterestPostingFinancialActivity financialActivity = new SavingsInterestPostingFinancialActivity(savingsTrxnDetail);
// exercise test
interestPostingAccountingEntry.buildAccountEntryForAction(financialActivity);
// verification
List<FinancialTransactionBO> transactions = financialActivity.getFinanacialTransaction();
assertThat(transactions.size(), is(2));
/*
* Sort by GLCode strings so "22100" (interest payable tran) should be first, followed by "22200" (client
* savings tran)
*/
Collections.sort(transactions, new GLCodeComparator());
Iterator<FinancialTransactionBO> it = transactions.iterator();
FinancialTransactionBO interestPostingTrans = it.next();
assertThat(interestPostingTrans.getActionDate(), is(savingsTrxnDetailActionDate.toDate()));
assertThat(interestPostingTrans.getPostedDate(), is(savingsTrxnDetailCreationDate.toDate()));
assertThat(interestPostingTrans.getPostedAmount(), is(new Money(currency, interestAmount)));
assertThat(interestPostingTrans.getGlcode().getGlcode(), is(coaSavingsInterestPayable.getGlCode()));
assertThat(interestPostingTrans.getDebitCreditFlag(), is(FinancialConstants.DEBIT.getValue()));
assertThat(interestPostingTrans.getPostedBy(), is(transactionCreator));
FinancialTransactionBO savingsPostingTrans = it.next();
assertThat(savingsPostingTrans.getActionDate(), is(savingsTrxnDetailActionDate.toDate()));
assertThat(savingsPostingTrans.getPostedDate(), is(savingsTrxnDetailCreationDate.toDate()));
assertThat(savingsPostingTrans.getPostedAmount(), is(new Money(currency, interestAmount)));
assertThat(savingsPostingTrans.getGlcode().getGlcode(), is(coaClientsSavings.getGlCode()));
assertThat(savingsPostingTrans.getDebitCreditFlag(), is(FinancialConstants.CREDIT.getValue()));
assertThat(savingsPostingTrans.getPostedBy(), is(transactionCreator));
}
use of org.joda.time.DateMidnight in project head by mifos.
the class AccountGetFeeDatesIntegrationTest method getScheduledDatesForFeesForGivenCustomerForWeeklySchedules.
@Test
public void getScheduledDatesForFeesForGivenCustomerForWeeklySchedules() throws Exception {
// setup
DateTime firstTuesdayInstallmentDate = new DateMidnight().toDateTime().withDate(2010, 4, 20);
weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(firstTuesdayInstallmentDate).build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).withStartDate(firstTuesdayInstallmentDate);
weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly);
center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
DateTime meetingStartDate = firstTuesdayInstallmentDate.minusDays(7);
MeetingBO feeMeetingFrequency = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(meetingStartDate.toDate()).build();
InstallmentDate installment1 = new InstallmentDate(Short.valueOf("1"), firstTuesdayInstallmentDate.toDate());
InstallmentDate installment2 = new InstallmentDate(Short.valueOf("2"), firstTuesdayInstallmentDate.plusWeeks(1).toDate());
InstallmentDate installment3 = new InstallmentDate(Short.valueOf("3"), firstTuesdayInstallmentDate.plusWeeks(2).toDate());
InstallmentDate installment4 = new InstallmentDate(Short.valueOf("4"), firstTuesdayInstallmentDate.plusWeeks(3).toDate());
List<InstallmentDate> installmentDates = Arrays.asList(installment1, installment2, installment3, installment4);
// exercise test
CustomerAccountBO customerAccount = center.getCustomerAccount();
List<Date> feeDates = customerAccount.getFeeDates(feeMeetingFrequency, installmentDates);
// verification
assertThat(feeDates.get(0), is(firstTuesdayInstallmentDate.toDate()));
assertThat(feeDates.get(1), is(firstTuesdayInstallmentDate.plusWeeks(1).toDate()));
assertThat(feeDates.get(2), is(firstTuesdayInstallmentDate.plusWeeks(2).toDate()));
assertThat(feeDates.get(3), is(firstTuesdayInstallmentDate.plusWeeks(3).toDate()));
}
Aggregations