Example usage for org.joda.time LocalDate LocalDate

List of usage examples for org.joda.time LocalDate LocalDate

Introduction

In this page you can find the example usage for org.joda.time LocalDate LocalDate.

Prototype

public LocalDate(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:com.gst.portfolio.loanaccount.rescheduleloan.domain.LoanRescheduleRequest.java

License:Apache License

/** 
 * @return the date the request was rejected 
 **//* w w w .  ja  v  a  2  s. com*/
public LocalDate getRejectedOnDate() {
    LocalDate localDate = null;

    if (this.rejectedOnDate != null) {
        localDate = new LocalDate(this.rejectedOnDate);
    }

    return localDate;
}

From source file:com.gst.portfolio.loanaccount.service.LoanReadPlatformServiceImpl.java

License:Apache License

@Override
public Collection<LoanScheduleAccrualData> retriveScheduleAccrualData() {

    LoanScheduleAccrualMapper mapper = new LoanScheduleAccrualMapper();
    Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
    final StringBuilder sqlBuilder = new StringBuilder(400);
    sqlBuilder.append("select ").append(mapper.schema()).append(
            " where (recaldet.is_compounding_to_be_posted_as_transaction is null or recaldet.is_compounding_to_be_posted_as_transaction = 0) ")
            .append(" and (((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))")
            .append(" or ( ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))")
            .append(" or ( ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))")
            .append(" and loan.loan_status_id=:active and mpl.accounting_type=:type and loan.is_npa=0 and ls.duedate <= CURDATE()) ");
    if (organisationStartDate != null) {
        sqlBuilder.append(" and ls.duedate > :organisationstartdate ");
    }/*from ww w  .j a  v  a 2s  .c o m*/
    sqlBuilder.append(" order by loan.id,ls.duedate ");
    Map<String, Object> paramMap = new HashMap<>(3);
    paramMap.put("active", LoanStatus.ACTIVE.getValue());
    paramMap.put("type", AccountingRuleType.ACCRUAL_PERIODIC.getValue());
    paramMap.put("organisationstartdate", formatter.print(new LocalDate(organisationStartDate)));

    return this.namedParameterJdbcTemplate.query(sqlBuilder.toString(), paramMap, mapper);
}

From source file:com.gst.portfolio.loanaccount.service.LoanReadPlatformServiceImpl.java

License:Apache License

@Override
public Collection<LoanScheduleAccrualData> retrivePeriodicAccrualData(final LocalDate tillDate) {

    LoanSchedulePeriodicAccrualMapper mapper = new LoanSchedulePeriodicAccrualMapper();
    Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
    final StringBuilder sqlBuilder = new StringBuilder(400);
    sqlBuilder.append("select ").append(mapper.schema()).append(
            " where  (recaldet.is_compounding_to_be_posted_as_transaction is null or recaldet.is_compounding_to_be_posted_as_transaction = 0) ")
            .append(" and (((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))")
            .append(" or (ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))")
            .append(" or (ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))")
            .append(" and loan.loan_status_id=:active and mpl.accounting_type=:type and (loan.closedon_date <= :tilldate or loan.closedon_date is null)")
            .append(" and loan.is_npa=0 and (ls.duedate <= :tilldate or (ls.duedate > :tilldate and ls.fromdate < :tilldate))) ");
    if (organisationStartDate != null) {
        sqlBuilder.append(" and ls.duedate > :organisationstartdate ");
    }//from ww w .j a  va2s  . c om
    sqlBuilder.append(" order by loan.id,ls.duedate ");
    Map<String, Object> paramMap = new HashMap<>(4);
    paramMap.put("active", LoanStatus.ACTIVE.getValue());
    paramMap.put("type", AccountingRuleType.ACCRUAL_PERIODIC.getValue());
    paramMap.put("tilldate", formatter.print(tillDate));
    paramMap.put("organisationstartdate", formatter.print(new LocalDate(organisationStartDate)));

    return this.namedParameterJdbcTemplate.query(sqlBuilder.toString(), paramMap, mapper);
}

From source file:com.gst.portfolio.savings.domain.DepositAccountTermAndPreClosure.java

License:Apache License

public LocalDate getMaturityLocalDate() {
    LocalDate maturityLocalDate = null;
    if (this.maturityDate != null) {
        maturityLocalDate = new LocalDate(this.maturityDate);
    }// w w  w .  j a v  a  2 s. c o  m
    return maturityLocalDate;
}

From source file:com.gst.portfolio.savings.domain.DepositAccountTermAndPreClosure.java

License:Apache License

public LocalDate getExpectedFirstDepositOnDate() {
    LocalDate expectedFirstDepositOnLocalDate = null;
    if (this.expectedFirstDepositOnDate != null) {
        expectedFirstDepositOnLocalDate = new LocalDate(this.expectedFirstDepositOnDate);
    }/*  w  w  w .j a v  a  2  s  .c o m*/
    return expectedFirstDepositOnLocalDate;
}

From source file:com.gst.portfolio.savings.domain.RecurringDepositScheduleInstallment.java

License:Apache License

public LocalDate dueDate() {
    return (this.dueDate == null) ? null : new LocalDate(this.dueDate);
}

From source file:com.gst.portfolio.savings.domain.SavingsAccount.java

License:Apache License

/**
 * All interest calculation based on END-OF-DAY-BALANCE.
 * /*from  w  w w  .  j a v  a  2 s .c o  m*/
 * Interest calculation is performed on-the-fly over all account
 * transactions.
 * 
 * 
 * 1. Calculate Interest From Beginning Of Account 1a. determine the
 * 'crediting' periods that exist for this savings acccount 1b. determine
 * the 'compounding' periods that exist within each 'crediting' period
 * calculate the amount of interest due at the end of each 'crediting'
 * period check if an existing 'interest posting' transaction exists for
 * date and matches the amount posted
 * 
 * @param isInterestTransfer
 *            TODO
 */

public List<PostingPeriod> calculateInterestUsing(final MathContext mc,
        final LocalDate upToInterestCalculationDate, boolean isInterestTransfer,
        final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth,
        final LocalDate postInterestOnDate) {

    // no openingBalance concept supported yet but probably will to allow
    // for migrations.
    final Money openingAccountBalance = Money.zero(this.currency);

    // update existing transactions so derived balance fields are
    // correct.
    recalculateDailyBalances(openingAccountBalance, upToInterestCalculationDate);

    // 1. default to calculate interest based on entire history OR
    // 2. determine latest 'posting period' and find interest credited to
    // that period

    // A generate list of EndOfDayBalances (not including interest postings)
    final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType
            .fromInt(this.interestPostingPeriodType);

    final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType
            .fromInt(this.interestCompoundingPeriodType);

    final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
            .fromInt(this.interestCalculationDaysInYearType);
    List<LocalDate> postedAsOnDates = getManualPostingDates();
    if (postInterestOnDate != null) {
        postedAsOnDates.add(postInterestOnDate);
    }
    final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
            getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType,
            financialYearBeginningMonth, postedAsOnDates);

    final List<PostingPeriod> allPostingPeriods = new ArrayList<>();

    Money periodStartingBalance;
    if (this.startInterestCalculationDate != null) {
        LocalDate startInterestCalculationDate = new LocalDate(this.startInterestCalculationDate);
        final SavingsAccountTransaction transaction = findLastTransaction(startInterestCalculationDate);

        if (transaction == null) {
            final String defaultUserMessage = "No transactions were found on the specified date "
                    + getStartInterestCalculationDate().toString() + " for account number "
                    + this.accountNumber.toString() + " and resource id " + getId();

            final ApiParameterError error = ApiParameterError.parameterError(
                    "error.msg.savingsaccount.transaction.incorrect.start.interest.calculation.date",
                    defaultUserMessage, "transactionDate", getStartInterestCalculationDate().toString());

            final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
            dataValidationErrors.add(error);

            throw new PlatformApiDataValidationException(dataValidationErrors);
        }

        periodStartingBalance = transaction.getRunningBalance(this.currency);
    } else
        periodStartingBalance = Money.zero(this.currency);

    final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType
            .fromInt(this.interestCalculationType);
    final BigDecimal interestRateAsFraction = getEffectiveInterestRateAsFraction(mc,
            upToInterestCalculationDate);
    final BigDecimal overdraftInterestRateAsFraction = getEffectiveOverdraftInterestRateAsFraction(mc);
    final Collection<Long> interestPostTransactions = this.savingsHelper
            .fetchPostInterestTransactionIds(getId());
    final Money minBalanceForInterestCalculation = Money.of(getCurrency(), minBalanceForInterestCalculation());
    final Money minOverdraftForInterestCalculation = Money.of(getCurrency(),
            this.minOverdraftForInterestCalculation);

    for (final LocalDateInterval periodInterval : postingPeriodIntervals) {

        boolean isUserPosting = false;
        if (postedAsOnDates.contains(periodInterval.endDate().plusDays(1))) {
            isUserPosting = true;
        }

        final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance,
                retreiveOrderedNonInterestPostingTransactions(), this.currency, compoundingPeriodType,
                interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
                upToInterestCalculationDate, interestPostTransactions, isInterestTransfer,
                minBalanceForInterestCalculation, isSavingsInterestPostingAtCurrentPeriodEnd,
                overdraftInterestRateAsFraction, minOverdraftForInterestCalculation, isUserPosting);

        periodStartingBalance = postingPeriod.closingBalance();

        allPostingPeriods.add(postingPeriod);
    }

    this.savingsHelper.calculateInterestForAllPostingPeriods(this.currency, allPostingPeriods,
            getLockedInUntilLocalDate(), isTransferInterestToOtherAccount());

    this.summary.updateFromInterestPeriodSummaries(this.currency, allPostingPeriods);
    this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);

    return allPostingPeriods;
}

