AshharAhmadKhan opened a new pull request, #6390: URL: https://github.com/apache/fineract/pull/6390
Description SavingsAccountAssembler.loadTransactionsToSavingsAccount(), the method that loads a savings account's transactions before any write action (deposit, withdrawal, and so on), calls savingsAccountTransactions.get(0).getSavingsAccount().setStartInterestCalculationDate(...) with no check that the list returned by findTransactionsAfterPivotDate() is non-empty. This code path only runs when the relaxing days pivot date config (allow-backdated-transaction-before-interest-posting-date-for-days) is enabled. If an account has zero transactions after the relaxed pivot date window, for example a dormant account or one where every transaction falls before the window, this throws IndexOutOfBoundsException on every write action that assembles the account, including a plain deposit. The running balance update logic in this method was refactored in 2022 to move the running balance calculation out of a block further down in the same method, one that was already properly guarded with savingsAccountTransactions != null && !savingsAccountTransactions.isEmpty(). That refactor introduced the new, unguarded get(0) access a few lines above the existing guarded block, and the guard was never carried over to the new access point. Changes Added SavingsAccountAssemblerTest.java to fineract-provider, covering: loadTransactionsToSavingsAccountWithNoTransactionsAfterPivotDateDoesNotThrow(): confirms loadTransactionsToSavingsAccount() no longer throws when the relaxing days config is enabled and findTransactionsAfterPivotDate() returns no transactions after the pivot date. SavingsAccountAssembler.loadTransactionsToSavingsAccount() now wraps the savingsAccountTransactions.get(0) access in the same null and empty check already used later in the method, so the method falls through safely when there are no transactions in the relaxed pivot window. Verified locally end to end See https://issues.apache.org/jira/browse/FINERACT-2804 -- 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]
