Example usage for org.joda.time LocalDate isBefore

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

Introduction

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

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:com.gst.portfolio.loanaccount.domain.Loan.java

License:Apache License

public Money retrieveAccruedAmountAfterDate(final LocalDate tillDate) {
    Money totalAmountAccrued = Money.zero(getCurrency());
    Money actualAmountTobeAccrued = Money.zero(getCurrency());
    for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
        totalAmountAccrued = totalAmountAccrued.plus(installment.getInterestAccrued(getCurrency()));

        if (tillDate.isAfter(installment.getFromDate()) && tillDate.isBefore(installment.getDueDate())) {
            int daysInPeriod = Days.daysBetween(installment.getFromDate(), installment.getDueDate()).getDays();
            int tillDays = Days.daysBetween(installment.getFromDate(), tillDate).getDays();
            double interest = calculateInterestForDays(daysInPeriod,
                    installment.getInterestCharged(getCurrency()).getAmount(), tillDays);
            actualAmountTobeAccrued = actualAmountTobeAccrued.plus(interest);
        } else if ((tillDate.isAfter(installment.getFromDate()) && tillDate.isEqual(installment.getDueDate()))
                || (tillDate.isEqual(installment.getFromDate()) && tillDate.isEqual(installment.getDueDate()))
                || (tillDate.isAfter(installment.getFromDate())
                        && tillDate.isAfter(installment.getDueDate()))) {
            actualAmountTobeAccrued = actualAmountTobeAccrued
                    .plus(installment.getInterestAccrued(getCurrency()));
        }/* w ww. java2s  .c o  m*/
    }
    Money accredAmountAfterDate = totalAmountAccrued.minus(actualAmountTobeAccrued);
    if (accredAmountAfterDate.isLessThanZero()) {
        accredAmountAfterDate = Money.zero(getCurrency());
    }
    return accredAmountAfterDate;
}

From source file:com.gst.portfolio.loanaccount.domain.LoanAccountDomainServiceJpa.java

License:Apache License

private void generateLoanScheduleAccrualData(final LocalDate accruedTill,
        final Collection<LoanScheduleAccrualData> loanScheduleAccrualDatas, final Long loanId, Long officeId,
        final LocalDate accrualStartDate, final PeriodFrequencyType repaymentFrequency,
        final Integer repayEvery, final LocalDate interestCalculatedFrom, final Long loanProductId,
        final MonetaryCurrency currency, final CurrencyData currencyData, final Set<LoanCharge> loanCharges,
        final LoanRepaymentScheduleInstallment installment) {

    if (!accruedTill.isBefore(installment.getDueDate()) || (accruedTill.isAfter(installment.getFromDate())
            && !accruedTill.isAfter(installment.getDueDate()))) {
        BigDecimal dueDateFeeIncome = BigDecimal.ZERO;
        BigDecimal dueDatePenaltyIncome = BigDecimal.ZERO;
        LocalDate chargesTillDate = installment.getDueDate();
        if (!accruedTill.isAfter(installment.getDueDate())) {
            chargesTillDate = accruedTill;
        }//  w ww.  j ava 2s.  co m

        for (final LoanCharge loanCharge : loanCharges) {
            if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(installment.getFromDate(),
                    chargesTillDate)) {
                if (loanCharge.isFeeCharge()) {
                    dueDateFeeIncome = dueDateFeeIncome.add(loanCharge.amount());
                } else if (loanCharge.isPenaltyCharge()) {
                    dueDatePenaltyIncome = dueDatePenaltyIncome.add(loanCharge.amount());
                }
            }
        }
        LoanScheduleAccrualData accrualData = new LoanScheduleAccrualData(loanId, officeId,
                installment.getInstallmentNumber(), accrualStartDate, repaymentFrequency, repayEvery,
                installment.getDueDate(), installment.getFromDate(), installment.getId(), loanProductId,
                installment.getInterestCharged(currency).getAmount(),
                installment.getFeeChargesCharged(currency).getAmount(),
                installment.getPenaltyChargesCharged(currency).getAmount(),
                installment.getInterestAccrued(currency).getAmount(),
                installment.getFeeAccrued(currency).getAmount(),
                installment.getPenaltyAccrued(currency).getAmount(), currencyData, interestCalculatedFrom,
                installment.getInterestWaived(currency).getAmount());
        loanScheduleAccrualDatas.add(accrualData);

    }
}

