Skip to content

FINERACT-3148: Extract loan disbursement operations from LoanWritePlatformServiceJpaRepositoryImpl - #6860

Open
SamarthPD-21 wants to merge 2 commits into
apache:developfrom
SamarthPD-21:FINERACT-3148-split-disbursement
Open

SamarthPD-21 wants to merge 2 commits into
apache:developfrom
SamarthPD-21:FINERACT-3148-split-disbursement

Conversation

@SamarthPD-21

Copy link
Copy Markdown

Description

https://issues.apache.org/jira/browse/FINERACT-3148

LoanWritePlatformServiceJpaRepositoryImpl goes from 3,739 to about 2,300 lines.

  • New LoanDisbursementWritePlatformService / Impl with the disbursement operations listed in the ticket, plus bulkLoanDisbursal, since it calls disburseLoan.
  • The old class still implements LoanWritePlatformService and delegates these methods, so the command handlers don't change.
  • 15 private helpers used by both the disbursement methods and the remaining operations are moved to LoanWriteServiceHelper, so they aren't duplicated. If you'd prefer a different split for these, I'm happy to change it.
  • Method bodies are moved without changes. The only new code is the delegating methods and the bean wiring in LoanAccountConfiguration.
  • Dependencies the old class no longer uses are removed from its constructor, including errorHandler, which was already unused.
  • The 11 disbursement unit tests move to LoanDisbursementWritePlatformServiceImplTest, unchanged apart from the object they call.

Tested locally: compile, spotless and checkstyle for fineract-provider; LoanWritePlatformServiceJpaRepositoryImplTest and LoanDisbursementWritePlatformServiceImplTest (17/17 pass). I'm relying on CI for the integration tests.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • 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.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our 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
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.
  • If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately.
  • I followed the AI Policy.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@SamarthPD-21
SamarthPD-21 force-pushed the FINERACT-3148-split-disbursement branch 6 times, most recently from e99ad81 to 92b4231 Compare November 10, 2026 18:43
…tformServiceJpaRepositoryImpl

Move the disbursement operations (disburseLoan, disburseGLIMLoan,
bulkLoanDisbursal, undoLoanDisbursal, undoGLIMLoanDisbursal,
undoLastLoanDisbursal, addAndDeleteLoanDisburseDetails,
updateDisbursementDateAndAmountForTranche and
updateLoanToPreDisbursalState) with their private helpers into
LoanDisbursementWritePlatformServiceImpl. LoanWritePlatformServiceJpaRepositoryImpl
keeps the LoanWritePlatformService methods and delegates them, so
callers are unchanged.

Helpers used by both services (loan counters, notes, schedule archive,
saveAndFlushLoanWithDataIntegrityViolationChecks, ...) are moved to
LoanWriteServiceHelper. Method bodies are moved as is.

The disbursement unit tests move to LoanDisbursementWritePlatformServiceImplTest.
@SamarthPD-21
SamarthPD-21 force-pushed the FINERACT-3148-split-disbursement branch from 92b4231 to 399f052 Compare November 10, 2026 18:45
galovics
galovics previously approved these changes Nov 11, 2026

@galovics galovics left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SamarthPD-21, thanks for the PR, nice work. I checked the move and the bodies really are unchanged, the @Transactional annotations all came along (36 before, 28 + 8 now), and the delegates are fine since the target methods are transactional. A few minor things on LoanWriteServiceHelper below, none of them should block the merge.

fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWriteServiceHelper.java:63

+    private final LoanAccountDomainService loanAccountDomainService;

Not used, the only mention is in the comment inside saveAndFlushLoanWithDataIntegrityViolationChecks. Let's get rid of it, the bean definition in LoanAccountConfiguration too.

fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWriteServiceHelper.java:157

+    public Integer getNewGroupLoanCounter(final Loan loan) {

getNewGroupLoanCounter, getNewGroupLoanProductCounter, updateLoanCounter, getNewClientOrJLGLoanCounter, getNewClientOrJLGLoanProductCounter, updateLoanCycleCounter and retrieveRepaymentScheduleFromModel are only called from inside this class. Can we keep them private? Then the public surface is only what the 2 services actually use.

You asked about the split, so here's my 2 cents. A class called ...Helper usually turns into the next dumping ground. The loan counter logic (updateLoanCounters, removeLoanCycle and their private friends) is a coherent piece by itself and could be its own service later. Also #6846 (FINERACT-3149) is extracting the transaction operations from the same class at the same time, and it moves createNote into LoanUtilService. Whichever PR lands second should reuse the other's home for the shared helpers instead of ending up with 2 copies. Not blocking this one, just something to sort out between the two. Thoughts?

Remove the unused LoanAccountDomainService dependency and make the
helper methods that are only used inside the class private.

Signed-off-by: Samarth Deshpande <samarthpd21@gmail.com>
@SamarthPD-21

Copy link
Copy Markdown
Author

Thanks @galovics ! Both done: I removed the unused LoanAccountDomainService (from the helper and its bean) and made the 7 internal methods private.

Agreed on the Helper name. I'd be happy to pull the loan counter logic (updateLoanCounters, removeLoanCycle and the private methods they use) into its own service as a follow-up, maybe together with FINERACT-3150, since that touches the same class. And with #6846: whichever lands second should reuse the other's home for createNote. If this one goes in first, I'm happy to help line them up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants