Repository navigation
FINERACT-3148: Extract loan disbursement operations from LoanWritePlatformServiceJpaRepositoryImpl - #6860
FINERACT-3148: Extract loan disbursement operations from LoanWritePlatformServiceJpaRepositoryImpl#6860SamarthPD-21 wants to merge 2 commits into
Conversation
e99ad81 to
92b4231
Compare
…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.
92b4231 to
399f052
Compare
galovics
left a comment
There was a problem hiding this comment.
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 inLoanAccountConfigurationtoo.
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,updateLoanCycleCounterandretrieveRepaymentScheduleFromModelare 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
...Helperusually turns into the next dumping ground. The loan counter logic (updateLoanCounters,removeLoanCycleand 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 movescreateNoteintoLoanUtilService. 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>
|
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. |
Description
https://issues.apache.org/jira/browse/FINERACT-3148
LoanWritePlatformServiceJpaRepositoryImpl goes from 3,739 to about 2,300 lines.
LoanDisbursementWritePlatformService/Implwith the disbursement operations listed in the ticket, plusbulkLoanDisbursal, since it callsdisburseLoan.LoanWritePlatformServiceand delegates these methods, so the command handlers don't change.LoanWriteServiceHelper, so they aren't duplicated. If you'd prefer a different split for these, I'm happy to change it.LoanAccountConfiguration.errorHandler, which was already unused.LoanDisbursementWritePlatformServiceImplTest, unchanged apart from the object they call.Tested locally: compile, spotless and checkstyle for fineract-provider;
LoanWritePlatformServiceJpaRepositoryImplTestandLoanDisbursementWritePlatformServiceImplTest(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!
Your assigned reviewer(s) will follow our guidelines for code reviews.