From source file:com.gst.portfolio.loanaccount.domain.LoanOfficerAssignmentHistory.java

License:Apache License

public boolean hasStartDateBefore(final LocalDate matchingDate) {
    return matchingDate.isBefore(getStartDate());
}

From source file:com.gst.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment.java

License:Apache License

private boolean isInAdvance(final LocalDate transactionDate) {
    return transactionDate.isBefore(getDueDate());
}

From source file:com.gst.portfolio.loanaccount.domain.transactionprocessor.AbstractLoanRepaymentScheduleTransactionProcessor.java

License:Apache License

/**
 * This method is responsible for checking if the current transaction is 'an
 * advance/early payment' based on the details passed through.
 * /*from  www.j  a  v a  2  s  . co m*/
 * Default implementation is check transaction date is before installment
 * due date.
 */
protected boolean isTransactionInAdvanceOfInstallment(final int currentInstallmentIndex,
        final List<LoanRepaymentScheduleInstallment> installments, final LocalDate transactionDate,
        @SuppressWarnings("unused") final Money transactionAmount) {

    final LoanRepaymentScheduleInstallment currentInstallment = installments.get(currentInstallmentIndex);

    return transactionDate.isBefore(currentInstallment.getDueDate());
}

From source file:com.gst.portfolio.loanaccount.domain.transactionprocessor.impl.CreocoreLoanRepaymentScheduleTransactionProcessor.java

License:Apache License

/**
 * For creocore, early is defined as any date before the installment due
 * date/*  w w w .  j  av  a2s .c  o  m*/
 */
@SuppressWarnings("unused")
@Override
protected boolean isTransactionInAdvanceOfInstallment(final int currentInstallmentIndex,
        final List<LoanRepaymentScheduleInstallment> installments, final LocalDate transactionDate,
        final Money transactionAmount) {

    final LoanRepaymentScheduleInstallment currentInstallment = installments.get(currentInstallmentIndex);

    return transactionDate.isBefore(currentInstallment.getDueDate());
}

From source file:com.gst.portfolio.loanaccount.domain.transactionprocessor.impl.FineractStyleLoanRepaymentScheduleTransactionProcessor.java

License:Apache License

@Override
protected boolean isTransactionInAdvanceOfInstallment(final int currentInstallmentIndex,
        final List<LoanRepaymentScheduleInstallment> installments, final LocalDate transactionDate,
        final Money transactionAmount) {

    final LoanRepaymentScheduleInstallment currentInstallment = installments.get(currentInstallmentIndex);

    return transactionDate.isBefore(currentInstallment.getDueDate());
}

From source file:com.gst.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData.java

License:Apache License

private LoanSchedulePeriodData(final Integer periodNumber, final LocalDate fromDate, final LocalDate dueDate,
        final BigDecimal principalDisbursed, final BigDecimal chargesDueAtTimeOfDisbursement,
        final boolean isDisbursed) {
    this.period = periodNumber;
    this.fromDate = fromDate;
    this.dueDate = dueDate;
    this.obligationsMetOnDate = null;
    this.complete = null;
    if (fromDate != null) {
        this.daysInPeriod = Days.daysBetween(this.fromDate, this.dueDate).getDays();
    } else {/*from   w  w  w.ja va2 s .c om*/
        this.daysInPeriod = null;
    }
    this.principalDisbursed = principalDisbursed;
    this.principalOriginalDue = null;
    this.principalDue = null;
    this.principalPaid = null;
    this.principalWrittenOff = null;
    this.principalOutstanding = null;
    this.principalLoanBalanceOutstanding = principalDisbursed;

    this.interestOriginalDue = null;
    this.interestDue = null;
    this.interestPaid = null;
    this.interestWaived = null;
    this.interestWrittenOff = null;
    this.interestOutstanding = null;

    this.feeChargesDue = chargesDueAtTimeOfDisbursement;
    if (isDisbursed) {
        this.feeChargesPaid = chargesDueAtTimeOfDisbursement;
        this.feeChargesWaived = null;
        this.feeChargesWrittenOff = null;
        this.feeChargesOutstanding = null;
    } else {
        this.feeChargesPaid = null;
        this.feeChargesWaived = null;
        this.feeChargesWrittenOff = null;
        this.feeChargesOutstanding = chargesDueAtTimeOfDisbursement;
    }

    this.penaltyChargesDue = null;
    this.penaltyChargesPaid = null;
    this.penaltyChargesWaived = null;
    this.penaltyChargesWrittenOff = null;
    this.penaltyChargesOutstanding = null;

    this.totalOriginalDueForPeriod = chargesDueAtTimeOfDisbursement;
    this.totalDueForPeriod = chargesDueAtTimeOfDisbursement;
    this.totalPaidForPeriod = this.feeChargesPaid;
    this.totalPaidInAdvanceForPeriod = null;
    this.totalPaidLateForPeriod = null;
    this.totalWaivedForPeriod = null;
    this.totalWrittenOffForPeriod = null;
    this.totalOutstandingForPeriod = this.feeChargesOutstanding;
    this.totalActualCostOfLoanForPeriod = this.feeChargesDue;
    this.totalInstallmentAmountForPeriod = null;
    if (dueDate.isBefore(new LocalDate())) {
        this.totalOverdue = this.totalOutstandingForPeriod;
    } else {
        this.totalOverdue = null;
    }
}