From source file:com.gst.portfolio.savings.domain.SavingsAccount.java

License:Apache License

public LocalDate getActivationLocalDate() {
    LocalDate activationLocalDate = null;
    if (this.activatedOnDate != null) {
        activationLocalDate = new LocalDate(this.activatedOnDate);
    }//from  ww  w  .j av  a2 s.com
    return activationLocalDate;
}

From source file:com.gst.portfolio.savings.domain.SavingsAccount.java

License:Apache License

public LocalDate getStartInterestCalculationDate() {
    LocalDate startInterestCalculationLocalDate = null;
    if (this.startInterestCalculationDate != null) {
        startInterestCalculationLocalDate = new LocalDate(this.startInterestCalculationDate);
    } else/*w w w. j  a v  a  2s.co m*/
        startInterestCalculationLocalDate = getActivationLocalDate();
    return startInterestCalculationLocalDate;
}

From source file:com.gst.portfolio.savings.domain.SavingsAccount.java

License:Apache License

protected LocalDate getLockedInUntilLocalDate() {
    LocalDate lockedInUntilLocalDate = null;
    if (this.lockedInUntilDate != null) {
        lockedInUntilLocalDate = new LocalDate(this.lockedInUntilDate);
    }//from   w  w  w.  j  a  v a2  s . c om
    return lockedInUntilLocalDate;
}