use of org.joda.time.LocalDate in project head by mifos.
the class SavingsApplyAdjustmentActionForm method getTrxnDateLocal.
public LocalDate getTrxnDateLocal() {
LocalDate trxnDate = null;
if (isTrxnDateEntered()) {
Integer day = Integer.parseInt(trxnDateDD);
Integer month = Integer.parseInt(trxnDateMM);
Integer year = Integer.parseInt(trxnDateYY);
trxnDate = new LocalDate(year, month, day);
}
return trxnDate;
}
use of org.joda.time.LocalDate in project head by mifos.
the class LoanArrearsAgingHelper method generateLoanArrearsAging.
private void generateLoanArrearsAging() throws BatchJobException {
StaticHibernateUtil.startTransaction();
try {
Query insert_select = StaticHibernateUtil.getSessionTL().getNamedQuery("generateLoanArrearsAging");
insert_select.setParameter("CURRENT_DATE", new LocalDate().toString());
insert_select.executeUpdate();
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new BatchJobException(e);
}
}
use of org.joda.time.LocalDate in project head by mifos.
the class ApplyPenaltyToLoanAccountsHelper method execute.
@Override
public void execute(final long timeInMillis) throws BatchJobException {
setCurrentDates(timeInMillis);
List<String> errorList = new ArrayList<String>();
List<LoanBO> loanAccounts;
try {
loanAccounts = getLoanAccounts();
} catch (Exception e) {
throw new BatchJobException(e);
}
if (loanAccounts != null && !loanAccounts.isEmpty()) {
Integer loanAccountId = null;
try {
for (LoanBO loanAccount : loanAccounts) {
loanAccountId = loanAccount.getAccountId();
List<AccountPenaltiesEntity> penaltyEntities = new ArrayList<AccountPenaltiesEntity>(loanAccount.getAccountPenalties());
for (AccountPenaltiesEntity penaltyEntity : penaltyEntities) {
List<LoanScheduleEntity> lateInstallments = loanAccount.getDetailsOfLateInstallmentsPeriod(new LocalDate(penaltyEntity.getCreatedDate()), currentLocalDate);
for (LoanScheduleEntity entity : lateInstallments) {
//check grace period for installment period type
if (penaltyEntity.getPenalty().getPeriodType().getPenaltyPeriod() == PenaltyPeriod.INSTALLMENTS && penaltyEntity.hasPeriodType()) {
if (lateInstallments.get(0).getInstallmentId().equals(entity.getInstallmentId()) && checkGracePeriodTypeInstallments(lateInstallments, penaltyEntity.getPenalty().getPeriodDuration())) {
continue;
}
} else //check grace period for daily period type
if (penaltyEntity.getPenalty().getPeriodType().getPenaltyPeriod() == PenaltyPeriod.DAYS && penaltyEntity.hasPeriodType()) {
if (checkGracePeriodTypeDays(entity, penaltyEntity.getPenalty().getPeriodDuration())) {
continue;
}
}
LoanPenaltyScheduleEntity penaltySchedule = entity.getPenaltyScheduleEntity(penaltyEntity.getPenalty().getPenaltyId());
if (checkPeriod(penaltyEntity, new LocalDate(entity.getActionDate().getTime())) || (penaltySchedule != null && penaltySchedule.isOn(currentLocalDate))) {
continue;
}
if (penaltyEntity.isAmountPenalty()) {
addAmountPenalty(penaltyEntity, loanAccount, entity);
} else {
addRatePenalty(penaltyEntity, loanAccount, entity);
}
}
}
}
} catch (Exception e) {
if (loanAccountId != null) {
getLogger().error(String.format("ApplyPenaltyToLoanAccountsTask execute failed with exception %s: %s at loan account %s", e.getClass().getName(), e.getMessage(), loanAccountId.toString()), e);
errorList.add(loanAccountId.toString());
}
StaticHibernateUtil.rollbackTransaction();
} finally {
StaticHibernateUtil.closeSession();
}
}
if (!errorList.isEmpty()) {
throw new BatchJobException(SchedulerConstants.FAILURE, errorList);
}
}
use of org.joda.time.LocalDate in project head by mifos.
the class SavingsDaoHibernateIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
enableCustomWorkingDays();
weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
weeklyPeriodicFeeForGroupOnly = new FeeBuilder().appliesToGroupsOnly().withFeeAmount("50.0").withName("Group Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForGroupOnly);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withFee(weeklyPeriodicFeeForGroupOnly).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
weeklyPeriodicFeeForClientsOnly = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForClientsOnly);
client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, weeklyMeeting);
customerHierarchyParams = new CustomerHierarchyParams(center.getCustomerId(), center.getOffice().getOfficeId(), center.getSearchId() + ".%", new LocalDate());
baseDao = new GenericDaoHibernate();
savingsDao = new SavingsDaoHibernate(baseDao);
}
use of org.joda.time.LocalDate in project head by mifos.
the class MonthlyOnLastDayOfMonthInterestScheduledEventTest method shouldReturnDateWithLastDayOfMonthOneMonthFromJan.
@Test
public void shouldReturnDateWithLastDayOfMonthOneMonthFromJan() {
// setup
int every = 1;
monthlyEvent = new MonthlyOnLastDayOfMonthInterestScheduledEvent(every);
// exercise test
LocalDate nextValidMatchingDate = monthlyEvent.nextMatchingDateFromAlreadyMatchingDate(jan31st);
assertThat(nextValidMatchingDate, is(feb28th));
}
Aggregations