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


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionRepository.java:
##########
@@ -70,4 +72,51 @@ Collection<LoanScheduleDelinquencyData> 
fetchLoanTransactionsByTypeAndLessOrEqua
 
     @Query(FIND_LOAN_ID_BY_ID)
     Optional<Long> findLoanIdById(@Param("id") Long id);
+
+    @Query("""
+            SELECT CASE WHEN COUNT(lt) > 0 THEN false ELSE true END
+            FROM LoanTransaction lt
+            WHERE lt.loan.id = :loanId
+            AND lt.reversed = false
+            AND lt.typeOf != 
org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType.DISBURSEMENT
+            AND lt.dateOf > :transactionDate
+            """)
+    boolean isChronologicallyLatestRepaymentOrWaiver(@Param("transactionDate") 
LocalDate transactionDate, @Param("loanId") Long loanId);
+
+    @Query("""
+            SELECT CASE WHEN COUNT(lt) > 0 THEN false ELSE true END
+            FROM LoanTransaction lt
+            WHERE lt.loan.id = :loanId
+            AND lt.reversed = false
+            AND lt.dateOf > :transactionDate
+            """)
+    boolean isChronologicallyLatest(@Param("transactionDate") LocalDate 
transactionDate, @Param("loanId") Long loanId);
+
+    @Query("""
+            SELECT lt.dateOf FROM LoanTransaction lt
+            WHERE lt.loan.id = :loanId
+            AND lt.reversed = false
+            AND (
+                lt.typeOf IN (

Review Comment:
   Lets simplify this a bit:
   Keep only the `lt.typeOf NOT IN` part... that's safer...



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