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


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidByRepository.java:
##########
@@ -18,14 +18,26 @@
  */
 package org.apache.fineract.portfolio.loanaccount.domain;
 
+import java.util.List;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 
 public interface LoanChargePaidByRepository extends 
JpaRepository<LoanChargePaidBy, Long>, JpaSpecificationExecutor<LoanCharge> {
 
-    @Query("select lp from LoanChargePaidBy lp where lp.loanCharge=:loanCharge 
and lp.installmentNumber=:installmentNumber")
-    LoanChargePaidBy getLoanChargePaidByLoanCharge(@Param("loanCharge") 
LoanCharge loanCharge,
-            @Param("installmentNumber") Integer installmentNo);
+    @Query("""
+            SELECT lcpb
+            FROM LoanChargePaidBy lcpb
+            JOIN lcpb.loanTransaction lt
+            JOIN lcpb.loanCharge lc
+            WHERE lt.loan = :loan
+                AND lt.reversed = false
+                AND (lt.typeOf = 
org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType.ACCRUAL
+                    OR lt.typeOf = 
org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType.ACCRUAL_ADJUSTMENT)
+                AND (lt.feeChargesPortion > 0 OR lt.penaltyChargesPortion > 0)
+                AND lcpb.installmentNumber IS NULL
+            """)
+    List<LoanChargePaidBy> 
findAccrualTransactionMappingsWithoutInstallmentNumber(@Param("loan") Loan 
loan);

Review Comment:
   Misleading method name... should we rename to "findChargePaidByMappings..."?



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