List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.apache.fineract.infrastructure.scheduledemail.domain.EmailCampaign.java
License:Apache License
public void reactivate(final AppUser currentUser, final DateTimeFormatter dateTimeFormat, final LocalDate reactivateLocalDate) { if (!isClosed()) { //handle errors if already activated final String defaultUserMessage = "Cannot reactivate campaign. Campaign must be in closed state."; final ApiParameterError error = ApiParameterError.parameterError("error.msg.campaign.must.be.closed", defaultUserMessage, EmailCampaignValidator.statusParamName, EmailCampaignStatus.fromInt(this.status).getCode()); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException(dataValidationErrors); }//w ww .jav a 2s .com this.approvedOnDate = reactivateLocalDate.toDate(); this.status = EmailCampaignStatus.ACTIVE.getValue(); this.approvedBy = currentUser; this.closureDate = null; this.isVisible = true; this.closedBy = null; validateReactivate(); }
From source file:org.apache.fineract.infrastructure.sms.domain.SmsCampaign.java
License:Apache License
private SmsCampaign(final String campaignName, final Integer campaignType, final Report businessRuleId, final String paramValue, final String message, final LocalDate submittedOnDate, final AppUser submittedBy, final String recurrence, final LocalDateTime localDateTime) { this.campaignName = campaignName; this.campaignType = SmsCampaignType.fromInt(campaignType).getValue(); this.businessRuleId = businessRuleId; this.paramValue = paramValue; this.status = SmsCampaignStatus.PENDING.getValue(); this.message = message; this.submittedOnDate = submittedOnDate.toDate(); this.submittedBy = submittedBy; this.recurrence = recurrence; LocalDateTime recurrenceStartDate = new LocalDateTime(); this.isVisible = true; if (localDateTime != null) { this.recurrenceStartDate = localDateTime.toDate(); } else {//ww w . j av a2 s . c om this.recurrenceStartDate = recurrenceStartDate.toDate(); } }
From source file:org.apache.fineract.infrastructure.sms.domain.SmsCampaign.java
License:Apache License
public void activate(final AppUser currentUser, final DateTimeFormatter formatter, final LocalDate activationLocalDate) { if (isActive()) { //handle errors if already activated final String defaultUserMessage = "Cannot activate campaign. Campaign is already active."; final ApiParameterError error = ApiParameterError.parameterError("error.msg.campaign.already.active", defaultUserMessage, SmsCampaignValidator.activationDateParamName, activationLocalDate.toString(formatter)); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException(dataValidationErrors); }/*from w w w . j a v a2 s.c om*/ this.approvedOnDate = activationLocalDate.toDate(); this.approvedBy = currentUser; this.status = SmsCampaignStatus.ACTIVE.getValue(); validate(); }
From source file:org.apache.fineract.infrastructure.sms.domain.SmsCampaign.java
License:Apache License
public void close(final AppUser currentUser, final DateTimeFormatter dateTimeFormatter, final LocalDate closureLocalDate) { if (isClosed()) { //handle errors if already activated final String defaultUserMessage = "Cannot close campaign. Campaign already in closed state."; final ApiParameterError error = ApiParameterError.parameterError("error.msg.campaign.already.closed", defaultUserMessage, SmsCampaignValidator.statusParamName, SmsCampaignStatus.fromInt(this.status).getCode()); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException(dataValidationErrors); }//from w w w.j a v a 2s .co m if (this.campaignType.intValue() == SmsCampaignType.SCHEDULE.getValue()) { this.nextTriggerDate = null; this.lastTriggerDate = null; } this.closedBy = currentUser; this.closureDate = closureLocalDate.toDate(); this.status = SmsCampaignStatus.CLOSED.getValue(); validateClosureDate(); }
From source file:org.apache.fineract.infrastructure.sms.domain.SmsCampaign.java
License:Apache License
public void reactivate(final AppUser currentUser, final DateTimeFormatter dateTimeFormat, final LocalDate reactivateLocalDate) { if (!isClosed()) { //handle errors if already activated final String defaultUserMessage = "Cannot reactivate campaign. Campaign must be in closed state."; final ApiParameterError error = ApiParameterError.parameterError("error.msg.campaign.must.be.closed", defaultUserMessage, SmsCampaignValidator.statusParamName, SmsCampaignStatus.fromInt(this.status).getCode()); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException(dataValidationErrors); }/*from w w w .jav a 2s.co m*/ this.approvedOnDate = reactivateLocalDate.toDate(); this.status = SmsCampaignStatus.ACTIVE.getValue(); this.approvedBy = currentUser; this.closureDate = null; this.isVisible = true; this.closedBy = null; validateReactivate(); }
From source file:org.apache.fineract.portfolio.account.service.StandingInstructionWritePlatformServiceImpl.java
License:Apache License
@Override @CronTarget(jobName = JobName.EXECUTE_STANDING_INSTRUCTIONS) public void executeStandingInstructions() throws JobExecutionException { Collection<StandingInstructionData> instructionDatas = this.standingInstructionReadPlatformService .retrieveAll(StandingInstructionStatus.ACTIVE.getValue()); final StringBuilder sb = new StringBuilder(); for (StandingInstructionData data : instructionDatas) { boolean isDueForTransfer = false; AccountTransferRecurrenceType recurrenceType = data.recurrenceType(); StandingInstructionType instructionType = data.instructionType(); LocalDate transactionDate = new LocalDate(); if (recurrenceType.isPeriodicRecurrence()) { final ScheduledDateGenerator scheduledDateGenerator = new DefaultScheduledDateGenerator(); PeriodFrequencyType frequencyType = data.recurrenceFrequency(); LocalDate startDate = data.validFrom(); if (frequencyType.isMonthly()) { startDate = startDate.withDayOfMonth(data.recurrenceOnDay()); if (startDate.isBefore(data.validFrom())) { startDate = startDate.plusMonths(1); }//from w ww .j av a 2s . c om } else if (frequencyType.isYearly()) { startDate = startDate.withDayOfMonth(data.recurrenceOnDay()) .withMonthOfYear(data.recurrenceOnMonth()); if (startDate.isBefore(data.validFrom())) { startDate = startDate.plusYears(1); } } isDueForTransfer = scheduledDateGenerator.isDateFallsInSchedule(frequencyType, data.recurrenceInterval(), startDate, transactionDate); } BigDecimal transactionAmount = data.amount(); if (data.toAccountType().isLoanAccount() && (recurrenceType.isDuesRecurrence() || (isDueForTransfer && instructionType.isDuesAmoutTransfer()))) { StandingInstructionDuesData standingInstructionDuesData = this.standingInstructionReadPlatformService .retriveLoanDuesData(data.toAccount().accountId()); if (data.instructionType().isDuesAmoutTransfer()) { transactionAmount = standingInstructionDuesData.totalDueAmount(); } if (recurrenceType.isDuesRecurrence()) { isDueForTransfer = new LocalDate().equals(standingInstructionDuesData.dueDate()); } } if (isDueForTransfer && transactionAmount != null && transactionAmount.compareTo(BigDecimal.ZERO) > 0) { final AccountTransferDetails accountTransferDetails = this.accountTransferDetailRepository .findOne(data.accountDetailId()); final SavingsAccount fromSavingsAccount = null; final boolean isRegularTransaction = true; final boolean isExceptionForBalanceCheck = false; accountTransferDetails.accountTransferStandingInstruction() .updateLatsRunDate(transactionDate.toDate()); AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, transactionAmount, data.fromAccountType(), data.toAccountType(), data.fromAccount().accountId(), data.toAccount().accountId(), data.name() + " Standing instruction trasfer ", null, null, null, null, data.toTransferType(), null, null, data.transferType().getValue(), accountTransferDetails, null, null, null, null, fromSavingsAccount, isRegularTransaction, isExceptionForBalanceCheck); transferAmount(sb, accountTransferDTO, data.getId()); } } if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); } }
From source file:org.apache.fineract.portfolio.accounts.serialization.ShareAccountDataSerializer.java
License:Apache License
private Set<PurchasedShares> asemblePurchasedShares(final JsonElement element) { Set<PurchasedShares> set = null; if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.purchasedshares_paramname, element)) { set = new HashSet<>(); JsonArray array = this.fromApiJsonHelper .extractJsonArrayNamed(ShareAccountApiConstants.purchasedshares_paramname, element); for (JsonElement arrayElement : array) { LocalDate localDate = this.fromApiJsonHelper .extractLocalDateNamed(ShareAccountApiConstants.purchaseddate_paramname, arrayElement); final Long shares = this.fromApiJsonHelper .extractLongNamed(ShareAccountApiConstants.numberofshares_paramname, arrayElement); final BigDecimal shareValue = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( ShareAccountApiConstants.purchasedprice_paramname, arrayElement); PurchasedShares obj = new PurchasedShares(localDate.toDate(), shares, shareValue); set.add(obj);/* ww w . j a va2 s .co m*/ } } return set; }
From source file:org.apache.fineract.portfolio.accounts.serialization.ShareAccountDataSerializer.java
License:Apache License
public Set<PurchasedShares> asembleAdditionalShares(final JsonElement element) { Set<PurchasedShares> set = null; if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.additionalshares_paramname, element)) { set = new HashSet<>(); JsonArray array = this.fromApiJsonHelper .extractJsonArrayNamed(ShareAccountApiConstants.additionalshares_paramname, element); for (JsonElement arrayElement : array) { LocalDate localDate = this.fromApiJsonHelper .extractLocalDateNamed(ShareAccountApiConstants.purchaseddate_paramname, arrayElement); final Long shares = this.fromApiJsonHelper .extractLongNamed(ShareAccountApiConstants.numberofshares_paramname, arrayElement); final BigDecimal shareValue = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( ShareAccountApiConstants.purchasedprice_paramname, arrayElement); PurchasedShares obj = new PurchasedShares(localDate.toDate(), shares, shareValue); set.add(obj);// w w w . j av a 2 s . c om } } return set; }
From source file:org.apache.fineract.portfolio.calendar.domain.Calendar.java
License:Apache License
public Calendar(final String title, final String description, final String location, final LocalDate startDate, final LocalDate endDate, final Integer duration, final Integer typeId, final boolean repeating, final String recurrence, final Integer remindById, final Integer firstReminder, final Integer secondReminder) { final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource(CALENDAR_RESOURCE_NAME); final CalendarType calendarType = CalendarType.fromInt(typeId); if (calendarType.isCollection() && !repeating) { baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()) .failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar"); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }/* w w w .j ava 2 s . com*/ } this.title = StringUtils.defaultIfEmpty(title, null); this.description = StringUtils.defaultIfEmpty(description, null); this.location = StringUtils.defaultIfEmpty(location, null); if (null != startDate) { this.startDate = startDate.toDateTimeAtStartOfDay().toDate(); } else { this.startDate = null; } if (null != endDate) { this.endDate = endDate.toDateTimeAtStartOfDay().toDate(); } else { this.endDate = null; } this.duration = duration; this.typeId = typeId; this.repeating = repeating; this.recurrence = StringUtils.defaultIfEmpty(recurrence, null); this.remindById = remindById; this.firstReminder = firstReminder; this.secondReminder = secondReminder; }
From source file:org.apache.fineract.portfolio.calendar.domain.Calendar.java
License:Apache License
public Map<String, Object> updateStartDateAndDerivedFeilds(final LocalDate newMeetingStartDate) { final Map<String, Object> actualChanges = new LinkedHashMap<>(9); final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); if (newMeetingStartDate.isBefore(currentDate)) { final String defaultUserMessage = "New meeting effective from date cannot be in past"; throw new CalendarDateException("new.start.date.cannot.be.in.past", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else if (isStartDateAfter(newMeetingStartDate) && isStartDateBeforeOrEqual(currentDate)) { // new meeting date should be on or after start date or current // date/*from w w w . ja va 2 s . co m*/ final String defaultUserMessage = "New meeting effective from date cannot be a date before existing meeting start date"; throw new CalendarDateException("new.start.date.before.existing.date", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else { actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), newMeetingStartDate.toString()); this.startDate = newMeetingStartDate.toDate(); /* * If meeting start date is changed then there is possibilities of * recurring day may change, so derive the recurring day and update * it if it is changed. For weekly type is weekday and for monthly * type it is day of the month */ CalendarFrequencyType calendarFrequencyType = CalendarUtils.getFrequency(this.recurrence); Integer interval = CalendarUtils.getInterval(this.recurrence); Integer repeatsOnDay = null; /* * Repeats on day, need to derive based on the start date */ if (calendarFrequencyType.isWeekly()) { repeatsOnDay = newMeetingStartDate.getDayOfWeek(); } else if (calendarFrequencyType.isMonthly()) { repeatsOnDay = newMeetingStartDate.getDayOfMonth(); } // TODO cover other recurrence also this.recurrence = constructRecurrence(calendarFrequencyType, interval, repeatsOnDay); } return actualChanges; }