francisguchie commented on a change in pull request #1536:
URL: https://github.com/apache/fineract/pull/1536#discussion_r546602134
##########
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:
@rrpawar96
thanks for sharing these details
----------------------------------------------------------------
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]