Repository navigation
FINERACT-3149: Split transaction methods into LoanTransactionWritePlatformService - #6846
Bhavya-Sonigra wants to merge 6 commits into
Conversation
galovics
left a comment
There was a problem hiding this comment.
Hi @Bhavya-Sonigra, thanks for the PR, splitting this class has been overdue for a long time.
I diffed the moved methods against develop and they are a faithful move (only blank lines and one dead commented-out line dropped), and the @Transactional annotations came along too. Nice. A couple of things though.
The bigger question for me is the delegation layer. Right now LoanWritePlatformService still declares all 13 methods and LoanWritePlatformServiceJpaRepositoryImpl just forwards them, so the interface stays as big as before. Is the plan to point the command handlers at LoanTransactionWritePlatformService directly in a follow-up and then remove these from LoanWritePlatformService? I'm fine with doing it in 2 steps, but if that's the plan, please make it part of the ticket so the forwarding methods don't stay forever. Thoughts?
CI never ran on this PR, so I can't approve yet. Once the workflows are approved and green I'm happy to go ahead.
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionWritePlatformServiceImpl.java:966
+ private void checkClientOrGroupActive(final Loan loan) {
+ final Client client = loan.client();
+ if (client != null && client.isNotActive()) {
+ throw new ClientNotActiveException(client.getId());
+ }This is a 1:1 copy of
LoanUtilService.checkClientOrGroupActive, and you already injectloanUtilServicehere. Can we just call that one instead of adding yet another copy?Same goes for
createNoteandsaveAndFlushLoanWithDataIntegrityViolationChecks, they now exist in both classes byte-for-byte. I'd rather not double the copy paste while we're splitting the class to reduce maintenance cost. What do you think?
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:2385
+ public void handleChargebackTransaction(final Loan loan, LoanTransaction chargebackTransaction) {
+ this.loanTransactionWritePlatformService.handleChargebackTransaction(loan, chargebackTransaction);
+ }This one isn't on
LoanWritePlatformServiceand after the move nobody calls it anymore (the only caller waschargebackLoanTransaction, which moved too). Let's get rid of it, together with its delegation test.
Thanks.
|
Hi @galovics, Thank you for the thorough review and constructive feedback! All points have been addressed in the latest update:
Could you please approve and trigger the GitHub Actions workflow when you have a moment? Thanks! |
galovics
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround @Bhavya-Sonigra. CI is green now, the duplicated checkClientOrGroupActive / createNote copies are gone and handleChargebackTransaction is cleaned up, nice. The 2-step plan works for me, please link the follow-up ticket here once it exists so we don't forget about the forwarding methods.
One thing I'm not comfortable with though, see below. The rest is fine.
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccountServiceImpl.java:56
public Loan saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
try {
+ loanRepaymentScheduleInstallmentRepository.saveAll(loan.getRepaymentScheduleInstallments());
return this.loanRepositoryWrapper.saveAndFlush(loan);Hmm, this isn't a refactor anymore.
LoanAccountService.saveAndFlushLoanWithDataIntegrityViolationChecksis shared, it's called fromLoanAccountDomainServiceJpa(so every repayment),LoanChargeWritePlatformServiceImpl,LoanRescheduleRequestWritePlatformServiceImplandLoanAdjustmentServiceImpltoo. With this line all of those now do an extrasaveAllon every installment of the loan, which they didn't do before. Plus the bean is@ConditionalOnMissingBean, so anybody providing their ownLoanAccountServicesilently loses the EclipseLink workaround that the 2 write services relied on. And the comment explaining why the workaround is there got dropped on the way.I'd rather keep the other callers untouched in this PR. Either keep a single private copy of the old method in one place (e.g. next to the 2 write services) or add a separate, explicitly named method on
LoanAccountServicefor the "save installments first" variant, and carry the EclipseLink comment over. If you really want to unify the behaviour for all callers, that's fine, but let's do it in a separate PR with its own ticket. Thoughts?
Thanks.
…ntegrityViolationChecks to leave existing callers untouched
|
Hi @galovics, Thanks for catching that! Modifying the existing shared method indeed had unintended side-effects on all other callers across the codebase. I have updated the PR following your suggestion:
All unit tests, Spotless, RAT, and Checkstyle are passing locally. Could you please take another look and trigger the workflows when you have a moment? Thanks! |
Description
Overview
LoanWritePlatformServiceJpaRepositoryImplmonolith (~3,700 lines).LoanWritePlatformServiceJpaRepositoryImplvia direct delegation, guaranteeing complete backward compatibility for all existing callers.Summary of Changes
fineract-loan/LoanTransactionWritePlatformService.javamakeLoanRepayment,adjustLoanTransaction,chargebackLoanTransaction, etc.).fineract-provider/LoanTransactionWritePlatformServiceImpl.javafineract-provider/LoanWritePlatformServiceJpaRepositoryImpl.javaLoanTransactionWritePlatformService, delegates transaction calls, removes 6 obsolete dependencies, and reduces class size by >800 lines.fineract-provider/LoanAccountConfiguration.javaLoanTransactionWritePlatformServiceSpring bean definition.fineract-provider/*Test.javaLoanTransactionWritePlatformServiceImplTestand 13 delegation tests inLoanWritePlatformServiceJpaRepositoryImplTest.Extracted Transaction Methods (13)
makeGLIMLoanRepaymentmakeLoanRepaymentmakeLoanRepaymentWithChargeRefundChargeTypemakeInterestPaymentWaiveradjustLoanTransactionchargebackLoanTransactionwaiveInterestOnLoanrecoverFromGuarantorcreditBalanceRefundmakeLoanRefundmakeRefundmakeManualInterestRefundhandleChargebackTransaction(Associated internal helper routines migrated:
recalculateLoanWithInterestPaymentWaiverTxn,reprocessChangedLoanTransactions,saveNote,validateLoanTransactionAmountChargeBack,waiveInterest,checkIfLoanIsPaidInAdvance,saveAndFlushLoanWithDataIntegrityViolationChecks,checkClientOrGroupActive,createNote).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.