List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java
License:Apache License
private LoanRepaymentScheduleInstallment getTotalOutstandingOnLoan() { Money feeCharges = Money.zero(loanCurrency()); Money penaltyCharges = Money.zero(loanCurrency()); Money totalPrincipal = Money.zero(loanCurrency()); Money totalInterest = Money.zero(loanCurrency()); for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) { totalPrincipal = totalPrincipal.plus(scheduledRepayment.getPrincipalOutstanding(loanCurrency())); totalInterest = totalInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency())); feeCharges = feeCharges.plus(scheduledRepayment.getFeeChargesOutstanding(loanCurrency())); penaltyCharges = penaltyCharges.plus(scheduledRepayment.getPenaltyChargesOutstanding(loanCurrency())); }/*from www. ja va 2 s .c o m*/ return new LoanRepaymentScheduleInstallment(null, 0, LocalDate.now(), LocalDate.now(), totalPrincipal.getAmount(), totalInterest.getAmount(), feeCharges.getAmount(), penaltyCharges.getAmount(), false); }
From source file:org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformServiceImpl.java
License:Apache License
@Override public LoanTransactionData retrieveLoanPrePaymentTemplate(final Long loanId, LocalDate onDate) { this.context.authenticatedUser(); final Loan loan = this.loanRepository.findOne(loanId); if (loan == null) { throw new LoanNotFoundException(loanId); }// w w w . java2 s. c om loan.setHelpers(null, null, loanRepaymentScheduleTransactionProcessorFactory); final MonetaryCurrency currency = loan.getCurrency(); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository .findOneWithNotFoundDetection(currency); final CurrencyData currencyData = applicationCurrency.toData(); final LocalDate earliestUnpaidInstallmentDate = LocalDate.now(); final LocalDate recalculateFrom = null; final ScheduleGeneratorDTO scheduleGeneratorDTO = loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loan .fetchPrepaymentDetail(scheduleGeneratorDTO, onDate); final LoanTransactionEnumData transactionType = LoanEnumerations .transactionType(LoanTransactionType.REPAYMENT); final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService .retrieveAllPaymentTypes(); final BigDecimal outstandingLoanBalance = loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency) .getAmount(); final BigDecimal unrecognizedIncomePortion = null; return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate, loanRepaymentScheduleInstallment.getTotalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion, paymentOptions, null, null, null, outstandingLoanBalance, false); }
From source file:org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private boolean addCharge(final Loan loan, final Charge chargeDefinition, final LoanCharge loanCharge) { AppUser currentUser = getAppUserIfPresent(); if (!loan.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())) { final String errorMessage = "Charge and Loan must have the same currency."; throw new InvalidCurrencyException("loanCharge", "attach.to.loan", errorMessage); }// w w w .j av a 2s. c om if (loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService .retriveLoanLinkedAssociation(loan.getId()); if (portfolioAccountData == null) { final String errorMessage = loanCharge.name() + "Charge requires linked savings account for payment"; throw new LinkedAccountRequiredException("loanCharge.add", errorMessage, loanCharge.name()); } } loan.addLoanCharge(loanCharge); this.loanChargeRepository.save(loanCharge); /** * we want to apply charge transactions only for those loans charges * that are applied when a loan is active and the loan product uses * Upfront Accruals **/ if (loan.status().isActive() && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null, currentUser); this.loanTransactionRepository.save(applyLoanChargeTransaction); } boolean isAppliedOnBackDate = false; if (loanCharge.getDueLocalDate() == null || LocalDate.now().isAfter(loanCharge.getDueLocalDate())) { isAppliedOnBackDate = true; } return isAppliedOnBackDate; }
From source file:org.apache.fineract.portfolio.savings.domain.RecurringDepositAccount.java
License:Apache License
protected BigDecimal getEffectiveInterestRateAsFraction(final MathContext mc, final LocalDate interestPostingUpToDate, final boolean isPreMatureClosure) { boolean applyPreMaturePenalty = false; BigDecimal penalInterest = BigDecimal.ZERO; LocalDate depositCloseDate = calculateMaturityDate(); if (isPreMatureClosure) { if (this.accountTermAndPreClosure.isPreClosurePenalApplicable()) { applyPreMaturePenalty = true; penalInterest = this.accountTermAndPreClosure.depositPreClosureDetail().preClosurePenalInterest(); final PreClosurePenalInterestOnType preClosurePenalInterestOnType = this.accountTermAndPreClosure .depositPreClosureDetail().preClosurePenalInterestOnType(); if (preClosurePenalInterestOnType.isWholeTerm()) { depositCloseDate = interestCalculatedUpto(); } else if (preClosurePenalInterestOnType.isTillPrematureWithdrawal()) { depositCloseDate = interestPostingUpToDate; }/*from www . ja v a 2 s . c o m*/ } } if (depositCloseDate == null) { depositCloseDate = LocalDate.now(); } final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount(); BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate, this.client); if (applyPreMaturePenalty) { applicableInterestRate = applicableInterestRate.subtract(penalInterest); applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : applicableInterestRate; } this.nominalAnnualInterestRate = applicableInterestRate; return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc); }
From source file:org.apache.fineract.portfolio.savings.service.SavingsProductWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
/** * this function adds savings charges of type annual, monthly and withdrawals to an already existing savings accounts * when its set to on a product. functions is more like a bulk addSavingsCharge to savings accounts *///from w ww . j a v a 2 s . co m @Override @CronTarget(jobName = JobName.APPLY_PRODUCT_CHARGE_TO_EXISTING_SAVINGS_ACCOUNT) public void applyChargeToExistingSavingsAccount() throws JobExecutionException { final StringBuilder sb = new StringBuilder(); final Collection<ApplyChargesToExistingSavingsAccount> applyChargesToExistingSavingsAccounts = this.applyChargesToExistingSavingsAccountRepository .findAll(); if (!applyChargesToExistingSavingsAccounts.isEmpty() && applyChargesToExistingSavingsAccounts.size() > 0) { for (final ApplyChargesToExistingSavingsAccount applyCharge : applyChargesToExistingSavingsAccounts) { if (applyCharge.isApplyChargeToExistingSavingsAccount()) { final List<SavingsAccount> activeSavingsAccountsWithoutCharge = this.savingsAccountRepository .savingsAccountWithoutCharge(applyCharge.getSavingsProduct().getId(), applyCharge.getProductCharge().getId()); for (final SavingsAccount account : activeSavingsAccountsWithoutCharge) { final Charge charge = applyCharge.getProductCharge(); final LocalDate currentDate = LocalDate.now(); final Locale locale = new Locale("en"); final String format = "dd MMMM yyyy"; final DateTimeFormatter fmt = StringUtils.isNotBlank(format) ? DateTimeFormat.forPattern(format).withLocale(locale) : DateTimeFormat.forPattern("dd MM yyyy"); final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge .createNewWithoutSavingsAccount(charge, charge.getAmount(), ChargeTimeType.fromInt(charge.getChargeTimeType()), ChargeCalculationType.fromInt(charge.getChargeCalculation()), currentDate, true, charge.getFeeOnMonthDay(), charge.feeInterval()); savingsAccountCharge.update(account); try { //FIXMe add validation from the add charge to savings account method account.addCharge(fmt, savingsAccountCharge, charge); this.savingsAccountRepository.saveAndFlush(account); } catch (PlatformApiDataValidationException e) { sb.append(e.getErrors().get(0).getDeveloperMessage() + " savings account with id " + account.getId() + ","); } catch (AbstractPlatformDomainRuleException e) { sb.append(e.getDefaultUserMessage() + " savings account with id " + account.getId() + ","); } catch (RuntimeException e) { sb.append(e.toString() + " savings account with id " + account.getId() + ","); } catch (Exception e) { sb.append(e.getCause().getMessage() + " savings account with id" + account.getId() + ","); } } } } } if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); } }
From source file:org.apigw.commons.logging.logback.ApigwStripSwedishSSNFromMessageConverter.java
License:Open Source License
private static boolean isSsnBirthdayInThePast(String ssn) { return !getBirthday(ssn).isAfter(LocalDate.now()); }
From source file:org.codeqinvest.quality.analysis.CodeChangeProbabilityCalculatorFactory.java
License:Open Source License
CodeChangeProbabilityCalculator create(CodeChangeSettings codeChangeSettings) { if (codeChangeSettings.getMethod() == SupportedCodeChangeProbabilityMethod.WEIGHTED.getId()) { return new WeightedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, LocalDate.now(), codeChangeSettings.getDays()); } else if (codeChangeSettings.getMethod() == SupportedCodeChangeProbabilityMethod.COMMIT_BASED.getId()) { return new CommitBasedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, codeChangeSettings.getNumberOfCommits()); } else {/* ww w .ja v a 2 s.c om*/ return new DefaultCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, LocalDate.now(), codeChangeSettings.getDays()); } }
From source file:org.devmaster.elasticsearch.index.mapper.Recurring.java
License:Apache License
public boolean notHasExpired() throws ParseException { final LocalDate today = LocalDate.now(); return getNextOccurrence(today) != null; }
From source file:org.devmaster.elasticsearch.script.NextOccurrenceSearchScript.java
License:Apache License
@Override public Object run() { Recurring recurring = getRecurring(getParamValueFor(PARAM_FIELD)); if (recurring != null) { String fromParam = getParamValueFor(PARAM_FROM); LocalDate date = fromParam != null ? new LocalDate(fromParam) : LocalDate.now(); try {/*from w w w.j a v a2s .co m*/ LocalDate nextOccurrence = recurring.getNextOccurrence(date); return nextOccurrence != null ? nextOccurrence.toString() : null; } catch (ParseException ignored) { } } return null; }
From source file:org.estatio.app.interactivemap.InteractiveMapForFixedAssetService.java
License:Apache License
private String getLeaseName(Unit unit) { LocalDate today = LocalDate.now(); List<Occupancy> occupancyList = occupancies.occupancies(unit); for (Occupancy occupancy : occupancyList) { LocalDate startDate = occupancy.getStartDate(); LocalDate endDate = occupancy.getEndDate(); if ((startDate == null || today.isAfter(startDate)) && (endDate == null || today.isBefore(endDate))) { Lease lease = occupancy.getLease(); return lease.getName(); }/* w w w.ja v a 2 s. c om*/ } return null; }