Skip to content

Commit f853898

Browse files
mariiaKraievskaadamsaghy
authored andcommitted
FINERACT-2181: New Loan Accrual Activity transactions publish LoanAdjustTransaction event during loan reopen
1 parent 1d24a8c commit f853898

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualActivity.feature

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7556,4 +7556,36 @@ Feature: LoanAccrualActivity
75567556
And Customer makes "AUTOPAY" repayment on "26 May 2025" with 107.75 EUR transaction amount
75577557
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
75587558
Then Loan has 0 outstanding amount
7559-
7559+
7560+
@TestRailId:C3802
7561+
Scenario: Correct Accrual Activity event publishing after loan reactivation
7562+
Given Admin sets the business date to "05 May 2023"
7563+
And Admin creates a client with random data
7564+
When Admin sets the business date to "24 June 2025"
7565+
And Admin creates a fully customized loan with the following data:
7566+
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
7567+
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_REFUND_INTEREST_RECALC_DOWNPAYMENT_ACCRUAL_ACTIVITY | 05 May 2023 | 359.79 | 9.99 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
7568+
And Admin successfully approves the loan on "05 May 2023" with "359.79" amount and expected disbursement date on "05 May 2023"
7569+
And Admin successfully disburse the loan on "05 May 2023" with "359.79" EUR transaction amount
7570+
When Customer makes "GOODWILL_CREDIT" transaction with "AUTOPAY" payment type on "19 May 2023" with 270.85 EUR transaction amount and system-generated Idempotency key
7571+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "19 May 2023"
7572+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
7573+
When Customer undo "1"th transaction made on "19 May 2023"
7574+
Then Loan status will be "ACTIVE"
7575+
And Loan Transactions tab has the following data:
7576+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
7577+
| 05 May 2023 | Disbursement | 359.79 | 0.0 | 0.0 | 0.0 | 0.0 | 359.79 | false | false |
7578+
| 05 May 2023 | Down Payment | 89.95 | 89.95 | 0.0 | 0.0 | 0.0 | 269.84 | false | false |
7579+
| 19 May 2023 | Goodwill Credit | 270.85 | 269.84 | 1.01 | 0.0 | 0.0 | 0.0 | true | false |
7580+
| 05 June 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | true |
7581+
| 05 July 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | false |
7582+
| 05 August 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | false |
7583+
| 05 September 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | false |
7584+
| 05 October 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | false |
7585+
| 05 November 2023 | Accrual | 1.01 | 0.0 | 1.01 | 0.0 | 0.0 | 0.0 | false | false |
7586+
| 05 November 2023 | Accrual Activity | 2.25 | 0.0 | 2.25 | 0.0 | 0.0 | 0.0 | false | false |
7587+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "05 July 2023"
7588+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "05 August 2023"
7589+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "05 September 2023"
7590+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "05 October 2023"
7591+
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "05 November 2023"

fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualActivityProcessingServiceImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void processAccrualActivityForLoanReopen(final @NonNull Loan loan) {
177177
}
178178
// grab the latest AccrualActivityTransaction
179179
// it does not matter if it is on an installment due date or not because it was posted due to loan close
180-
final Optional<LoanTransaction> lastAccrualActivityMarkedToReverse = loanTransactionRepository
180+
Optional<LoanTransaction> lastAccrualActivityMarkedToReverse = loanTransactionRepository
181181
.findNonReversedByLoanAndType(loan, LoanTransactionType.ACCRUAL_ACTIVITY, PageRequest.of(0, 1)) //
182182
.stream().findFirst();
183183

@@ -195,9 +195,10 @@ public void processAccrualActivityForLoanReopen(final @NonNull Loan loan) {
195195
return isDueBefore && isAfterOrEqualToLastAccrualDate;
196196
}).sorted(Comparator.comparing(LoanRepaymentScheduleInstallment::getDueDate)).toList();
197197

198-
installments.forEach(installment -> {
198+
for (LoanRepaymentScheduleInstallment installment : installments) {
199199
makeOrReplayActivity(loan, installment, lastAccrualActivityMarkedToReverse.orElse(null));
200-
});
200+
lastAccrualActivityMarkedToReverse = Optional.empty();
201+
}
201202

202203
if (installments.isEmpty()) {
203204
lastAccrualActivityMarkedToReverse.ifPresent(this::reverseAccrualActivityTransaction);

0 commit comments

Comments
 (0)