mariiaKraievska commented on code in PR #4800:
URL: https://github.com/apache/fineract/pull/4800#discussion_r2189854089
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeService.java:
##########
@@ -575,49 +608,67 @@ private BigDecimal
calculatePerInstallmentChargeAmount(final Loan loan, final Lo
}
private void updateInstallmentCharges(final LoanCharge loanCharge) {
- final Collection<LoanInstallmentCharge> remove = new HashSet<>();
+ for (LoanInstallmentCharge oldCharge :
loanCharge.getLoanInstallmentCharge()) {
+
oldCharge.getInstallment().getInstallmentCharges().remove(oldCharge);
+ }
+ loanCharge.getLoanInstallmentCharge().clear();
Review Comment:
Thank you for your question!
After reverting to the previous logic, I encountered a database integrity
error during testing (specifically on charge-off with accelerate maturity date
behaviour), caused by a foreign key constraint violation between
m_loan_installment_charge and m_loan_repayment_schedule.
It seems that the old approach does not always properly remove or update all
related installment charges before the repayment schedule is changed, which
leads to this issue.
That’s why the logic to clear and recreate all charges was introduced — to
ensure data consistency and avoid such integrity problems.
--
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]