adamsaghy commented on code in PR #4552:
URL: https://github.com/apache/fineract/pull/4552#discussion_r2039211142


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/DefaultLoanLifecycleStateMachine.java:
##########
@@ -276,4 +274,111 @@ private boolean anyOfAllowedWhenComingFrom(final 
LoanStatus state, final LoanSta
 
         return allowed;
     }
+
+    @Override
+    public void handleLoanRepayment(final Loan loan, final LocalDate 
transactionDate) {
+        final boolean statusChanged = evaluateAndTransitionLoanStatus(loan, 
transactionDate);

Review Comment:
   I wonder whether there is a way to further simplify the things:
   this `evaluateAndTransitionLoanStatus` is doing some calculation and it 
might change status and here we are checking again whether was there any status 
change and if not we try to change status once again.
   
   Can we rework this and make sure:
   - Calculate and change loan status just once -> no further conditions and 
loan status changes in multiple places...
   
   I would like something like this:
   
   * If we had a repayment and loan status was ACTIVE,
     * if current outstanding balance is greater than 0 -> No status change
     * if current outstanding balance is zero and overpaid amount is 0 -> 
CLOSED_OBLIGATIONS_MET
     * if current outstanding balance is zero and overpaid amount is greater 
than 0 -> OVERPAID
     
     
   This logic just an example, but i really want this to be only one place 
where we evaluate and do the necessary loan status change. 
   We should avoid evaluate and change statuses (having the logic) multiple 
places!
    



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