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

   Description:
   
   JournalEntryWritePlatformServiceImpl.revertJournalEntry(List<JournalEntry>, 
String) calls journalEntries.get(0).getOffice().getId() with no check that the 
list is non-empty. This overload is called from two places: the public API 
entry point revertJournalEntry(JsonCommand), which validates the list is 
non-empty before calling it, and defineOpeningBalance(JsonCommand), which does 
not. For each transaction ID returned by findNonReversedContraTransactionIds(), 
defineOpeningBalance() fetches journal entries via the narrower 
findUnReversedManualJournalEntriesByTransactionId() query and passes the result 
straight into revertJournalEntry() with no guard. If a contra transaction has 
no unreversed manual journal entries (for example, if it was system-generated 
rather than manually posted), this query returns an empty list and the method 
throws IndexOutOfBoundsException, blocking the entire opening-balance 
definition workflow.
   
   The guard pattern already exists elsewhere in the same file — 
revertShareAccountJournalEntries() checks for a null or empty list before an 
equivalent access — but was never applied to this call site.
   
   Changes
   
   Added JournalEntryWritePlatformServiceImplTest.java, covering:
   
   revertJournalEntryWithEmptyListDoesNotThrow(): confirms revertJournalEntry() 
no longer throws when called with an empty list.
   
   JournalEntryWritePlatformServiceImpl.revertJournalEntry(List<JournalEntry>, 
String) now returns early when the list is null or empty, mirroring the guard 
already used elsewhere in the file.
   
   Verified locally end to end
   
   See https://issues.apache.org/jira/browse/FINERACT-2806


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