Package org.mifosplatform.portfolio.loanaccount.domain

Examples of org.mifosplatform.portfolio.loanaccount.domain.LoanTransaction


        final Loan loan = this.loanAssembler.assembleFrom(accountId);

        final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
        final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());

        final LoanTransaction newTransferAcceptanceTransaction = LoanTransaction.withdrawTransfer(loan.getOffice(), loan, transferDate);
        loan.getLoanTransactions().add(newTransferAcceptanceTransaction);
        loan.setLoanStatus(LoanStatus.ACTIVE.getValue());

        this.loanTransactionRepository.save(newTransferAcceptanceTransaction);
        saveLoanWithDataIntegrityViolationChecks(loan);
View Full Code Here


    }

    public LoanTransaction disburseLoanAmountToSavings(final Long loanId, Long loanChargeId, final JsonCommand command,
            final boolean isChargeIdIncludedInJson) {

        LoanTransaction transaction = null;

        this.loanEventApiJsonValidator.validateChargePaymentTransaction(command.json(), isChargeIdIncludedInJson);
        if (isChargeIdIncludedInJson) {
            loanChargeId = command.longValueOfParameterNamed("chargeId");
        }
View Full Code Here

        LoanScheduleModel loanScheduleModel = null;
        List<LoanRepaymentScheduleInstallment> installments = previousSchedule;
        List<LoanRepaymentScheduleInstallment> removeInstallments = new ArrayList<>();
        MonetaryCurrency currency = loanApplicationTerms.getPrincipal().getCurrency();
        LoanTransaction preCloseTransaction = getPreclosureTransaction(transactions, installments, currency, loanApplicationTerms, mc,
                loanCharges);
        Integer updatedInstallmentNumber = 1;
        // temp fix to calculate from start need to fix properly
        recalculateFrom = loanApplicationTerms.getExpectedDisbursementDate();
        for (LoanRepaymentScheduleInstallment installment : installments) {
View Full Code Here

            final List<LoanRepaymentScheduleInstallment> previousSchedule, LoanScheduleModel loanScheduleModel,
            List<LoanRepaymentScheduleInstallment> installments, MonetaryCurrency currency,
            final List<RecalculationDetail> recalculationDetails, final Map<LocalDate, RecalculationDetail> retainRecalculationDetails,
            boolean recalculate, int installmentNumber, List<LoanTransaction> processTransactions, LoanTransaction preCloseTransaction,
            final LocalDate lastTransactionDate, final int penaltyWaitPeriod, final List<LoanTransaction> actualTransactions) {
        LoanTransaction loanTransaction = processTransactions.remove(processTransactions.size() - 1);
        if (!(loanTransaction.isRepayment() || loanTransaction.isInterestWaiver())) {
            processTransactions.add(loanTransaction);
            return loanScheduleModel;
        }
        LocalDate processTransactionsForInterestCompound = loanTransaction.getTransactionDate();
        List<LoanRepaymentScheduleInstallment> scheduleInstallments = getInstallmentsForInterestCompound(installments,
                processTransactionsForInterestCompound, retainRecalculationDetails.keySet());

        if (!scheduleInstallments.isEmpty()) {
            for (LoanRepaymentScheduleInstallment installment : installments) {
                installment.resetDerivedComponents();
                installment.updateDerivedFields(currency, loanApplicationTerms.getExpectedDisbursementDate());
            }
            loanRepaymentScheduleTransactionProcessor.applyTransaction(processTransactions, currency, installments);

            Money principalUnprocessed = Money.zero(currency);
            Money interestUnprocessed = Money.zero(currency);
            Money feeUnprocessed = Money.zero(currency);
            boolean isBeforeFirstInstallment = false;
            if (scheduleInstallments.size() == 1) {
                LoanRepaymentScheduleInstallment installment = scheduleInstallments.get(0);
                if (installment.getInstallmentNumber() == 1
                        && (installment.getDueDate().isAfter(processTransactionsForInterestCompound) || (installment
                                .isRecalculatedInterestComponent() && installment.getDueDate().isEqual(
                                processTransactionsForInterestCompound)))) {
                    isBeforeFirstInstallment = true;
                }
            }
            if (!isBeforeFirstInstallment) {
                for (LoanRepaymentScheduleInstallment installment : scheduleInstallments) {
                    principalUnprocessed = principalUnprocessed.plus(installment.getPrincipalOutstanding(currency));
                    interestUnprocessed = interestUnprocessed.plus(installment.getInterestOutstanding(currency));
                    feeUnprocessed = feeUnprocessed.plus(installment.getFeeChargesOutstanding(currency));
                    feeUnprocessed = feeUnprocessed.plus(installment.getPenaltyChargesOutstanding(currency));
                }
            }
            if (interestUnprocessed.isLessThan(loanTransaction.getAmount(currency))) {
                LoanRepaymentScheduleInstallment lastProcessedInstallment = scheduleInstallments.get(scheduleInstallments.size() - 1);
                LocalDate startDate = lastProcessedInstallment.getDueDate();
                if (isBeforeFirstInstallment) {
                    startDate = loanApplicationTerms.getExpectedDisbursementDate();
                }
View Full Code Here

    private List<LoanTransaction> copyTransactions(List<LoanTransaction> transactions) {
        List<LoanTransaction> loanTransactions = new ArrayList<>();
        for (LoanTransaction loanTransaction : transactions) {
            if (loanTransaction.isNotReversed() && !loanTransaction.isAccrual()) {
                LoanTransaction transaction = LoanTransaction.copyTransactionProperties(loanTransaction);
                loanTransactions.add(transaction);
            }
        }
        return loanTransactions;
    }
View Full Code Here

    }

    private LoanTransaction getPreclosureTransaction(List<LoanTransaction> loanTransactions,
            List<LoanRepaymentScheduleInstallment> installments, MonetaryCurrency currency, final LoanApplicationTerms applicationTerms,
            MathContext mc, final Set<LoanCharge> loanCharges) {
        LoanTransaction precloseTransaction = null;
        Money collectedPrincipal = Money.zero(currency);
        for (LoanTransaction loanTransaction : loanTransactions) {
            if (precloseTransaction == null
                    || (!precloseTransaction.getTransactionDate().isAfter(loanTransaction.getTransactionDate()) && (loanTransaction.getId() == null || (precloseTransaction
                            .getId() != null && loanTransaction.getId().compareTo(precloseTransaction.getId()) == 1)))) {
                precloseTransaction = loanTransaction;
            }
            collectedPrincipal = collectedPrincipal.plus(loanTransaction.getPrincipalPortion());
        }
        if (precloseTransaction != null) {
            LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = calculatePrepaymentAmount(installments, currency,
                    precloseTransaction.getTransactionDate(), applicationTerms.getInterestChargedFromLocalDate(), applicationTerms, mc,
                    loanCharges);
            Money pendingPrinciapl = applicationTerms.getPrincipal().minus(collectedPrincipal)
                    .plus(precloseTransaction.getPrincipalPortion());
            if (pendingPrinciapl.isGreaterThan(loanRepaymentScheduleInstallment.getPrincipal(currency))
                    || precloseTransaction.getAmount(currency).isLessThan(loanRepaymentScheduleInstallment.getTotalOutstanding(currency))) {
                precloseTransaction = null;
            }
        }

        return precloseTransaction;
View Full Code Here

        final MonetaryCurrency currency = loan.getCurrency();
        final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
        final CurrencyData currencyData = applicationCurrency.toData();

        final LoanTransaction waiveOfInterest = loan.deriveDefaultInterestWaiverTransaction();

        final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.WAIVE_INTEREST);

        final BigDecimal amount = waiveOfInterest.getAmount(currency).getAmount();
        final BigDecimal outstandingLoanBalance = null;
        final BigDecimal unrecognizedIncomePortion = null;
        return new LoanTransactionData(null, null, null, transactionType, null, currencyData, waiveOfInterest.getTransactionDate(), amount,
                null, null, null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion);
    }
View Full Code Here

        final MonetaryCurrency currency = loan.getCurrency();
        final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
        final CurrencyData currencyData = applicationCurrency.toData();

        final LoanTransaction transaction = this.loanTransactionRepository.findOne(transactionId);
        if (transaction == null) { throw new LoanTransactionNotFoundException(transactionId); }

        if (transaction.isNotBelongingToLoanOf(loan)) { throw new LoanTransactionNotFoundException(transactionId, loanId); }

        final LoanTransactionsAccountTransferMapper trasfermapper = new LoanTransactionsAccountTransferMapper();
        final String sql = "select " + trasfermapper.accountTransferSchema() + " where tr.loan_id = ? and tr.id = ?";
        final AccountTransferData accountTransferData = this.jdbcTemplate.queryForObject(sql, trasfermapper, loanId, transactionId);
        return transaction.toData(currencyData, accountTransferData);
    }
View Full Code Here

                // pass through for new transactions
                if (loanTransaction.getId() == null) {
                    handleTransaction(loanTransaction, currency, installments, charges);
                    loanTransaction.adjustInterestComponent(currency);
                } else {
                    /**
                     * For existing transactions, check if the re-payment
                     * breakup (principal, interest, fees, penalties) has
                     * changed.<br>
                     **/
                    final LoanTransaction newLoanTransaction = LoanTransaction.copyTransactionProperties(loanTransaction);

                    // Reset derived component of new loan transaction and
                    // re-process transaction
                    handleTransaction(newLoanTransaction, currency, installments, charges);
                    newLoanTransaction.adjustInterestComponent(currency);
                    /**
                     * Check if the transaction amounts have changed. If so,
                     * reverse the original transaction and update
                     * changedTransactionDetail accordingly
                     **/
 
View Full Code Here

            Money amountToProcess = null;
            LocalDate transactionDate = loanTransaction.getTransactionDate();
            if (loanTransaction != preCloseTransaction) {
                transactionDate = recalculationDates.get(transactionDate);
            }
            final LoanTransaction newLoanTransaction = LoanTransaction.copyTransactionProperties(loanTransaction);
            if (newLoanTransaction.isRepayment() || newLoanTransaction.isInterestWaiver() || newLoanTransaction.isRecoveryRepayment()) {
                newLoanTransaction.resetDerivedComponents();
            }

            Money unProcessed = processTransaction(newLoanTransaction, currency, installments, amountToProcess);
            if (loanTransaction.getTransactionDate().isEqual(maxTransactionDate) && transactionDate.isAfter(installment.getFromDate())
                    && transactionDate.isBefore(installment.getDueDate())) {
                Money earlyPayment = currentInstallmentOutstanding.minus(installment.getTotalOutstanding(currency));
                if (earlyPayment.isGreaterThanZero()
                        && (newLoanTransaction.isRepayment() || newLoanTransaction.isInterestWaiver() || newLoanTransaction
                                .isRecoveryRepayment())) {
                    earlypaymentDetail.add(new RecalculationDetail(false, transactionDate, null, earlyPayment, false));
                }
                currentInstallmentOutstanding = installment.getTotalOutstanding(currency);
            }
View Full Code Here

TOP

Related Classes of org.mifosplatform.portfolio.loanaccount.domain.LoanTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.