Example usage for org.joda.time LocalDate toDate

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

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public Date toDate() 

Source Link

Document

Get the date time as a java.util.Date.

Usage

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

License:Apache License

public ChangedTransactionDetail closeAsWrittenOff(final JsonCommand command,
        final LoanLifecycleStateMachine loanLifecycleStateMachine, final Map<String, Object> changes,
        final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds,
        final AppUser currentUser, final ScheduleGeneratorDTO scheduleGeneratorDTO) {

    final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
            .determineProcessor(this.transactionProcessingStrategy);
    ChangedTransactionDetail changedTransactionDetail = closeDisbursements(scheduleGeneratorDTO,
            loanRepaymentScheduleTransactionProcessor, currentUser);

    validateAccountStatus(LoanEvent.WRITE_OFF_OUTSTANDING);

    final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.WRITE_OFF_OUTSTANDING,
            LoanStatus.fromInt(this.loanStatus));

    LoanTransaction loanTransaction = null;
    if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
        this.loanStatus = statusEnum.getValue();
        changes.put("status", LoanEnumerations.status(this.loanStatus));

        existingTransactionIds.addAll(findExistingTransactionIds());
        existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());

        final LocalDate writtenOffOnLocalDate = command.localDateValueOfParameterNamed("transactionDate");
        final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");

        this.closedOnDate = writtenOffOnLocalDate.toDate();
        this.writtenOffOnDate = writtenOffOnLocalDate.toDate();
        this.closedBy = currentUser;
        changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
        changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));

        if (writtenOffOnLocalDate.isBefore(getDisbursementDate())) {
            final String errorMessage = "The date on which a loan is written off cannot be before the loan disbursement date: "
                    + getDisbursementDate().toString();
            throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date",
                    errorMessage, writtenOffOnLocalDate, getDisbursementDate());
        }//from   w ww .j  a va  2  s .  c  o  m

        validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.WRITE_OFF_OUTSTANDING,
                writtenOffOnLocalDate);

        if (writtenOffOnLocalDate.isAfter(DateUtils.getLocalDateOfTenant())) {
            final String errorMessage = "The date on which a loan is written off cannot be in the future.";
            throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.a.future.date", errorMessage,
                    writtenOffOnLocalDate);
        }

        LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
        loanTransaction = LoanTransaction.writeoff(this, getOffice(), writtenOffOnLocalDate, txnExternalId,
                createdDate, currentUser);
        LocalDate lastTransactionDate = getLastUserTransactionDate();
        if (lastTransactionDate.isAfter(writtenOffOnLocalDate)) {
            final String errorMessage = "The date of the writeoff transaction must occur on or before previous transactions.";
            throw new InvalidLoanStateTransitionException("writeoff",
                    "must.occur.on.or.after.other.transaction.dates", errorMessage, writtenOffOnLocalDate);
        }

        this.loanTransactions.add(loanTransaction);

        loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(),
                this.repaymentScheduleInstallments);

        updateLoanSummaryDerivedFields();
    }
    if (changedTransactionDetail == null) {
        changedTransactionDetail = new ChangedTransactionDetail();
    }
    changedTransactionDetail.getNewTransactionMappings().put(0L, loanTransaction);
    return changedTransactionDetail;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

License:Apache License

