List of usage examples for org.joda.time LocalDate isAfter
public boolean isAfter(ReadablePartial partial)
From source file:com.gst.infrastructure.core.domain.LocalDateInterval.java
License:Apache License
private boolean isBetweenInclusive(final LocalDate start, final LocalDate end, final LocalDate target) { return !target.isBefore(start) && !target.isAfter(end); }
From source file:com.gst.infrastructure.core.service.DateUtils.java
License:Apache License
public static boolean isDateInTheFuture(final LocalDate localDate) { return localDate.isAfter(getLocalDateOfTenant()); }
From source file:com.gst.organisation.holiday.service.HolidayUtil.java
License:Apache License
public static LocalDate getRepaymentRescheduleDateToIfHoliday(LocalDate repaymentDate, final List<Holiday> holidays) { for (final Holiday holiday : holidays) { if (repaymentDate.equals(holiday.getFromDateLocalDate()) || repaymentDate.equals(holiday.getToDateLocalDate()) || (repaymentDate.isAfter(holiday.getFromDateLocalDate()) && repaymentDate.isBefore(holiday.getToDateLocalDate()))) { repaymentDate = getRepaymentRescheduleDateIfHoliday(repaymentDate, holidays); }/*ww w .j ava 2 s. co m*/ } return repaymentDate; }
From source file:com.gst.organisation.holiday.service.HolidayUtil.java
License:Apache License
private static LocalDate getRepaymentRescheduleDateIfHoliday(final LocalDate repaymentDate, final List<Holiday> holidays) { for (final Holiday holiday : holidays) { if (repaymentDate.equals(holiday.getFromDateLocalDate()) || repaymentDate.equals(holiday.getToDateLocalDate()) || (repaymentDate.isAfter(holiday.getFromDateLocalDate()) && repaymentDate.isBefore(holiday.getToDateLocalDate()))) { // should be take from holiday return holiday.getRepaymentsRescheduledToLocalDate(); }// w ww . j a v a2s .c o m } return repaymentDate; }
From source file:com.gst.organisation.holiday.service.HolidayUtil.java
License:Apache License
public static boolean isHoliday(final LocalDate date, final List<Holiday> holidays) { for (final Holiday holiday : holidays) { if (date.isEqual(holiday.getFromDateLocalDate()) || date.isEqual(holiday.getToDateLocalDate()) || (date.isAfter(holiday.getFromDateLocalDate()) && date.isBefore(holiday.getToDateLocalDate()))) { return true; }/*from ww w . j a v a 2s . c om*/ } return false; }
From source file:com.gst.organisation.holiday.service.HolidayWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private void validateInputDates(final LocalDate fromDate, final LocalDate toDate, final LocalDate repaymentsRescheduledTo) { String defaultUserMessage = ""; if (toDate.isBefore(fromDate)) { defaultUserMessage = "To Date date cannot be before the From Date."; throw new HolidayDateException("to.date.cannot.be.before.from.date", defaultUserMessage, fromDate.toString(), toDate.toString()); }/* w ww. j a va 2 s . com*/ if (repaymentsRescheduledTo.isEqual(fromDate) || repaymentsRescheduledTo.isEqual(toDate) || (repaymentsRescheduledTo.isAfter(fromDate) && repaymentsRescheduledTo.isBefore(toDate))) { defaultUserMessage = "Repayments rescheduled date should be before from date or after to date."; throw new HolidayDateException( "repayments.rescheduled.date.should.be.before.from.date.or.after.to.date", defaultUserMessage, repaymentsRescheduledTo.toString()); } final WorkingDays workingDays = this.daysRepositoryWrapper.findOne(); final Boolean isRepaymentOnWorkingDay = WorkingDaysUtil.isWorkingDay(workingDays, repaymentsRescheduledTo); if (!isRepaymentOnWorkingDay) { defaultUserMessage = "Repayments rescheduled date should not fall on non working days"; throw new HolidayDateException("repayments.rescheduled.date.should.not.fall.on.non.working.day", defaultUserMessage, repaymentsRescheduledTo.toString()); } // validate repaymentsRescheduledTo date // 1. should be within a 7 days date range. // 2. Alternative date should not be an exist holiday.//TBD // 3. Holiday should not be on an repaymentsRescheduledTo date of // another holiday.//TBD // restricting repaymentsRescheduledTo date to be within 7 days range // before or after from date and to date. if (repaymentsRescheduledTo.isBefore(fromDate.minusDays(7)) || repaymentsRescheduledTo.isAfter(toDate.plusDays(7))) { defaultUserMessage = "Repayments Rescheduled to date must be within 7 days before or after from and to dates"; throw new HolidayDateException("repayments.rescheduled.to.must.be.within.range", defaultUserMessage, fromDate.toString(), toDate.toString(), repaymentsRescheduledTo.toString()); } }
From source file:com.gst.portfolio.calendar.service.CalendarReadPlatformServiceImpl.java
License:Apache License
private LocalDate getPeriodEndDate(LocalDate endDate, LocalDate tillDate) { LocalDate periodEndDate = endDate; final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); if (tillDate != null) { if (endDate != null) { if (endDate.isAfter(tillDate)) { // to retrieve meeting dates tillspecified date (tillDate) periodEndDate = tillDate; }/*from w w w . ja va2 s. c o m*/ } else { // end date is null then fetch meeting dates tillDate periodEndDate = tillDate; } } else if (endDate == null || endDate.isAfter(currentDate.plusYears(1))) { periodEndDate = currentDate.plusYears(1); } return periodEndDate; }
From source file:com.gst.portfolio.client.domain.Client.java
License:Apache License
public static Client createNew(final AppUser currentUser, final Office clientOffice, final Group clientParentGroup, final Staff staff, final Long savingsProductId, final CodeValue gender, final CodeValue clientType, final CodeValue clientClassification, final Integer legalForm, final JsonCommand command) { final String accountNo = command.stringValueOfParameterNamed(ClientApiConstants.accountNoParamName); final String externalId = command.stringValueOfParameterNamed(ClientApiConstants.externalIdParamName); final String mobileNo = command.stringValueOfParameterNamed(ClientApiConstants.mobileNoParamName); final String firstname = command.stringValueOfParameterNamed(ClientApiConstants.firstnameParamName); final String middlename = command.stringValueOfParameterNamed(ClientApiConstants.middlenameParamName); final String lastname = command.stringValueOfParameterNamed(ClientApiConstants.lastnameParamName); final String fullname = command.stringValueOfParameterNamed(ClientApiConstants.fullnameParamName); final LocalDate dataOfBirth = command .localDateValueOfParameterNamed(ClientApiConstants.dateOfBirthParamName); ClientStatus status = ClientStatus.PENDING; boolean active = false; if (command.hasParameter("active")) { active = command.booleanPrimitiveValueOfParameterNamed(ClientApiConstants.activeParamName); }//from w w w .j a va 2 s .co m LocalDate activationDate = null; LocalDate officeJoiningDate = null; if (active) { status = ClientStatus.ACTIVE; activationDate = command.localDateValueOfParameterNamed(ClientApiConstants.activationDateParamName); officeJoiningDate = activationDate; } LocalDate submittedOnDate = new LocalDate(); if (active && submittedOnDate.isAfter(activationDate)) { submittedOnDate = activationDate; } if (command.hasParameter(ClientApiConstants.submittedOnDateParamName)) { submittedOnDate = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName); } final Long savingsAccountId = null; return new Client(currentUser, status, clientOffice, clientParentGroup, accountNo, firstname, middlename, lastname, fullname, activationDate, officeJoiningDate, externalId, mobileNo, staff, submittedOnDate, savingsProductId, savingsAccountId, dataOfBirth, gender, clientType, clientClassification, legalForm); }
From source file:com.gst.portfolio.floatingrates.domain.FloatingRate.java
License:Apache License
private void updateRatePeriods(final List<FloatingRatePeriod> newRatePeriods, final AppUser appUser) { final LocalDate today = DateUtils.getLocalDateOfTenant(); if (this.floatingRatePeriods != null) { for (FloatingRatePeriod ratePeriod : this.floatingRatePeriods) { LocalDate fromDate = LocalDate.fromDateFields(ratePeriod.getFromDate()); if (fromDate.isAfter(today)) { ratePeriod.setActive(false); ratePeriod.setModifiedBy(appUser); ratePeriod.setModifiedOn(today.toDate()); }//from ww w .j a va 2 s . c o m } } for (FloatingRatePeriod newRatePeriod : newRatePeriods) { newRatePeriod.updateFloatingRate(this); this.floatingRatePeriods.add(newRatePeriod); } }
From source file:com.gst.portfolio.group.service.GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private CommandProcessingResult createGroupingType(final JsonCommand command, final GroupTypes groupingType, final Long centerId) { try {/*w ww. ja va 2s. c om*/ final String accountNo = command .stringValueOfParameterNamed(GroupingTypesApiConstants.accountNoParamName); final String name = command.stringValueOfParameterNamed(GroupingTypesApiConstants.nameParamName); final String externalId = command .stringValueOfParameterNamed(GroupingTypesApiConstants.externalIdParamName); final AppUser currentUser = this.context.authenticatedUser(); Long officeId = null; Group parentGroup = null; if (centerId == null) { officeId = command.longValueOfParameterNamed(GroupingTypesApiConstants.officeIdParamName); } else { parentGroup = this.groupRepository.findOneWithNotFoundDetection(centerId); officeId = parentGroup.officeId(); } final Office groupOffice = this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId); final LocalDate activationDate = command .localDateValueOfParameterNamed(GroupingTypesApiConstants.activationDateParamName); final GroupLevel groupLevel = this.groupLevelRepository.findOne(groupingType.getId()); validateOfficeOpeningDateisAfterGroupOrCenterOpeningDate(groupOffice, groupLevel, activationDate); Staff staff = null; final Long staffId = command.longValueOfParameterNamed(GroupingTypesApiConstants.staffIdParamName); if (staffId != null) { staff = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(staffId, groupOffice.getHierarchy()); } final Set<Client> clientMembers = assembleSetOfClients(officeId, command); final Set<Group> groupMembers = assembleSetOfChildGroups(officeId, command); final boolean active = command .booleanPrimitiveValueOfParameterNamed(GroupingTypesApiConstants.activeParamName); LocalDate submittedOnDate = new LocalDate(); if (active && submittedOnDate.isAfter(activationDate)) { submittedOnDate = activationDate; } if (command.hasParameter(GroupingTypesApiConstants.submittedOnDateParamName)) { submittedOnDate = command .localDateValueOfParameterNamed(GroupingTypesApiConstants.submittedOnDateParamName); } final Group newGroup = Group.newGroup(groupOffice, staff, parentGroup, groupLevel, name, externalId, active, activationDate, clientMembers, groupMembers, submittedOnDate, currentUser, accountNo); boolean rollbackTransaction = false; if (newGroup.isActive()) { this.groupRepository.save(newGroup); // validate Group creation rules for Group if (newGroup.isGroup()) { validateGroupRulesBeforeActivation(newGroup); } if (newGroup.isCenter()) { final CommandWrapper commandWrapper = new CommandWrapperBuilder().activateCenter(null).build(); rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser); } else { final CommandWrapper commandWrapper = new CommandWrapperBuilder().activateGroup(null).build(); rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser); } } if (!newGroup.isCenter() && newGroup.hasActiveClients()) { final CommandWrapper commandWrapper = new CommandWrapperBuilder() .associateClientsToGroup(newGroup.getId()).build(); rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser); } // pre-save to generate id for use in group hierarchy this.groupRepository.save(newGroup); /* * Generate hierarchy for a new center/group and all the child * groups if they exist */ newGroup.generateHierarchy(); /* Generate account number if required */ generateAccountNumberIfRequired(newGroup); this.groupRepository.saveAndFlush(newGroup); newGroup.captureStaffHistoryDuringCenterCreation(staff, activationDate); if (newGroup.isGroup()) { if (command.parameterExists(GroupingTypesApiConstants.datatables)) { this.entityDatatableChecksWritePlatformService.saveDatatables( StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), newGroup.getId(), null, command.arrayOfParameterNamed(GroupingTypesApiConstants.datatables)); } this.entityDatatableChecksWritePlatformService.runTheCheck(newGroup.getId(), EntityTables.GROUP.getName(), StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable()); } return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withOfficeId(groupOffice.getId()) // .withGroupId(newGroup.getId()) // .withEntityId(newGroup.getId()) // .setRollbackTransaction(rollbackTransaction)// .build(); } catch (final DataIntegrityViolationException dve) { handleGroupDataIntegrityIssues(command, dve.getMostSpecificCause(), dve, groupingType); return CommandProcessingResult.empty(); } catch (final PersistenceException dve) { Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()); handleGroupDataIntegrityIssues(command, throwable, dve, groupingType); return CommandProcessingResult.empty(); } }