From source file:com.gst.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData.java

License:Apache License

private LoanSchedulePeriodData(final Integer periodNumber, final LocalDate fromDate, final LocalDate dueDate,
        final BigDecimal principalOriginalDue, final BigDecimal principalOutstanding,
        final BigDecimal interestDueOnPrincipalOutstanding, final BigDecimal feeChargesDueForPeriod,
        final BigDecimal penaltyChargesDueForPeriod, final BigDecimal totalDueForPeriod,
        BigDecimal totalInstallmentAmountForPeriod) {
    this.period = periodNumber;
    this.fromDate = fromDate;
    this.dueDate = dueDate;
    this.obligationsMetOnDate = null;
    this.complete = null;
    if (fromDate != null) {
        this.daysInPeriod = Days.daysBetween(this.fromDate, this.dueDate).getDays();
    } else {/*from  w  w  w  .  j a va  2  s .c  om*/
        this.daysInPeriod = null;
    }
    this.principalDisbursed = null;
    this.principalOriginalDue = principalOriginalDue;
    this.principalDue = principalOriginalDue;
    this.principalPaid = null;
    this.principalWrittenOff = null;
    this.principalOutstanding = principalOriginalDue;
    this.principalLoanBalanceOutstanding = principalOutstanding;

    this.interestOriginalDue = interestDueOnPrincipalOutstanding;
    this.interestDue = interestDueOnPrincipalOutstanding;
    this.interestPaid = null;
    this.interestWaived = null;
    this.interestWrittenOff = null;
    this.interestOutstanding = interestDueOnPrincipalOutstanding;

    this.feeChargesDue = feeChargesDueForPeriod;
    this.feeChargesPaid = null;
    this.feeChargesWaived = null;
    this.feeChargesWrittenOff = null;
    this.feeChargesOutstanding = null;

    this.penaltyChargesDue = penaltyChargesDueForPeriod;
    this.penaltyChargesPaid = null;
    this.penaltyChargesWaived = null;
    this.penaltyChargesWrittenOff = null;
    this.penaltyChargesOutstanding = null;

    this.totalOriginalDueForPeriod = totalDueForPeriod;
    this.totalDueForPeriod = totalDueForPeriod;
    this.totalPaidForPeriod = BigDecimal.ZERO;
    this.totalPaidInAdvanceForPeriod = null;
    this.totalPaidLateForPeriod = null;
    this.totalWaivedForPeriod = null;
    this.totalWrittenOffForPeriod = null;
    this.totalOutstandingForPeriod = totalDueForPeriod;
    this.totalActualCostOfLoanForPeriod = interestDueOnPrincipalOutstanding.add(feeChargesDueForPeriod);
    this.totalInstallmentAmountForPeriod = totalInstallmentAmountForPeriod;

    if (dueDate.isBefore(new LocalDate())) {
        this.totalOverdue = this.totalOutstandingForPeriod;
    } else {
        this.totalOverdue = null;
    }
}