public ChangedTransactionDetail close(final JsonCommand command,
        final LoanLifecycleStateMachine loanLifecycleStateMachine, final Map<String, Object> changes,
        final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds,
        final ScheduleGeneratorDTO scheduleGeneratorDTO, final AppUser currentUser) {

    validateAccountStatus(LoanEvent.LOAN_CLOSED);

    existingTransactionIds.addAll(findExistingTransactionIds());
    existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());

    final LocalDate closureDate = command.localDateValueOfParameterNamed("transactionDate");
    final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");

    this.closedOnDate = closureDate.toDate();
    changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));

    validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate);
    if (closureDate.isBefore(getDisbursementDate())) {
        final String errorMessage = "The date on which a loan is closed cannot be before the loan disbursement date: "
                + getDisbursementDate().toString();
        throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage,
                closureDate, getDisbursementDate());
    }//w w w. ja  v  a2  s .co  m

    if (closureDate.isAfter(DateUtils.getLocalDateOfTenant())) {
        final String errorMessage = "The date on which a loan is closed cannot be in the future.";
        throw new InvalidLoanStateTransitionException("close", "cannot.be.a.future.date", errorMessage,
                closureDate);
    }
    final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
            .determineProcessor(this.transactionProcessingStrategy);
    ChangedTransactionDetail changedTransactionDetail = closeDisbursements(scheduleGeneratorDTO,
            loanRepaymentScheduleTransactionProcessor, currentUser);

    LoanTransaction loanTransaction = null;
    if (isOpen()) {
        final Money totalOutstanding = this.summary.getTotalOutstanding(loanCurrency());
        if (totalOutstanding.isGreaterThanZero()
                && getInArrearsTolerance().isGreaterThanOrEqualTo(totalOutstanding)) {

            final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL,
                    LoanStatus.fromInt(this.loanStatus));
            if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
                this.loanStatus = statusEnum.getValue();
                changes.put("status", LoanEnumerations.status(this.loanStatus));
            }
            this.closedOnDate = closureDate.toDate();
            loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId,
                    DateUtils.getLocalDateTimeOfTenant(), currentUser);
            final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction,
                    this.loanTransactions);
            if (!isLastTransaction) {
                final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
                throw new InvalidLoanStateTransitionException("close.loan",
                        "must.occur.on.or.after.latest.transaction.date", errorMessage, closureDate);
            }

            this.loanTransactions.add(loanTransaction);

            loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(),
                    this.repaymentScheduleInstallments);

            updateLoanSummaryDerivedFields();
        } else if (totalOutstanding.isGreaterThanZero()) {
            final String errorMessage = "A loan with money outstanding cannot be closed";
            throw new InvalidLoanStateTransitionException("close", "loan.has.money.outstanding", errorMessage,
                    totalOutstanding.toString());
        }
    }

    if (isOverPaid()) {
        final Money totalLoanOverpayment = calculateTotalOverpayment();
        if (totalLoanOverpayment.isGreaterThanZero()
                && getInArrearsTolerance().isGreaterThanOrEqualTo(totalLoanOverpayment)) {
            // TODO - KW - technically should set somewhere that this loan
            // has
            // 'overpaid' amount
            final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL,
                    LoanStatus.fromInt(this.loanStatus));
            if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
                this.loanStatus = statusEnum.getValue();
                changes.put("status", LoanEnumerations.status(this.loanStatus));
            }
            this.closedOnDate = closureDate.toDate();
        } else if (totalLoanOverpayment.isGreaterThanZero()) {
            final String errorMessage = "The loan is marked as 'Overpaid' and cannot be moved to 'Closed (obligations met).";
            throw new InvalidLoanStateTransitionException("close", "loan.is.overpaid", errorMessage,
                    totalLoanOverpayment.toString());
        }
    }

    if (changedTransactionDetail == null) {
        changedTransactionDetail = new ChangedTransactionDetail();
    }
    changedTransactionDetail.getNewTransactionMappings().put(0L, loanTransaction);
    return changedTransactionDetail;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

License:Apache License

public void updateLoanRepaymentScheduleDates(final LocalDate meetingStartDate, final String recuringRule,
        final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays,
        final Boolean reschedulebasedOnMeetingDates, final LocalDate presentMeetingDate,
        final LocalDate newMeetingDate) {

    // first repayment's from date is same as disbursement date.
    /*/*from   ww  w  . j a v  a 2s  .co  m*/
     * meetingStartDate is used as seedDate Capture the seedDate from user
     * and use the seedDate as meetingStart date
     */

    LocalDate tmpFromDate = getDisbursementDate();
    final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail
            .getRepaymentPeriodFrequencyType();
    final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery();
    final String frequency = CalendarUtils
            .getMeetingFrequencyFromPeriodFrequencyType(repaymentPeriodFrequencyType);

    LocalDate newRepaymentDate = null;
    Boolean isFirstTime = true;
    LocalDate latestRepaymentDate = null;
    for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {

        LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();

        if (oldDueDate.isEqual(presentMeetingDate) || oldDueDate.isAfter(presentMeetingDate)) {

            if (isFirstTime) {

                isFirstTime = false;
                newRepaymentDate = newMeetingDate;

            } else {
                // tmpFromDate.plusDays(1) is done to make sure
                // getNewRepaymentMeetingDate method returns next meeting
                // date and not the same as tmpFromDate
                newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, tmpFromDate,
                        tmpFromDate.plusDays(1), loanRepaymentInterval, frequency, workingDays);
            }

            if (isHolidayEnabled) {
                newRepaymentDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(newRepaymentDate,
                        holidays);
            }
            if (latestRepaymentDate == null || latestRepaymentDate.isBefore(newRepaymentDate)) {
                latestRepaymentDate = newRepaymentDate;
            }
            loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
            // reset from date to get actual daysInPeriod

            if (!isFirstTime) {
                loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
            }

            tmpFromDate = newRepaymentDate;// update with new repayment
            // date
        } else {
            tmpFromDate = oldDueDate;
        }
    }
    if (latestRepaymentDate != null) {
        this.expectedMaturityDate = latestRepaymentDate.toDate();
    }
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

