List of usage examples for org.joda.time LocalDate plusDays
public LocalDate plusDays(int days)
From source file:org.libreplan.web.common.components.NewAllocationSelector.java
License:Open Source License
public void open(LocalDate start, LocalDate end) { LocalDate newStart = start.minusDays(DAYS_LEAD_LAG_TO_TASK_LIMITS_DATES_FILTERING_INITIALIZATION); LocalDate newEnd = end.plusDays(DAYS_LEAD_LAG_TO_TASK_LIMITS_DATES_FILTERING_INITIALIZATION); getController().open(newStart, newEnd); }
From source file:org.libreplan.web.dashboard.DashboardModel.java
License:Open Source License
private void calculateMarginWithDeadLine() { if (this.getRootTask() == null) { throw new RuntimeException("Root task is null"); }/*from ww w. j a va2 s. c om*/ if (this.currentOrder.getDeadline() == null) { this.marginWithDeadLine = null; return; } TaskGroup rootTask = getRootTask(); LocalDate endDate = TaskElement.maxDate(rootTask.getChildren()).asExclusiveEnd(); Days orderDuration = Days.daysBetween(TaskElement.minDate(rootTask.getChildren()).getDate(), endDate); LocalDate deadLineAsLocalDate = LocalDate.fromDateFields(currentOrder.getDeadline()); Days deadlineOffset = Days.daysBetween(endDate, deadLineAsLocalDate.plusDays(1)); BigDecimal outcome = new BigDecimal(deadlineOffset.getDays(), MathContext.DECIMAL32); this.marginWithDeadLine = orderDuration.getDays() != 0 ? outcome.divide(new BigDecimal(orderDuration.getDays()), 8, BigDecimal.ROUND_HALF_EVEN) : new BigDecimal(Days.daysBetween(rootTask.getStartAsLocalDate(), deadLineAsLocalDate.plusDays(1)) .getDays()); }
From source file:org.libreplan.web.limitingresources.QueueComponent.java
License:Open Source License
private static int getDeadlinePixels(IDatesMapper datesMapper, LocalDate deadlineDate) { // Deadline date is considered inclusively return datesMapper.toPixelsAbsolute(deadlineDate.plusDays(1).toDateTimeAtStartOfDay().getMillis()); }
From source file:org.libreplan.web.montecarlo.MonteCarloTask.java
License:Open Source License
private static LocalDate calculateEndDateFor(MonteCarloTask task, BigDecimal daysDuration) { BaseCalendar calendar = task.getCalendar(); LocalDate day = new LocalDate(task.getStartDate()); double duration = daysDuration.doubleValue(); for (int i = 0; i < duration;) { EffortDuration workableTime = calendar.getCapacityOn(PartialDay.wholeDay(day)); if (!EffortDuration.zero().equals(workableTime)) { i++;//from ww w.jav a 2 s.com } day = day.plusDays(1); } return day; }
From source file:org.libreplan.web.orders.ProjectDetailsController.java
License:Open Source License
private void calculateProjectDates(OrderTemplate template) { LocalDate initLocalDate = new LocalDate().plusDays(template.getStartAsDaysFromBeginning()); Date initDate = initLocalDate.toDateTimeAtStartOfDay().toDate(); getOrder().setInitDate(initDate);// w ww . j a va2 s . co m this.initDate.setValue(initDate); if (template.getDeadlineAsDaysFromBeginning() != null) { LocalDate deadlineLocalDate = initLocalDate.plusDays(template.getDeadlineAsDaysFromBeginning()); Date deadline = deadlineLocalDate.toDateTimeAtStartOfDay().toDate(); getOrder().setDeadline(deadline); this.deadline.setValue(deadline); } else { getOrder().setDeadline(null); this.deadline.setValue(null); } }
From source file:org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent.java
License:Open Source License
@Override public LocalDate nextMatchingDateFromAlreadyMatchingDate(LocalDate validMatchingDate) { return validMatchingDate.plusDays(every); }
From source file:org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent.java
License:Open Source License
@Override public LocalDate findFirstDateOfPeriodForMatchingDate(LocalDate matchingDate) { LocalDate previousMatchingDate = lastDayOfMonthFor(matchingDate.minusMonths(every)); return previousMatchingDate.plusDays(1); }
From source file:org.mifos.application.servicefacade.LoanAccountServiceFacadeWebTier.java
License:Open Source License
private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) { MeetingBO newMeetingForRepaymentDay = null; final int minDaysInterval = configurationPersistence .getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY); final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime() .toDate();//from w ww .j ava 2 s . c o m try { if (recurringSchedule.isWeekly()) { WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue()); Short recurEvery = recurringSchedule.getEvery().shortValue(); newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace()); } else if (recurringSchedule.isMonthly()) { if (recurringSchedule.isMonthlyOnDayOfMonth()) { Short dayOfMonth = recurringSchedule.getDay().shortValue(); Short dayRecurMonth = recurringSchedule.getEvery().shortValue(); newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace()); } else { Short weekOfMonth = recurringSchedule.getDay().shortValue(); Short monthRank = recurringSchedule.getWeek().shortValue(); Short everyMonth = recurringSchedule.getEvery().shortValue(); newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank); } } else { Short recurEvery = recurringSchedule.getEvery().shortValue(); newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace()); } return newMeetingForRepaymentDay; } catch (NumberFormatException nfe) { throw new MifosRuntimeException(nfe); } catch (MeetingException me) { throw new BusinessRuleException(me.getKey(), me); } }
From source file:org.mifos.application.servicefacade.SavingsServiceFacadeWebTier.java
License:Open Source License
private boolean withdrawalMakesBalanceNegativeOnDate(SavingsBO savingsAccount, Money amount, LocalDate trxnDate) { List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor( savingsAccount.getCurrency(), savingsAccount.getAccountId().longValue()); MifosCurrency currencyInUse = savingsAccount.getCurrency(); Money balanceOnDateOfWithdrawal = calculateAccountBalanceOn(trxnDate.plusDays(1), allEndOfDayDetailsForAccount, currencyInUse); return amount.isGreaterThan(balanceOnDateOfWithdrawal); }
From source file:org.mifosplatform.portfolio.loanaccount.domain.Loan.java
License:Mozilla Public License
public void updateLoanRepaymentScheduleDates(final LocalDate meetingStartDate, final String recuringRule, final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays, final Boolean reschedulebasedOnMeetingDates, final LocalDate presentMeetingDate, final LocalDate newMeetingDate) { // first repayment's from date is same as disbursement date. /*/*from w w w . j a va 2 s. co m*/ * meetingStartDate is used as seedDate Capture the seedDate from user * and use the seedDate as meetingStart date */ LocalDate tmpFromDate = getDisbursementDate(); final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail .getRepaymentPeriodFrequencyType(); final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery(); final String frequency = CalendarUtils .getMeetingFrequencyFromPeriodFrequencyType(repaymentPeriodFrequencyType); LocalDate newRepaymentDate = null; Boolean isFirstTime = true; for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) { LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate(); if (oldDueDate.isEqual(presentMeetingDate) || oldDueDate.isAfter(presentMeetingDate)) { if (isFirstTime) { isFirstTime = false; newRepaymentDate = newMeetingDate; } else { // tmpFromDate.plusDays(1) is done to make sure // getNewRepaymentMeetingDate method returns next meeting // date and not the same as tmpFromDate newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, tmpFromDate, tmpFromDate.plusDays(1), loanRepaymentInterval, frequency, workingDays); } if (isHolidayEnabled) { newRepaymentDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(newRepaymentDate, holidays); } loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate); // reset from date to get actual daysInPeriod if (!isFirstTime) { loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); } tmpFromDate = newRepaymentDate;// update with new repayment // date } else { tmpFromDate = oldDueDate; } } }