From source file:com.gst.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData.java

License:Apache License

private LoanSchedulePeriodData(final Integer periodNumber, final LocalDate fromDate, final LocalDate dueDate,
        final LocalDate obligationsMetOnDate, final boolean complete, final BigDecimal principalOriginalDue,
        final BigDecimal principalPaid, final BigDecimal principalWrittenOff,
        final BigDecimal principalOutstanding, final BigDecimal principalLoanBalanceOutstanding,
        final BigDecimal interestDueOnPrincipalOutstanding, final BigDecimal interestPaid,
        final BigDecimal interestWaived, final BigDecimal interestWrittenOff,
        final BigDecimal interestOutstanding, final BigDecimal feeChargesDue, final BigDecimal feeChargesPaid,
        final BigDecimal feeChargesWaived, final BigDecimal feeChargesWrittenOff,
        final BigDecimal feeChargesOutstanding, final BigDecimal penaltyChargesDue,
        final BigDecimal penaltyChargesPaid, final BigDecimal penaltyChargesWaived,
        final BigDecimal penaltyChargesWrittenOff, final BigDecimal penaltyChargesOutstanding,
        final BigDecimal totalDueForPeriod, final BigDecimal totalPaid,
        final BigDecimal totalPaidInAdvanceForPeriod, final BigDecimal totalPaidLateForPeriod,
        final BigDecimal totalWaived, final BigDecimal totalWrittenOff, final BigDecimal totalOutstanding,
        final BigDecimal totalActualCostOfLoanForPeriod, final BigDecimal totalInstallmentAmountForPeriod) {
    this.period = periodNumber;
    this.fromDate = fromDate;
    this.dueDate = dueDate;
    this.obligationsMetOnDate = obligationsMetOnDate;
    this.complete = complete;
    if (fromDate != null) {
        this.daysInPeriod = Days.daysBetween(this.fromDate, this.dueDate).getDays();
    } else {/*from   w ww. ja  v a  2 s . c  om*/
        this.daysInPeriod = null;
    }
    this.principalDisbursed = null;
    this.principalOriginalDue = principalOriginalDue;
    this.principalDue = principalOriginalDue;
    this.principalPaid = principalPaid;
    this.principalWrittenOff = principalWrittenOff;
    this.principalOutstanding = principalOutstanding;
    this.principalLoanBalanceOutstanding = principalLoanBalanceOutstanding;

    this.interestOriginalDue = interestDueOnPrincipalOutstanding;
    this.interestDue = interestDueOnPrincipalOutstanding;
    this.interestPaid = interestPaid;
    this.interestWaived = interestWaived;
    this.interestWrittenOff = interestWrittenOff;
    this.interestOutstanding = interestOutstanding;

    this.feeChargesDue = feeChargesDue;
    this.feeChargesPaid = feeChargesPaid;
    this.feeChargesWaived = feeChargesWaived;
    this.feeChargesWrittenOff = feeChargesWrittenOff;
    this.feeChargesOutstanding = feeChargesOutstanding;

    this.penaltyChargesDue = penaltyChargesDue;
    this.penaltyChargesPaid = penaltyChargesPaid;
    this.penaltyChargesWaived = penaltyChargesWaived;
    this.penaltyChargesWrittenOff = penaltyChargesWrittenOff;
    this.penaltyChargesOutstanding = penaltyChargesOutstanding;

    this.totalOriginalDueForPeriod = totalDueForPeriod;
    this.totalDueForPeriod = totalDueForPeriod;
    this.totalPaidForPeriod = totalPaid;
    this.totalPaidInAdvanceForPeriod = totalPaidInAdvanceForPeriod;
    this.totalPaidLateForPeriod = totalPaidLateForPeriod;
    this.totalWaivedForPeriod = totalWaived;
    this.totalWrittenOffForPeriod = totalWrittenOff;
    this.totalOutstandingForPeriod = totalOutstanding;
    this.totalActualCostOfLoanForPeriod = totalActualCostOfLoanForPeriod;
    this.totalInstallmentAmountForPeriod = totalInstallmentAmountForPeriod;

    if (dueDate.isBefore(new LocalDate())) {
        this.totalOverdue = this.totalOutstandingForPeriod;
    } else {
        this.totalOverdue = null;
    }
}