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 2022/06/20 08:51:00 UTC

[GitHub] [fineract] logoutdhaval opened a new pull request, #2372: FINERACT-1642: Bulk reversal of related Transactions

logoutdhaval opened a new pull request, #2372:
URL: https://github.com/apache/fineract/pull/2372

   ## Description
   [FINERACT-1642](https://issues.apache.org/jira/browse/FINERACT-1642).
   
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [x] Write the commit message as per https://github.com/apache/fineract/#pull-requests
   
   - [x] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
   
   - [x] Create/update unit or integration tests for verifying the changes made.
   
   - [x] Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
   
   - [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
   
   - [x] Submission is not a "code dump".  (Large changes can be made "in repository" via a branch.  Ask on the developer mailing list for guidance, if required.)
   
   FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
   


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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2372:
URL: https://github.com/apache/fineract/pull/2372#discussion_r905016289


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java:
##########
@@ -309,29 +314,31 @@ public SavingsAccountTransaction handleReversal(SavingsAccount account, SavingsA
         } else {
             updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
         }
-
-        SavingsAccountTransaction reversal = SavingsAccountTransaction.reversal(savingsAccountTransaction);
-        reversal.getSavingsAccountChargesPaid().addAll(chargePaidBySet);
-        account.undoTransaction(savingsAccountTransaction);
+        List<SavingsAccountTransaction> newTransactions = new ArrayList<>();
+        SavingsAccountTransaction reversal = null;
+        for (SavingsAccountTransaction savingsAccountTransaction : savingsAccountTransactions) {
+            reversal = SavingsAccountTransaction.reversal(savingsAccountTransaction);
+            reversal.getSavingsAccountChargesPaid().addAll(chargePaidBySet);
+            account.undoTransaction(savingsAccountTransaction);
+            newTransactions.add(reversal);
+        }
 
         boolean isInterestTransfer = false;
         LocalDate postInterestOnDate = null;
         final LocalDate today = DateUtils.getLocalDateOfTenant();
         final MathContext mc = new MathContext(15, MoneyHelper.getRoundingMode());
 
-        if (savingsAccountTransaction.isPostInterestCalculationRequired()
-                && account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate(), backdatedTxnsAllowedTill)) {
+        if (savingsAccountTransactions.get(0).isPostInterestCalculationRequired()
+                && account.isBeforeLastPostingPeriod(savingsAccountTransactions.get(0).transactionLocalDate(), backdatedTxnsAllowedTill)) {
+            boolean postReversals = true;
             account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth,
-                    postInterestOnDate, backdatedTxnsAllowedTill);
+                    postInterestOnDate, backdatedTxnsAllowedTill, postReversals);
         } else {
             account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
                     financialYearBeginningMonth, postInterestOnDate, backdatedTxnsAllowedTill);
         }
 
-        List<SavingsAccountTransaction> newTransactions = new ArrayList<>();
-        newTransactions.add(reversal);
-
-        account.validateAccountBalanceDoesNotBecomeNegativeMinimal(savingsAccountTransaction.getAmount(), false);
+        account.validateAccountBalanceDoesNotBecomeNegativeMinimal(savingsAccountTransactions.get(0).getAmount(), false);

Review Comment:
   order is not guaranteed...



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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2372:
URL: https://github.com/apache/fineract/pull/2372#discussion_r903712004


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java:
##########
@@ -292,15 +296,16 @@ private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity enti
     }
 
     @Override
-    public SavingsAccountTransaction handleReversal(SavingsAccount account, SavingsAccountTransaction savingsAccountTransaction,
+    public SavingsAccountTransaction handleReversal(SavingsAccount account, List<SavingsAccountTransaction> savingsAccountTransactions,
             boolean backdatedTxnsAllowedTill) {
 
         final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
                 .isSavingsInterestPostingAtCurrentPeriodEnd();
         final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
-
-        final Set<SavingsAccountChargePaidBy> chargePaidBySet = savingsAccountTransaction.getSavingsAccountChargesPaid();
-
+        Set<SavingsAccountChargePaidBy> chargePaidBySet = null;
+        for (SavingsAccountTransaction savingsAccountTransaction : savingsAccountTransactions) {
+            chargePaidBySet = savingsAccountTransaction.getSavingsAccountChargesPaid();

Review Comment:
   This one looks  faulty. Overriding the set each  iteration.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java:
##########
@@ -292,15 +296,16 @@ private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity enti
     }
 
     @Override
-    public SavingsAccountTransaction handleReversal(SavingsAccount account, SavingsAccountTransaction savingsAccountTransaction,
+    public SavingsAccountTransaction handleReversal(SavingsAccount account, List<SavingsAccountTransaction> savingsAccountTransactions,
             boolean backdatedTxnsAllowedTill) {
 
         final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
                 .isSavingsInterestPostingAtCurrentPeriodEnd();
         final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
-
-        final Set<SavingsAccountChargePaidBy> chargePaidBySet = savingsAccountTransaction.getSavingsAccountChargesPaid();
-
+        Set<SavingsAccountChargePaidBy> chargePaidBySet = null;
+        for (SavingsAccountTransaction savingsAccountTransaction : savingsAccountTransactions) {
+            chargePaidBySet = savingsAccountTransaction.getSavingsAccountChargesPaid();

Review Comment:
   This one looks  faulty. Overriding the set in each  iteration.



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


[GitHub] [fineract] logoutdhaval commented on pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
logoutdhaval commented on PR #2372:
URL: https://github.com/apache/fineract/pull/2372#issuecomment-1165510355

   > fynmanoj
   
   done


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


[GitHub] [fineract] logoutdhaval commented on pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
logoutdhaval commented on PR #2372:
URL: https://github.com/apache/fineract/pull/2372#issuecomment-1165474388

   > the
   
   


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


[GitHub] [fineract] logoutdhaval closed pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
logoutdhaval closed pull request #2372: FINERACT-1642: Bulk reversal of related Transactions
URL: https://github.com/apache/fineract/pull/2372


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


[GitHub] [fineract] fynmanoj merged pull request #2372: FINERACT-1642: Bulk reversal of related Transactions

Posted by GitBox <gi...@apache.org>.
fynmanoj merged PR #2372:
URL: https://github.com/apache/fineract/pull/2372


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