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


##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java:
##########
@@ -157,6 +162,44 @@ private List<SavingsAccountTransactionData> 
fetchTransactionsFromIds(final List<
         return 
this.savingsAccountReadPlatformService.retrieveAllTransactionData(refNo);
     }
 
+    private Long validateAccountForCreditAllowOverdraft(Boolean 
allowOverdraft, Boolean isOverdraftDown,
+            SavingsAccountData savingsAccountData, 
SavingsAccountTransactionData savingsAccountTransactionData) {
+        Long accountId = null;
+        if (allowOverdraft) {
+            if 
(!MathUtil.isZero(savingsAccountData.getGlAccountIdForInterestReceivable())) {
+                accountId = isOverdraftDown
+                        ? 
MathUtil.isLessThanZero(savingsAccountTransactionData.getRunningBalance())
+                                ? 
savingsAccountData.getGlAccountIdForInterestReceivable()
+                                : 
savingsAccountData.getGlAccountIdForInterestReceivable()
+                        : savingsAccountData.getGlAccountIdForSavingsControl();
+            } else {
+                accountId = 
savingsAccountData.getGlAccountIdForSavingsControl();

Review Comment:
   Would you mind to rework this? Readability is not too great and having 
"multiple" else case which sets the same usually means it can be reworked and 
simplified 



##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java:
##########
@@ -157,6 +162,44 @@ private List<SavingsAccountTransactionData> 
fetchTransactionsFromIds(final List<
         return 
this.savingsAccountReadPlatformService.retrieveAllTransactionData(refNo);
     }
 
+    private Long validateAccountForCreditAllowOverdraft(Boolean 
allowOverdraft, Boolean isOverdraftDown,
+            SavingsAccountData savingsAccountData, 
SavingsAccountTransactionData savingsAccountTransactionData) {
+        Long accountId = null;
+        if (allowOverdraft) {
+            if 
(!MathUtil.isZero(savingsAccountData.getGlAccountIdForInterestReceivable())) {
+                accountId = isOverdraftDown
+                        ? 
MathUtil.isLessThanZero(savingsAccountTransactionData.getRunningBalance())
+                                ? 
savingsAccountData.getGlAccountIdForInterestReceivable()
+                                : 
savingsAccountData.getGlAccountIdForInterestReceivable()
+                        : savingsAccountData.getGlAccountIdForSavingsControl();
+            } else {
+                accountId = 
savingsAccountData.getGlAccountIdForSavingsControl();
+            }
+        } else {
+            accountId = savingsAccountData.getGlAccountIdForSavingsControl();
+        }
+        return accountId;
+    }
+
+    private Long validateAccountForDebitAllowOverdraft(Boolean allowOverdraft, 
Boolean isOverdraftDown,

Review Comment:
   same as above



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