Bhavya-Sonigra opened a new pull request, #6740: URL: https://github.com/apache/fineract/pull/6740
## Description Jira issue: FINERACT-2993 ### Background & Root Cause In `RBILoanRepaymentScheduleTransactionProcessor.handleTransactionThatIsALateRepaymentOfInstallment()`, when handling late repayments where payment covers an overdue installment and partially pays subsequent installment principal, the outer-scoped `feeChargesPortion` and `penaltyChargesPortion` from the overdue installment leak into subsequent installment schedule mappings (lines 172–176). This causes: 1. Fee and penalty charges from previous installments to be duplicated and mapped to subsequent installments that never accrued those charges. 2. The sum of the mapping amounts in `m_loan_transaction_repayment_schedule_mapping` to exceed the actual payment amount of the parent transaction (e.g. $650.00 mapped on a $600.00 payment). 3. Accounting anomalies during chargebacks and reverse-replay. ### Solution 1. In the second loop of `handleTransactionThatIsALateRepaymentOfInstallment`, reset `feeChargesPortion` and `penaltyChargesPortion` to zero (`Money.zero(currency)`) when creating schedule mappings for subsequent installments. 2. Ensure schedule mapping is only added when `principalPortion.isGreaterThanZero()`. 3. Added a dedicated unit test `RBILoanRepaymentScheduleTransactionProcessorTest` verifying that subsequent installment mappings do not inherit fees or penalties from prior overdue installments. ## Verification - Added unit test: `RBILoanRepaymentScheduleTransactionProcessorTest` (PASSED). - Provider Unit Tests: `./gradlew :fineract-provider:test` (1,893 tests executed, all PASSED). - Full Integration Tests: `./gradlew :integration-tests:test` (2,967 tests executed, all PASSED). - Quality checks: `./gradlew spotlessCheck checkstyleMain checkstyleTest rat` (all PASSED). ## Checklist - [x] Write the commit message as per our guidelines https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests - [x] Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers. - [x] Create/update unit or integration tests https://fineract.apache.org/docs/current/#_testing for verifying the changes made. - [x] Follow our coding conventions https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions. - [ ] Add required Swagger annotation and update API documentation (N/A - no API contract changes) - [x] This PR must not be a "code dump" https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit. - [x] If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately. - [x] I followed the AI Policy https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
