vidakovic commented on code in PR #6106:
URL: https://github.com/apache/fineract/pull/6106#discussion_r3746958678


##########
fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java:
##########
@@ -258,18 +262,23 @@ public List<ChargeToGLAccountMapper> 
fetchPenaltyToIncomeAccountMappingsForSavin
     private List<ChargeToGLAccountMapper> 
fetchChargeToIncomeAccountMappings(final PortfolioProductType 
portfolioProductType,
             final Long loanProductId, final boolean penalty) {
         final List<ProductToGLAccountMapping> mappings = penalty
-                ? 
productToGLAccountMappingRepository.findAllPenaltyMappings(loanProductId, 
portfolioProductType.getValue())
-                : 
productToGLAccountMappingRepository.findAllFeeMappings(loanProductId, 
portfolioProductType.getValue());
+                ? 
productToGLAccountMappingRepository.findAllPenaltyToIncomeAccountMappings(loanProductId,
 portfolioProductType.getValue())
+                : 
productToGLAccountMappingRepository.findAllFeeToIncomeAccountMappings(loanProductId,
 portfolioProductType.getValue());
+        if (mappings.isEmpty()) {
+            return null;

Review Comment:
   @adamsaghy the old code made no sense... checking for an empty collection: 
if it's not empty then returns null (why?!?) else if it's empty then create a 
new empty list (that is just waste and makes no sense whatsoever).
   
   @mansi75 if I'm not reading this the wrong way, your code is reversing the 
above "contract"... which is also not correct. Your code translates to: if  the 
collection is empty then return null... which is the exact opposite of the 
original code (flawed as it might be).
   
   Why not just return an empty list and be done with it... null-safe... ?



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