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


##########
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;
+                break;
+            } else if (periodInterval.startDate().getMonth() == 
lists.getDate().getMonth()) {
+                BigDecimal bd = new 
BigDecimal(String.valueOf(lists.getRunningBalance())).setScale(2, 
RoundingMode.DOWN);

Review Comment:
   Replaced the hardcoded BigDecimal rounding with Money based on the account’s 
MonetaryCurrency to ensure consistent precision and rounding.



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