You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2021/10/30 06:08:19 UTC

[GitHub] [fineract] rrpawar96 commented on a change in pull request #1940: FINERACT-1374: Withdraw-charge-discount

rrpawar96 commented on a change in pull request #1940:
URL: https://github.com/apache/fineract/pull/1940#discussion_r739614585



##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
##########
@@ -1066,15 +1070,98 @@ public BigDecimal calculateWithdrawalFee(final BigDecimal transactionAmount) {
         return result;
     }
 
-    private void payWithdrawalFee(final BigDecimal transactionAmount, final LocalDate transactionDate, final AppUser user) {
+    private void payWithdrawalFee(final BigDecimal transactionAmount, final LocalDate transactionDate, final AppUser user,
+            final PaymentDetail paymentDetail) {
+
         for (SavingsAccountCharge charge : this.charges()) {
+
             if (charge.isWithdrawalFee() && charge.isActive()) {
-                charge.updateWithdralFeeAmount(transactionAmount);
-                this.payCharge(charge, charge.getAmountOutstanding(this.getCurrency()), transactionDate, user);
+                if (charge.getFreeWithdrawalCount() == null) {
+                    charge.setFreeWithdrawalCount(0);
+                }
+
+                if (charge.isEnableFreeWithdrawal()) {
+                    resetFreeChargeDaysCount(charge, transactionAmount, transactionDate, user);
+
+                }
+            }
+
+        }
+    }
+
+    private void resetFreeChargeDaysCount(SavingsAccountCharge charge, final BigDecimal transactionAmount, final LocalDate transactionDate,
+            final AppUser user) {
+        Date resetDate = charge.getResetChargeDate();
+
+        Integer restartPeriod = charge.getRestartFrequency();

Review comment:
       The logic of the PR is to compare the interval between the current period and the lastdate or Month when it was got reset.
   (but if the lastdate is null such that it is first-time is getting reset then it will set the current date as resetdate)
   then it will do the addition of monthvalue of lastresetdate and restartPeriod(which will be taken from the user, like after which month it should reset) 
   
   if that calculated period exceeds the gap between the currentMonth and lastResetMonth then it will reset it.
   
   till than period it will also make sure that it will keep a count (+1) how many times the withdrawal transaction was done free, if that count exceeds with the freeWithdrawalCount which is given by user then it will start taking charges until the restartPeriod gets reset as explained above. 
   
   Once it gets reset then it will start the count from 0 until it reaches to the frequency of freeWithdrawalCount given by user.
   




-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org