List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:com.gst.organisation.office.domain.Office.java
License:Apache License
private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) { this.parent = parent; this.openingDate = openingDate.toDateTimeAtStartOfDay().toDate(); if (parent != null) { this.parent.addChild(this); }//from w w w .ja va2 s .co m if (StringUtils.isNotBlank(name)) { this.name = name.trim(); } else { this.name = null; } if (StringUtils.isNotBlank(externalId)) { this.externalId = externalId.trim(); } else { this.externalId = null; } }
From source file:com.gst.organisation.office.domain.OfficeTransaction.java
License:Apache License
private OfficeTransaction(final Office fromOffice, final Office toOffice, final LocalDate transactionLocalDate, final Money amount, final String description) { this.from = fromOffice; this.to = toOffice; if (transactionLocalDate != null) { this.transactionDate = transactionLocalDate.toDate(); }/*from w w w . j a v a 2s. c o m*/ this.currency = amount.getCurrency(); this.transactionAmount = amount.getAmount(); this.description = description; }
From source file:com.gst.organisation.staff.domain.Staff.java
License:Apache License
private Staff(final Office staffOffice, final String firstname, final String lastname, final String externalId, final String mobileNo, final boolean isLoanOfficer, final Boolean isActive, final LocalDate joiningDate) { this.office = staffOffice; this.firstname = StringUtils.defaultIfEmpty(firstname, null); this.lastname = StringUtils.defaultIfEmpty(lastname, null); this.externalId = StringUtils.defaultIfEmpty(externalId, null); this.mobileNo = StringUtils.defaultIfEmpty(mobileNo, null); this.loanOfficer = isLoanOfficer; this.active = (isActive == null) ? true : isActive; deriveDisplayName(firstname);//w ww . j av a2s. c om if (joiningDate != null) { this.joiningDate = joiningDate.toDateTimeAtStartOfDay().toDate(); } }
From source file:com.gst.organisation.teller.domain.Cashier.java
License:Apache License
public Cashier(Office office, Teller teller, Staff staff, String description, LocalDate startDate, LocalDate endDate, Boolean isFullDay, String startTime, String endTime) { this.office = office; this.teller = teller; this.staff = staff; this.description = description; this.startDate = startDate.toDate(); this.endDate = endDate.toDate(); this.isFullDay = isFullDay; this.startTime = startTime; this.endTime = endTime; }
From source file:com.gst.organisation.teller.domain.CashierTransaction.java
License:Apache License
public CashierTransaction(Cashier cashier, Integer txnType, BigDecimal txnAmount, LocalDate txnDate, String entityType, Long entityId, String txnNote, String currencyCode) { this.cashier = cashier; this.txnType = txnType; if (txnDate != null) { this.txnDate = txnDate.toDate(); }/*from w ww . j av a2 s . c o m*/ this.txnAmount = txnAmount; this.entityType = entityType; this.entityId = entityId; this.txnNote = txnNote; this.createdDate = new Date(); this.currencyCode = currencyCode; }
From source file:com.gst.organisation.teller.domain.Teller.java
License:Apache License
private Teller(final Office staffOffice, final String name, final String description, final LocalDate startDate, final LocalDate endDate, final TellerStatus status) { this.name = StringUtils.defaultIfEmpty(name, null); this.description = StringUtils.defaultIfEmpty(description, null); if (startDate != null) { this.startDate = startDate.toDateTimeAtStartOfDay().toDate(); }//from w w w. j a v a2s . co m if (endDate != null) { this.endDate = endDate.toDateTimeAtStartOfDay().toDate(); } if (status != null) { this.status = status.getValue(); } this.office = staffOffice; /* if (StringUtils.isNotBlank(name)) { this.name = name.trim(); } else { this.name = null; } if (StringUtils.isNotBlank(description)) { this.description = description.trim(); } else { this.description = null; } */ }
From source file:com.gst.portfolio.account.domain.AccountTransferStandingInstruction.java
License:Apache License
private AccountTransferStandingInstruction(final AccountTransferDetails accountTransferDetails, final String name, final Integer priority, final Integer instructionType, final Integer status, final BigDecimal amount, final LocalDate validFrom, final LocalDate validTill, final Integer recurrenceType, final Integer recurrenceFrequency, final Integer recurrenceInterval, final Integer recurrenceOnDay, final Integer recurrenceOnMonth) { this.accountTransferDetails = accountTransferDetails; this.name = name; this.priority = priority; this.instructionType = instructionType; this.status = status; this.amount = amount; if (validFrom != null) { this.validFrom = validFrom.toDate(); }/*w ww. j a v a2 s . c o m*/ if (validTill == null) { this.validTill = null; } else { this.validTill = validTill.toDate(); } this.recurrenceType = recurrenceType; this.recurrenceFrequency = recurrenceFrequency; this.recurrenceInterval = recurrenceInterval; this.recurrenceOnDay = recurrenceOnDay; this.recurrenceOnMonth = recurrenceOnMonth; final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource(STANDING_INSTRUCTION_RESOURCE_NAME); validateDependencies(baseDataValidator); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } }
From source file:com.gst.portfolio.account.domain.AccountTransferStandingInstruction.java
License:Apache License
public Map<String, Object> update(JsonCommand command) { final Map<String, Object> actualChanges = new HashMap<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource(STANDING_INSTRUCTION_RESOURCE_NAME); if (StandingInstructionStatus.fromInt(this.status).isDeleted()) { baseDataValidator.reset().parameter(statusParamName).failWithCode("can.not.modify.once.deleted"); }/* w w w . j a v a 2 s. c o m*/ if (command.isChangeInDateParameterNamed(validFromParamName, this.validFrom)) { final LocalDate newValue = command.localDateValueOfParameterNamed(validFromParamName); actualChanges.put(validFromParamName, newValue); this.validFrom = newValue.toDate(); } if (command.isChangeInDateParameterNamed(validTillParamName, this.validTill)) { final LocalDate newValue = command.localDateValueOfParameterNamed(validTillParamName); actualChanges.put(validTillParamName, newValue); this.validTill = newValue.toDate(); } if (command.isChangeInBigDecimalParameterNamed(amountParamName, this.amount)) { final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountParamName); actualChanges.put(amountParamName, newValue); this.amount = newValue; } if (command.isChangeInIntegerParameterNamed(statusParamName, this.status)) { final Integer newValue = command.integerValueOfParameterNamed(statusParamName); actualChanges.put(statusParamName, newValue); this.status = newValue; } if (command.isChangeInIntegerParameterNamed(priorityParamName, this.priority)) { final Integer newValue = command.integerValueOfParameterNamed(priorityParamName); actualChanges.put(priorityParamName, newValue); this.priority = newValue; } if (command.isChangeInIntegerParameterNamed(instructionTypeParamName, this.instructionType)) { final Integer newValue = command.integerValueOfParameterNamed(instructionTypeParamName); actualChanges.put(instructionTypeParamName, newValue); this.instructionType = newValue; } if (command.isChangeInIntegerParameterNamed(recurrenceTypeParamName, this.recurrenceType)) { final Integer newValue = command.integerValueOfParameterNamed(recurrenceTypeParamName); actualChanges.put(recurrenceTypeParamName, newValue); this.recurrenceType = newValue; } if (command.isChangeInIntegerParameterNamed(recurrenceFrequencyParamName, this.recurrenceFrequency)) { final Integer newValue = command.integerValueOfParameterNamed(recurrenceFrequencyParamName); actualChanges.put(recurrenceFrequencyParamName, newValue); this.recurrenceFrequency = newValue; } if (command.hasParameter(recurrenceOnMonthDayParamName)) { final MonthDay monthDay = command.extractMonthDayNamed(recurrenceOnMonthDayParamName); final String actualValueEntered = command.stringValueOfParameterNamed(recurrenceOnMonthDayParamName); final Integer dayOfMonthValue = monthDay.getDayOfMonth(); if (this.recurrenceOnDay != dayOfMonthValue) { actualChanges.put(recurrenceOnMonthDayParamName, actualValueEntered); this.recurrenceOnDay = dayOfMonthValue; } final Integer monthOfYear = monthDay.getMonthOfYear(); if (this.recurrenceOnMonth != monthOfYear) { actualChanges.put(recurrenceOnMonthDayParamName, actualValueEntered); this.recurrenceOnMonth = monthOfYear; } } if (command.isChangeInIntegerParameterNamed(recurrenceIntervalParamName, this.recurrenceInterval)) { final Integer newValue = command.integerValueOfParameterNamed(recurrenceIntervalParamName); actualChanges.put(recurrenceIntervalParamName, newValue); this.recurrenceInterval = newValue; } validateDependencies(baseDataValidator); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } return actualChanges; }
From source file:com.gst.portfolio.account.domain.AccountTransferTransaction.java
License:Apache License
private AccountTransferTransaction(final AccountTransferDetails accountTransferDetails, final SavingsAccountTransaction withdrawal, final SavingsAccountTransaction deposit, final LoanTransaction loanRepaymentTransaction, final LoanTransaction loanRefundTransaction, final LocalDate transactionDate, final Money transactionAmount, final String description) { this.accountTransferDetails = accountTransferDetails; this.fromLoanTransaction = loanRefundTransaction; this.fromSavingsTransaction = withdrawal; this.toSavingsTransaction = deposit; this.toLoanTransaction = loanRepaymentTransaction; this.date = transactionDate.toDate(); this.currency = transactionAmount.getCurrency(); this.amount = transactionAmount.getAmountDefaultedToNullIfZero(); this.description = description; }
From source file:com.gst.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); }//w w w.j a v a2 s . com } 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 SavingsAccount fromSavingsAccount = null; final boolean isRegularTransaction = true; final boolean isExceptionForBalanceCheck = false; 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(), null, null, null, null, null, fromSavingsAccount, isRegularTransaction, isExceptionForBalanceCheck); final boolean transferCompleted = transferAmount(sb, accountTransferDTO, data.getId()); if (transferCompleted) { final String updateQuery = "UPDATE m_account_transfer_standing_instructions SET last_run_date = ? where id = ?"; this.jdbcTemplate.update(updateQuery, transactionDate.toDate(), data.getId()); } } } if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); } }