Bhavya-Sonigra opened a new pull request, #6733:
URL: https://github.com/apache/fineract/pull/6733

   ## Description
   
   Jira issue: 
[FINERACT-2990](https://issues.apache.org/jira/browse/FINERACT-2990)
   
   ### Background & Root Cause
   
`HeavensFamilyLoanRepaymentScheduleTransactionProcessor.handleTransactionThatIsPaymentInAdvanceOfInstallment()`,
 early/advance repayments calculate the principal paid on an installment (lines 
129–140). However, lines 142–144 contained an accidental duplicate call to 
`currentInstallment.payPrincipalComponent(transactionDate, 
transactionAmountRemaining)` from the on-time repayment handler. Because 
`transactionAmountRemaining` was already decremented to 0 (or the installment 
principal was already completed), this duplicate call calculated 0 and 
overwrote `principalPortion` with 0.
   
   As a result:
   1. `principalPortion` was set to 0 on the transaction.
   2. The mapping condition `if 
(principalPortion.plus(...).isGreaterThanZero())` evaluated to `false`, causing 
the creation of `LoanTransactionToRepaymentScheduleMapping` to be skipped 
completely.
   3. In addition, `loanTransaction.updateComponents(...)` was being called 
twice on the repayment branch (once inside the `if` block and once at the end 
of the method).
   
   ### Solution
   1. Removed lines 142–144 (the duplicate `payPrincipalComponent` and 
decrement).
   2. Removed the premature call to `loanTransaction.updateComponents(...)` 
inside the `if` block so it is called only once at the end of the method, 
mirroring the interest-waiver fix from FINERACT-2861.
   3. Added unit test 
`inAdvanceRepaymentAppliesPrincipalPortionAndCreatesScheduleMapping` in 
`HeavensFamilyLoanRepaymentScheduleTransactionProcessorTest` to verify that 
early repayments populate `principalPortion` and create the corresponding 
schedule mapping.
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request 
- thanks!
   
   - [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 at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes (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).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [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]

Reply via email to