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.domain.Loan.java

License:Apache License

public LocalDate getAccruedTill() {
    LocalDate accruedTill = null;
    if (this.accruedTill != null) {
        accruedTill = new LocalDate(this.accruedTill);
    }/*from www.jav a2s  .c  o  m*/
    return accruedTill;
}

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

License:Apache License

public LocalDate fetchInterestRecalculateFromDate() {
    LocalDate interestRecalculatedOn = null;
    if (this.interestRecalculatedOn == null) {
        interestRecalculatedOn = getDisbursementDate();
    } else {//from   w  ww. java2  s.  c  o m
        interestRecalculatedOn = new LocalDate(this.interestRecalculatedOn);
    }
    return interestRecalculatedOn;
}

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

License:Apache License

/**
 * @return loan disbursement data/*from  w  w  w. j  a  v a 2  s .c o  m*/
 **/
public List<DisbursementData> getDisbursmentData() {
    Iterator<LoanDisbursementDetails> iterator = this.getDisbursementDetails().iterator();
    List<DisbursementData> disbursementData = new ArrayList<>();

    while (iterator.hasNext()) {
        LoanDisbursementDetails loanDisbursementDetails = iterator.next();

        LocalDate expectedDisbursementDate = null;
        LocalDate actualDisbursementDate = null;

        if (loanDisbursementDetails.expectedDisbursementDate() != null) {
            expectedDisbursementDate = new LocalDate(loanDisbursementDetails.expectedDisbursementDate());
        }

        if (loanDisbursementDetails.actualDisbursementDate() != null) {
            actualDisbursementDate = new LocalDate(loanDisbursementDetails.actualDisbursementDate());
        }

        disbursementData.add(new DisbursementData(loanDisbursementDetails.getId(), expectedDisbursementDate,
                actualDisbursementDate, loanDisbursementDetails.principal(), null, null));
    }

    return disbursementData;
}

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

License:Apache License

private void updateLoanToLastDisbursalState(LocalDate actualDisbursementDate) {

    for (final LoanCharge charge : charges()) {
        if (charge.isOverdueInstallmentCharge()) {
            charge.setActive(false);//from   w  ww  .  ja  v  a 2  s  .c  om
        } else if (charge.isTrancheDisbursementCharge() && actualDisbursementDate.equals(new LocalDate(
                charge.getTrancheDisbursementCharge().getloanDisbursementDetails().actualDisbursementDate()))) {
            charge.resetToOriginal(loanCurrency());
        }
    }
    for (final LoanDisbursementDetails details : this.disbursementDetails) {
        if (actualDisbursementDate.equals(new LocalDate(details.actualDisbursementDate()))) {
            this.loanRepaymentScheduleDetail.setPrincipal(getDisbursedAmount().subtract(details.principal()));
            details.updateActualDisbursementDate(null);
        }
    }
    updateLoanSummaryDerivedFields();
}

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

License:Apache License

@Override
public void recalculateAccruals(Loan loan, boolean isInterestCalcualtionHappened) {
    LocalDate accruedTill = loan.getAccruedTill();
    if (!loan.isPeriodicAccrualAccountingEnabledOnLoanProduct() || !isInterestCalcualtionHappened
            || accruedTill == null || loan.isNpa() || !loan.status().isActive()) {
        return;//from  www .j a va  2s  . com
    }

    boolean isOrganisationDateEnabled = this.configurationDomainService.isOrganisationstartDateEnabled();
    Date organisationStartDate = new Date();
    if (isOrganisationDateEnabled) {
        organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
    }
    Collection<LoanScheduleAccrualData> loanScheduleAccrualDatas = new ArrayList<>();
    List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
    Long loanId = loan.getId();
    Long officeId = loan.getOfficeId();
    LocalDate accrualStartDate = null;
    PeriodFrequencyType repaymentFrequency = loan.repaymentScheduleDetail().getRepaymentPeriodFrequencyType();
    Integer repayEvery = loan.repaymentScheduleDetail().getRepayEvery();
    LocalDate interestCalculatedFrom = loan.getInterestChargedFromDate();
    Long loanProductId = loan.productId();
    MonetaryCurrency currency = loan.getCurrency();
    ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository
            .findOneWithNotFoundDetection(currency);
    CurrencyData currencyData = applicationCurrency.toData();
    Set<LoanCharge> loanCharges = loan.charges();

    for (LoanRepaymentScheduleInstallment installment : installments) {
        if (installment.getDueDate().isAfter(loan.getMaturityDate())) {
            accruedTill = DateUtils.getLocalDateOfTenant();
        }
        if (!isOrganisationDateEnabled
                || new LocalDate(organisationStartDate).isBefore(installment.getDueDate())) {
            generateLoanScheduleAccrualData(accruedTill, loanScheduleAccrualDatas, loanId, officeId,
                    accrualStartDate, repaymentFrequency, repayEvery, interestCalculatedFrom, loanProductId,
                    currency, currencyData, loanCharges, installment);
        }
    }

    if (!loanScheduleAccrualDatas.isEmpty()) {
        String error = this.loanAccrualPlatformService.addPeriodicAccruals(accruedTill,
                loanScheduleAccrualDatas);
        if (error.length() > 0) {
            String globalisationMessageCode = "error.msg.accrual.exception";
            throw new GeneralPlatformDomainRuleException(globalisationMessageCode, error, error);
        }
    }
}

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

License:Apache License

public LocalDate expectedDisbursementDateAsLocalDate() {
    LocalDate expectedDisburseDate = null;
    if (this.expectedDisbursementDate != null) {
        expectedDisburseDate = new LocalDate(this.expectedDisbursementDate);
    }/*from  w w w .  j a  va 2  s.c  o m*/
    return expectedDisburseDate;
}

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

License:Apache License

public DisbursementData toData() {
    LocalDate expectedDisburseDate = expectedDisbursementDateAsLocalDate();
    LocalDate actualDisburseDate = null;
    if (this.actualDisbursementDate != null) {
        actualDisburseDate = new LocalDate(this.actualDisbursementDate);
    }/*from w  w  w .  j  a  v  a 2 s .  co m*/
    return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal, null, null);
}

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

License:Apache License

public LocalDate getEffectiveDate() {
    return new LocalDate(this.effectiveDate);
}

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

License:Apache License

/**
 * If endDate is null then return false.
 * //ww  w  .  jav a 2  s  .c om
 * @param compareDate
 * @return
 */
public boolean isEndDateAfter(final LocalDate compareDate) {
    return this.endDate == null ? false : new LocalDate(this.endDate).isAfter(compareDate);
}

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

License:Apache License

public LocalDate getEndDate() {
    return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.endDate), null);
}