From cb89cf1cc24483a2ac794fce63b2039d5ad2cbc6 Mon Sep 17 00:00:00 2001 From: Oleksii Novikov Date: Fri, 13 Dec 2024 12:38:46 +0200 Subject: [PATCH] FINERACT-2148: Fix undoChargeOff method for zero interest behaviour --- .../apache/fineract/portfolio/loanaccount/domain/Loan.java | 7 +++++-- .../impl/AdvancedPaymentScheduleTransactionProcessor.java | 4 ++-- .../service/LoanWritePlatformServiceJpaRepositoryImpl.java | 3 +++ 3 files changed, 10 insertions(+), 4 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 280693da5f..4803e2de6c 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 @@ -1588,8 +1588,11 @@ public List retrieveListOfTransactionsForReprocessing() { } private static Predicate loanTransactionForReprocessingPredicate() { - return transaction -> transaction.isNotReversed() && (transaction.isChargeOff() || transaction.isReAge() - || transaction.isAccrualActivity() || transaction.isReAmortize() || !transaction.isNonMonetaryTransaction()); + return transaction -> transaction.isNotReversed() + && (transaction.isChargeOff() || transaction.isReAge() || transaction.isAccrualActivity() || transaction.isReAmortize() + || !transaction.isNonMonetaryTransaction()) + || transaction.isReversed() && transaction.isChargeOff() && LoanChargeOffBehaviour.ZERO_INTEREST + .equals(transaction.getLoan().getLoanProductRelatedDetail().getChargeOffBehaviour()); } public List retrieveListOfTransactionsExcludeAccruals() { 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 d7b52bd9e2..d08bb6288f 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 @@ -1172,8 +1172,8 @@ private void handleOverpayment(Money overpaymentPortion, LoanTransaction loanTra private void handleChargeOff(final LoanTransaction loanTransaction, final TransactionCtx transactionCtx) { if (transactionCtx instanceof ProgressiveTransactionCtx progressiveTransactionCtx) { - if (LoanChargeOffBehaviour.ZERO_INTEREST - .equals(loanTransaction.getLoan().getLoanProductRelatedDetail().getChargeOffBehaviour())) { + if (LoanChargeOffBehaviour.ZERO_INTEREST.equals(loanTransaction.getLoan().getLoanProductRelatedDetail().getChargeOffBehaviour()) + && !loanTransaction.isReversed()) { handleZeroInterestChargeOff(loanTransaction, progressiveTransactionCtx); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index ea08a7b337..a544fde4f8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -3348,6 +3348,9 @@ public CommandProcessingResult undoChargeOff(JsonCommand command) { saveLoanWithDataIntegrityViolationChecks(loan); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); businessEventNotifierService.notifyPostBusinessEvent(new LoanUndoChargeOffBusinessEvent(chargedOffTransaction)); + + loan.reprocessTransactions(); + return new CommandProcessingResultBuilder() // .withOfficeId(loan.getOfficeId()) // .withClientId(loan.getClientId()) //