From f33edee8be1a4cca2337f02d4a7a7cf137035913 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Sun, 22 Dec 2024 11:39:10 -0500 Subject: [PATCH] FINERACT-2148: Stop recalculating interest if the loan is charged-off --- .../portfolio/loanaccount/service/LoanScheduleService.java | 6 +++--- .../impl/AdvancedPaymentScheduleTransactionProcessor.java | 6 +++--- .../service/LoanChargeWritePlatformServiceImpl.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanScheduleService.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanScheduleService.java index a5bf24e662..9c7554a412 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanScheduleService.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanScheduleService.java @@ -54,7 +54,7 @@ public void regenerateRepaymentSchedule(final Loan loan, final ScheduleGenerator } public void recalculateScheduleFromLastTransaction(final Loan loan, final ScheduleGeneratorDTO generatorDTO) { - if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { + if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { regenerateRepaymentScheduleWithInterestRecalculation(loan, generatorDTO); } else { regenerateRepaymentSchedule(loan, generatorDTO); @@ -73,7 +73,7 @@ public ChangedTransactionDetail recalculateScheduleFromLastTransaction(final Loa * loanTransaction.getTransactionDate().isAfter(recalculateFrom)) { recalculateFrom = * loanTransaction.getTransactionDate(); } } generatorDTO.setRecalculateFrom(recalculateFrom); */ - if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { + if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { regenerateRepaymentScheduleWithInterestRecalculation(loan, generatorDTO); } else { regenerateRepaymentSchedule(loan, generatorDTO); @@ -84,7 +84,7 @@ public ChangedTransactionDetail recalculateScheduleFromLastTransaction(final Loa public void regenerateRepaymentScheduleWithInterestRecalculation(final Loan loan, final ScheduleGeneratorDTO generatorDTO) { final LocalDate lastTransactionDate = loan.getLastUserTransactionDate(); final LoanScheduleDTO loanSchedule = loan.getRecalculatedSchedule(generatorDTO); - if (loanSchedule == null) { + if (loanSchedule == null || loan.isChargedOff()) { return; } // Either the installments got recalculated or the model diff --git a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java index d08bb6288f..c95d5c53bc 100644 --- a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java +++ b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java @@ -1583,7 +1583,7 @@ private Money processAllocationsHorizontally(LoanTransaction loanTransaction, Tr transactionMappings, loanTransaction, oldestPastDueInstallment, currency); Loan loan = loanTransaction.getLoan(); if (transactionCtx instanceof ProgressiveTransactionCtx ctx && loan.isInterestBearing() - && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled()) { + && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, transactionAmountUnprocessed, balances, paymentAllocationType, oldestPastDueInstallment, ctx, loanTransactionToRepaymentScheduleMapping, oldestPastDueInstallmentCharges); @@ -1605,7 +1605,7 @@ private Money processAllocationsHorizontally(LoanTransaction loanTransaction, Tr transactionMappings, loanTransaction, dueInstallment, currency); Loan loan = loanTransaction.getLoan(); if (transactionCtx instanceof ProgressiveTransactionCtx ctx && loan.isInterestBearing() - && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled()) { + && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, transactionAmountUnprocessed, balances, paymentAllocationType, dueInstallment, ctx, loanTransactionToRepaymentScheduleMapping, dueInstallmentCharges); @@ -1636,7 +1636,7 @@ private Money processAllocationsHorizontally(LoanTransaction loanTransaction, Tr Loan loan = loanTransaction.getLoan(); if (transactionCtx instanceof ProgressiveTransactionCtx ctx && loan.isInterestBearing() - && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled()) { + && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, evenPortion, balances, paymentAllocationType, inAdvanceInstallment, ctx, loanTransactionToRepaymentScheduleMapping, inAdvanceInstallmentCharges); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java index 7751d18aa2..d0e8495bc9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java @@ -1154,7 +1154,7 @@ private void addInstallmentIfPenaltyAppliedAfterLastDueDate(Loan loan, LocalDate } public Loan runScheduleRecalculation(Loan loan, final LocalDate recalculateFrom) { - if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { + if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled() && !loan.isChargedOff()) { final List existingTransactionIds = loan.findExistingTransactionIds(); ScheduleGeneratorDTO generatorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ChangedTransactionDetail changedTransactionDetail = loanScheduleService