From e91177fcc6c362d5899648645da050218cfc870f Mon Sep 17 00:00:00 2001 From: Oleksii Novikov Date: Tue, 17 Dec 2024 13:10:03 +0200 Subject: [PATCH] FINERACT-2148: Update instalments interest with zero after charge off with interest recalculation enabled --- .../fineract/portfolio/loanaccount/domain/Loan.java | 6 ++++++ .../AdvancedPaymentScheduleTransactionProcessor.java | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 27bb50d75a..0d47a4f6c0 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -3572,4 +3572,10 @@ public LoanRepaymentScheduleTransactionProcessor getTransactionProcessor() { public boolean isProgressiveSchedule() { return getLoanProductRelatedDetail().getLoanScheduleType() == PROGRESSIVE; } + + public boolean isTransactionBeforeZeroInterestChargeOff(final LoanTransaction transaction) { + return !this.isChargedOff() + || !LoanChargeOffBehaviour.ZERO_INTEREST.equals(this.getLoanProductRelatedDetail().getChargeOffBehaviour()) + || !transaction.getTransactionDate().isAfter(this.getChargedOffOnDate()); + } } 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..016c75d759 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,8 @@ 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() + && loanTransaction.getLoan().isTransactionBeforeZeroInterestChargeOff(loanTransaction)) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, transactionAmountUnprocessed, balances, paymentAllocationType, oldestPastDueInstallment, ctx, loanTransactionToRepaymentScheduleMapping, oldestPastDueInstallmentCharges); @@ -1605,7 +1606,8 @@ 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() + && loanTransaction.getLoan().isTransactionBeforeZeroInterestChargeOff(loanTransaction)) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, transactionAmountUnprocessed, balances, paymentAllocationType, dueInstallment, ctx, loanTransactionToRepaymentScheduleMapping, dueInstallmentCharges); @@ -1636,7 +1638,8 @@ private Money processAllocationsHorizontally(LoanTransaction loanTransaction, Tr Loan loan = loanTransaction.getLoan(); if (transactionCtx instanceof ProgressiveTransactionCtx ctx && loan.isInterestBearing() - && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled()) { + && loan.getLoanProductRelatedDetail().isInterestRecalculationEnabled() + && loanTransaction.getLoan().isTransactionBeforeZeroInterestChargeOff(loanTransaction)) { paidPortion = handlingPaymentAllocationForInterestBearingProgressiveLoan(loanTransaction, evenPortion, balances, paymentAllocationType, inAdvanceInstallment, ctx, loanTransactionToRepaymentScheduleMapping, inAdvanceInstallmentCharges);