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-unsubscr...@fineract.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org