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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountInterestPostingServiceImpl.java:
##########
@@ -297,6 +350,54 @@ public List<PostingPeriod> calculateInterestUsing(final 
MathContext mc, final Lo
         return allPostingPeriods;
     }
 
+    private List<SavingsAccountTransactionData> listForOverdraft(final 
SavingsAccountData savingsAccountData,
+            final LocalDateInterval periodInterval) {
+        List<SavingsAccountTransactionData> overdraftTransactionsInPeriod = 
new ArrayList<>();
+        for (SavingsAccountTransactionData lists : 
retreiveOrderedNonInterestPostingTransactions(savingsAccountData)) {
+            if (MathUtil.isLessThanZero(lists.getRunningBalance()) && 
periodInterval.startDate().getMonth() == lists.getDate().getMonth()) {
+                overdraftTransactionsInPeriod.add(lists);
+
+            }
+        }
+        return overdraftTransactionsInPeriod;
+
+    }
+
+    private List<SavingsAccountTransactionData> listForInterestPosting(final 
SavingsAccountData savingsAccountData,
+            final LocalDateInterval periodInterval) {
+        List<SavingsAccountTransactionData> listOfTransactionsIsNotOverdraft = 
new ArrayList<>();
+        for (SavingsAccountTransactionData lists : 
retreiveOrderedNonInterestPostingTransactions(savingsAccountData)) {
+            if (MathUtil.isGreaterThanZero(lists.getRunningBalance())
+                    && periodInterval.startDate().getMonth() == 
lists.getDate().getMonth()) {
+                BigDecimal bd = new 
BigDecimal(String.valueOf(lists.getRunningBalance())).setScale(2, 
RoundingMode.DOWN);
+                if (!MathUtil.isZero(bd)) {
+                    listOfTransactionsIsNotOverdraft.add(lists);
+
+                }
+            }
+        }
+        return listOfTransactionsIsNotOverdraft;
+
+    }
+
+    private Boolean isOverdraftAccount(final SavingsAccountData 
savingsAccountData, final LocalDateInterval periodInterval) {
+        Boolean isOverdraftAccountBalance = false;
+        for (SavingsAccountTransactionData lists : 
retreiveOrderedNonInterestPostingTransactions(savingsAccountData)) {
+            if (MathUtil.isLessThanZero(lists.getRunningBalance()) && 
periodInterval.startDate().getMonth() == lists.getDate().getMonth()) {
+                isOverdraftAccountBalance = true;

Review Comment:
   I removed the break statements and rewrote the method to return early when 
the condition is met. This way the logic remains the same (exit at the first 
matching transaction), but without using break.



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