ptuomola commented on a change in pull request #1536:
URL: https://github.com/apache/fineract/pull/1536#discussion_r543710273



##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
##########
@@ -168,6 +180,40 @@ public LoanTransaction makeRepayment(final Loan loan, 
final CommandProcessingRes
         final List<Long> existingReversedTransactionIds = new ArrayList<>();
 
         final Money repaymentAmount = Money.of(loan.getCurrency(), 
transactionAmount);
+
+        Money outstandingBalance = Money.of(loan.getCurrency(), 
loan.getSummary().getTotalOutstanding());
+
+        if (outstandingBalance.isZero()) { // In writtenOff loans, the 
outstandingBalance is transferred to writtenOff
+            final Money writtenOffBalance = Money.of(loan.getCurrency(), 
loan.getSummary().getTotalWrittenOff());
+
+            if (writtenOffBalance.isGreaterThanZero()) { // When outstanding 
balance is 0 & writtenbalance is greater
+                                                         // than 0,
+                                                         // it confirms that 
the loan has been writtenOff.
+                final Money totalRecoveryPaid = Money.of(loan.getCurrency(), 
loan.getSummary().getTotalRecoveryPaid());
+
+                if 
(writtenOffBalance.isGreaterThanOrEqualTo(repaymentAmount.plus(totalRecoveryPaid))
 && isAvoidLoanOverpaymentEnabled) {
+                    outstandingBalance = writtenOffBalance; // transferring 
the writtenOff Balance to Outstanding for

Review comment:
       Hmm... not quite sure I understand this. Seems that this code allows 
repayments to be used to pay written off amounts. Whilst this may be right 
(though should we not deduct the amount transferred from writtenOffBalance?), 
why/how is this linked to the functionality to stop overpayments? 
   
   In other words, why does turning off overpayments for loans also change how 
we handle written off balances? 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to