ruzeynalov commented on code in PR #5825:
URL: https://github.com/apache/fineract/pull/5825#discussion_r3225321608


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -650,11 +650,17 @@ private void handleInterestRefund(final LoanTransaction 
loanTransaction, final T
                     final Money interestAfterRefund = 
interestRefundService.totalInterestByTransactions(this, loan.getId(), 
targetDate,
                             modifiedTransactions, unmodifiedTransactionIds, 
ctx.getActiveLoanTermVariations());
                     final Money newAmount = 
interestBeforeRefund.minus(progCtx.getSumOfInterestRefundAmount()).minus(interestAfterRefund);
-                    loanTransaction.updateAmount(newAmount.getAmount());
+                    
loanTransaction.updateAmount(MathUtil.negativeToZero(newAmount).getAmount());

Review Comment:
   @galovics   Thanks for pushing back. As @alberto-art3ch already explained in 
this thread, newAmount is reachable as ≤ 0 during reverse-replay: a backdated 
GoodwillCredit (or any other replay trigger) replays the schedule against a 
model whose principal has already been credited by a prior CBR, which reduces 
future scheduled interest.
   
   The replay-time copy of this interest-refund transaction has no 
loanTransactionRelations, so it recalculates against the post-CBR model and 
interestAfterRefund can legitimately exceed interestBeforeRefund − 
sumOfInterestRefundAmount — clamping to zero is the correct truncation because 
there is no remaining interest to refund.
   
   @alberto-art3ch I assume you will take care of the implementing code-side 
changes



-- 
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