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


##########
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:
   The method has been refactored to remove redundant else cases and improve 
readability.



##########
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 here — the logic has been refactored and simplified for better 
readability



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