License:Apache License

public void updateLoanRepaymentScheduleDates(final LocalDate meetingStartDate, final String recuringRule,
        final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays) {

    // first repayment's from date is same as disbursement date.
    LocalDate tmpFromDate = getDisbursementDate();
    final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail
            .getRepaymentPeriodFrequencyType();
    final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery();
    final String frequency = CalendarUtils
            .getMeetingFrequencyFromPeriodFrequencyType(repaymentPeriodFrequencyType);

    LocalDate newRepaymentDate = null;
    LocalDate seedDate = meetingStartDate;
    LocalDate latestRepaymentDate = null;
    for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {

        LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();

        // FIXME: AA this won't update repayment dates before current date.

        if (oldDueDate.isAfter(seedDate) && oldDueDate.isAfter(DateUtils.getLocalDateOfTenant())) {

            newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, seedDate, oldDueDate,
                    loanRepaymentInterval, frequency, workingDays);

            final LocalDate maxDateLimitForNewRepayment = getMaxDateLimitForNewRepayment(
                    repaymentPeriodFrequencyType, loanRepaymentInterval, tmpFromDate);

            if (newRepaymentDate.isAfter(maxDateLimitForNewRepayment)) {
                newRepaymentDate = CalendarUtils.getNextRepaymentMeetingDate(recuringRule, seedDate,
                        tmpFromDate, loanRepaymentInterval, frequency, workingDays);
            }//www.j  a v  a  2 s  . c  om

            if (isHolidayEnabled) {
                newRepaymentDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(newRepaymentDate,
                        holidays);
            }
            if (latestRepaymentDate == null || latestRepaymentDate.isBefore(newRepaymentDate)) {
                latestRepaymentDate = newRepaymentDate;
            }

            loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
            // reset from date to get actual daysInPeriod
            loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
            tmpFromDate = newRepaymentDate;// update with new repayment
            // date
        } else {
            tmpFromDate = oldDueDate;
        }
    }
    if (latestRepaymentDate != null) {
        this.expectedMaturityDate = latestRepaymentDate.toDate();
    }
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

License:Apache License

public ChangedTransactionDetail updateDisbursementDateAndAmountForTranche(
        final LoanDisbursementDetails disbursementDetails, final JsonCommand command,
        final Map<String, Object> actualChanges, final ScheduleGeneratorDTO scheduleGeneratorDTO,
        final AppUser currentUser) {
    final Locale locale = command.extractLocale();
    validateAccountStatus(LoanEvent.LOAN_EDIT_MULTI_DISBURSE_DATE);
    final BigDecimal principal = command.bigDecimalValueOfParameterNamed(
            LoanApiConstants.updatedDisbursementPrincipalParameterName, locale);
    final LocalDate expectedDisbursementDate = command
            .localDateValueOfParameterNamed(LoanApiConstants.updatedDisbursementDateParameterName);
    disbursementDetails.updateExpectedDisbursementDateAndAmount(expectedDisbursementDate.toDate(), principal);
    actualChanges.put(LoanApiConstants.disbursementDateParameterName,
            command.stringValueOfParameterNamed(LoanApiConstants.disbursementDateParameterName));
    actualChanges.put(LoanApiConstants.disbursementIdParameterName,
            command.stringValueOfParameterNamed(LoanApiConstants.disbursementIdParameterName));
    actualChanges.put(LoanApiConstants.disbursementPrincipalParameterName, command
            .bigDecimalValueOfParameterNamed(LoanApiConstants.disbursementPrincipalParameterName, locale));

    Collection<LoanDisbursementDetails> loanDisburseDetails = this.getDisbursementDetails();
    BigDecimal setPrincipalAmount = BigDecimal.ZERO;
    for (LoanDisbursementDetails details : loanDisburseDetails) {
        setPrincipalAmount = setPrincipalAmount.add(details.principal());
    }//from ww  w .  jav a  2 s.co  m

    this.loanRepaymentScheduleDetail.setPrincipal(setPrincipalAmount);
    if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
        regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser);
    } else {
        regenerateRepaymentSchedule(scheduleGeneratorDTO, currentUser);
    }

    final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
            .determineProcessor(this.transactionProcessingStrategy);
    final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
    ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor
            .handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(),
                    this.repaymentScheduleInstallments, charges());
    for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings()
            .entrySet()) {
        mapEntry.getValue().updateLoan(this);
        this.loanTransactions.add(mapEntry.getValue());
    }

    return changedTransactionDetail;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainServiceJpa.java

License:Apache License

@Override
public LoanTransaction makeRefund(final Long accountId, final CommandProcessingResultBuilder builderResult,
        final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
        final String noteText, final String txnExternalId) {
    AppUser currentUser = getAppUserIfPresent();
    boolean isAccountTransfer = true;
    final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
    checkClientOrGroupActive(loan);//from   w w  w  .j  av a2 s . c om
    this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REFUND,
            constructEntityMap(BUSINESS_ENTITY.LOAN, loan));
    final List<Long> existingTransactionIds = new ArrayList<>();
    final List<Long> existingReversedTransactionIds = new ArrayList<>();

    final Money refundAmount = Money.of(loan.getCurrency(), transactionAmount);
    final LoanTransaction newRefundTransaction = LoanTransaction.refund(loan.getOffice(), refundAmount,
            paymentDetail, transactionDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
    final boolean allowTransactionsOnHoliday = this.configurationDomainService
            .allowTransactionsOnHolidayEnabled();
    final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
            transactionDate.toDate(), HolidayStatusType.ACTIVE.getValue());
    final WorkingDays workingDays = this.workingDaysRepository.findOne();
    final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService
            .allowTransactionsOnNonWorkingDayEnabled();

    loan.makeRefund(newRefundTransaction, defaultLoanLifecycleStateMachine(), existingTransactionIds,
            existingReversedTransactionIds, allowTransactionsOnHoliday, holidays, workingDays,
            allowTransactionsOnNonWorkingDay);

    saveLoanTransactionWithDataIntegrityViolationChecks(newRefundTransaction);
    this.loanRepository.save(loan);

    if (StringUtils.isNotBlank(noteText)) {
        final Note note = Note.loanTransactionNote(loan, newRefundTransaction, noteText);
        this.noteRepository.save(note);
    }

    postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
    this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REFUND,
            constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newRefundTransaction));
    builderResult.withEntityId(newRefundTransaction.getId()) //
            .withOfficeId(loan.getOfficeId()) //
            .withClientId(loan.getClientId()) //
            .withGroupId(loan.getGroupId()); //

    return newRefundTransaction;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainServiceJpa.java

License:Apache License

@Override
public LoanTransaction makeRefundForActiveLoan(Long accountId, CommandProcessingResultBuilder builderResult,
        LocalDate transactionDate, BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText,
        String txnExternalId) {//from  ww  w  .ja v  a 2  s  . co m
    final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
    checkClientOrGroupActive(loan);
    this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REFUND,
            constructEntityMap(BUSINESS_ENTITY.LOAN, loan));
    final List<Long> existingTransactionIds = new ArrayList<>();
    final List<Long> existingReversedTransactionIds = new ArrayList<>();
    AppUser currentUser = getAppUserIfPresent();

    final Money refundAmount = Money.of(loan.getCurrency(), transactionAmount);
    final LoanTransaction newRefundTransaction = LoanTransaction.refundForActiveLoan(loan.getOffice(),
            refundAmount, paymentDetail, transactionDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(),
            currentUser);
    final boolean allowTransactionsOnHoliday = this.configurationDomainService
            .allowTransactionsOnHolidayEnabled();
    final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
            transactionDate.toDate(), HolidayStatusType.ACTIVE.getValue());
    final WorkingDays workingDays = this.workingDaysRepository.findOne();
    final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService
            .allowTransactionsOnNonWorkingDayEnabled();

    loan.makeRefundForActiveLoan(newRefundTransaction, defaultLoanLifecycleStateMachine(),
            existingTransactionIds, existingReversedTransactionIds, allowTransactionsOnHoliday, holidays,
            workingDays, allowTransactionsOnNonWorkingDay);

    this.loanTransactionRepository.save(newRefundTransaction);
    this.loanRepository.save(loan);

    if (StringUtils.isNotBlank(noteText)) {
        final Note note = Note.loanTransactionNote(loan, newRefundTransaction, noteText);
        this.noteRepository.save(note);
    }

    postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
    recalculateAccruals(loan);
    this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REFUND,
            constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newRefundTransaction));

    builderResult.withEntityId(newRefundTransaction.getId()) //
            .withOfficeId(loan.getOfficeId()) //
            .withClientId(loan.getClientId()) //
            .withGroupId(loan.getGroupId()); //

    return newRefundTransaction;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalculationDetails.java

