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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountInterestPostingServiceImpl.java:
##########
@@ -444,6 +548,26 @@ protected void recalculateDailyBalances(final Money 
openingAccountBalance, final
                     accountTransaction.updateRunningBalance(runningBalance);
                     addTransactionToExisting(accountTransaction, 
savingsAccountData);
 
+                    isTransactionsModified = true;
+                } else if 
(overdraftAmount.isNotEqualTo(Money.of(savingsAccountData.getCurrency(), 
transaction.getOverdraftAmount()))

Review Comment:
   What i see this method `recalculateDailyBalances` is huge, and doing 
repetitive things:
   ```
   if (transaction.isChargeTransaction()) {
                           Set<SavingsAccountChargesPaidByData> chargesPaidBy = 
transaction.getSavingsAccountChargesPaid();
                           final Set<SavingsAccountChargesPaidByData> 
newChargePaidBy = new HashSet<>();
                           chargesPaidBy.forEach(chargePaidBy -> newChargePaidBy
                                   
.add(SavingsAccountChargesPaidByData.instance(chargePaidBy.getChargeId(), 
chargePaidBy.getAmount())));
                           
transaction.getSavingsAccountChargesPaid().addAll(newChargePaidBy);
                       }
   ```
   ```
   if (overdraftAmount.isGreaterThanZero()) {
                           
transaction.updateOverdraftAmount(overdraftAmount.getAmount());
                       }
                       transaction.updateRunningBalance(runningBalance);
   ```
   
   The above piece of codes letter to letter duplications...
   
   Please extract the content of each IF and ELSE into a private method and 
leave a short 1 sentence description what it does!



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