License:Apache License

public void update(final JsonCommand command, final Map<String, Object> actualChanges) {
    if (command.isChangeInLocalDateParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName,
            getRestFrequencyLocalDate())) {
        final String dateFormatAsInput = command.dateFormat();
        final String localeAsInput = command.locale();
        final String valueAsInput = command
                .stringValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName);
        actualChanges.put(LoanProductConstants.recalculationRestFrequencyDateParamName, valueAsInput);
        actualChanges.put("dateFormat", dateFormatAsInput);
        actualChanges.put("locale", localeAsInput);

        final LocalDate newValue = command
                .localDateValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName);
        if (newValue == null || getRestFrequencyType().isSameAsRepayment()) {
            this.restFrequencyDate = null;
        } else {/*from ww w .j a  va 2s  .  c o m*/
            this.restFrequencyDate = newValue.toDate();
        }
    }

    if (command.isChangeInLocalDateParameterNamed(
            LoanProductConstants.recalculationCompoundingFrequencyDateParamName,
            getCompoundingFrequencyLocalDate())) {
        final String dateFormatAsInput = command.dateFormat();
        final String localeAsInput = command.locale();
        final String valueAsInput = command.stringValueOfParameterNamed(
                LoanProductConstants.recalculationCompoundingFrequencyDateParamName);
        actualChanges.put(LoanProductConstants.recalculationCompoundingFrequencyDateParamName, valueAsInput);
        actualChanges.put("dateFormat", dateFormatAsInput);
        actualChanges.put("locale", localeAsInput);

        final LocalDate newValue = command.localDateValueOfParameterNamed(
                LoanProductConstants.recalculationCompoundingFrequencyDateParamName);
        if (newValue == null || !getInterestRecalculationCompoundingMethod().isCompoundingEnabled()
                || getCompoundingFrequencyType().isSameAsRepayment()) {
            this.compoundingFrequencyDate = null;
        } else {
            this.compoundingFrequencyDate = newValue.toDate();
        }
    }
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment.java

License:Apache License

public LoanRepaymentScheduleInstallment(final Loan loan, final Integer installmentNumber,
        final LocalDate fromDate, final LocalDate dueDate, final BigDecimal principal,
        final BigDecimal interest, final BigDecimal feeCharges, final BigDecimal penaltyCharges,
        boolean recalculatedInterestComponent) {
    this.loan = loan;
    this.installmentNumber = installmentNumber;
    this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate();
    this.dueDate = dueDate.toDateTimeAtStartOfDay().toDate();
    this.principal = defaultToNullIfZero(principal);
    this.interestCharged = defaultToNullIfZero(interest);
    this.feeChargesCharged = defaultToNullIfZero(feeCharges);
    this.penaltyCharges = defaultToNullIfZero(penaltyCharges);
    this.obligationsMet = false;
    this.recalculatedInterestComponent = recalculatedInterestComponent;
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.PaymentInventoryPdc.java

License:Apache License

public PaymentInventoryPdc(final Integer period, final LocalDate date, final BigDecimal amount,
        final LocalDate chequeDate, final Long chequeno, final String nameOfBank, final String ifscCode,
        final PdcPresentationEnumOption status, final boolean makePresentation) {
    this.period = period;
    this.amount = amount;
    this.chequeDate = chequeDate.toDate();
    this.chequeno = chequeno;
    this.date = date.toDate();
    this.ifscCode = ifscCode;
    this.nameOfBank = nameOfBank;
    this.presentationStatus = status.getValue();
    this.makePresentation = makePresentation;

}