You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "mariiaKraievska (via GitHub)" <gi...@apache.org> on 2025/02/19 12:41:19 UTC
[PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
mariiaKraievska opened a new pull request, #4350:
URL: https://github.com/apache/fineract/pull/4350
## Description
Accrual handling in case of Charged-off loan
## Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Write the commit message as per https://github.com/apache/fineract/#pull-requests
- [ ] 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 coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/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
- [ ] Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "mariiaKraievska (via GitHub)" <gi...@apache.org>.
mariiaKraievska commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1967338431
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3092,6 +3098,15 @@ public CommandProcessingResult chargeOff(JsonCommand command) {
final List<Long> existingTransactionIds = loan.findExistingTransactionIds();
final List<Long> existingReversedTransactionIds = loan.findExistingReversedTransactionIds();
+ final LoanChargeOffBehaviour chargeOffBehaviour = loan.getLoanProductRelatedDetail().getChargeOffBehaviour();
+ if (loan.isProgressiveSchedule()) {
Review Comment:
Done
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1961670285
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3092,6 +3098,15 @@ public CommandProcessingResult chargeOff(JsonCommand command) {
final List<Long> existingTransactionIds = loan.findExistingTransactionIds();
final List<Long> existingReversedTransactionIds = loan.findExistingReversedTransactionIds();
+ final LoanChargeOffBehaviour chargeOffBehaviour = loan.getLoanProductRelatedDetail().getChargeOffBehaviour();
Review Comment:
I think it would be better to handle inside the Transaction processor as we need similar logic in case a reverse-replay occurs and we need to create additional Accrual or Accrual adjustment as a side effect. What do you think?
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1961676303
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3092,6 +3098,15 @@ public CommandProcessingResult chargeOff(JsonCommand command) {
final List<Long> existingTransactionIds = loan.findExistingTransactionIds();
final List<Long> existingReversedTransactionIds = loan.findExistingReversedTransactionIds();
+ final LoanChargeOffBehaviour chargeOffBehaviour = loan.getLoanProductRelatedDetail().getChargeOffBehaviour();
+ if (loan.isProgressiveSchedule()) {
Review Comment:
This should not be created only for progressive loans... We can create the missing accrual for cumulative loans as well...
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "mariiaKraievska (via GitHub)" <gi...@apache.org>.
mariiaKraievska commented on PR #4350:
URL: https://github.com/apache/fineract/pull/4350#issuecomment-2682319048
Please, consider this PR as a **draft**, because there are no tests from qa yet.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #4350:
URL: https://github.com/apache/fineract/pull/4350
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1961674565
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3745,4 +3760,39 @@ public void closeAsMarkedForReschedule(final Loan loan, final JsonCommand comman
loanTransactionValidator.validateLoanRescheduleDate(loan);
}
+
+ private void createMissingAccrualTransactionIfNeeded(final BigDecimal newInterest, final Loan loan, final LocalDate chargeOffDate) {
+ final LoanRepaymentScheduleInstallment installment = loan.getRepaymentScheduleInstallments().stream()
+ .filter(i -> !i.getFromDate().isAfter(chargeOffDate) && i.getDueDate().isAfter(chargeOffDate)).findFirst().orElse(null);
+
+ if (installment == null) {
+ return;
+ }
+
+ final BigDecimal sumOfAccrualsOnCurrentPeriod = loan.getLoanTransactions().stream()
+ .filter(lt -> lt.isAccrual() && !lt.getTransactionDate().isBefore(installment.getFromDate())
+ && lt.getTransactionDate().isBefore(installment.getDueDate()))
+ .map(LoanTransaction::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ final BigDecimal missingAccrualAmount = newInterest.subtract(sumOfAccrualsOnCurrentPeriod);
+
+ if (missingAccrualAmount.compareTo(BigDecimal.ZERO) > 0) {
+ final LoanTransaction newAccrualTransaction = accrueTransaction(loan, loan.getOffice(), chargeOffDate, missingAccrualAmount,
+ missingAccrualAmount, ZERO, ZERO, externalIdFactory.create());
+ loan.addLoanTransaction(newAccrualTransaction);
+ }
+ }
+
+ private BigDecimal getInterestTillChargeOffForPeriod(final Loan loan, final LocalDate chargeOffDate) {
Review Comment:
This seems not correct for progressive loans...
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "mariiaKraievska (via GitHub)" <gi...@apache.org>.
mariiaKraievska commented on PR #4350:
URL: https://github.com/apache/fineract/pull/4350#issuecomment-2677978640
PTAL
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1961670285
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3092,6 +3098,15 @@ public CommandProcessingResult chargeOff(JsonCommand command) {
final List<Long> existingTransactionIds = loan.findExistingTransactionIds();
final List<Long> existingReversedTransactionIds = loan.findExistingReversedTransactionIds();
+ final LoanChargeOffBehaviour chargeOffBehaviour = loan.getLoanProductRelatedDetail().getChargeOffBehaviour();
Review Comment:
I think it would be better to handle inside the Transaction processor as we need similar logic in case a reverse-replay occurs and we need to create additional Accrual or Accrual adjustment as a side effect. What do you think?
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1961674910
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3745,4 +3760,39 @@ public void closeAsMarkedForReschedule(final Loan loan, final JsonCommand comman
loanTransactionValidator.validateLoanRescheduleDate(loan);
}
+
+ private void createMissingAccrualTransactionIfNeeded(final BigDecimal newInterest, final Loan loan, final LocalDate chargeOffDate) {
Review Comment:
Would it make sense to move this into the LoanAccrualProcessingService?
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "mariiaKraievska (via GitHub)" <gi...@apache.org>.
mariiaKraievska commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1967338040
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3745,4 +3760,39 @@ public void closeAsMarkedForReschedule(final Loan loan, final JsonCommand comman
loanTransactionValidator.validateLoanRescheduleDate(loan);
}
+
+ private void createMissingAccrualTransactionIfNeeded(final BigDecimal newInterest, final Loan loan, final LocalDate chargeOffDate) {
+ final LoanRepaymentScheduleInstallment installment = loan.getRepaymentScheduleInstallments().stream()
+ .filter(i -> !i.getFromDate().isAfter(chargeOffDate) && i.getDueDate().isAfter(chargeOffDate)).findFirst().orElse(null);
+
+ if (installment == null) {
+ return;
+ }
+
+ final BigDecimal sumOfAccrualsOnCurrentPeriod = loan.getLoanTransactions().stream()
+ .filter(lt -> lt.isAccrual() && !lt.getTransactionDate().isBefore(installment.getFromDate())
+ && lt.getTransactionDate().isBefore(installment.getDueDate()))
+ .map(LoanTransaction::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ final BigDecimal missingAccrualAmount = newInterest.subtract(sumOfAccrualsOnCurrentPeriod);
+
+ if (missingAccrualAmount.compareTo(BigDecimal.ZERO) > 0) {
+ final LoanTransaction newAccrualTransaction = accrueTransaction(loan, loan.getOffice(), chargeOffDate, missingAccrualAmount,
+ missingAccrualAmount, ZERO, ZERO, externalIdFactory.create());
+ loan.addLoanTransaction(newAccrualTransaction);
+ }
+ }
+
+ private BigDecimal getInterestTillChargeOffForPeriod(final Loan loan, final LocalDate chargeOffDate) {
Review Comment:
Done
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2333: Accrual handling in case of Charged-off loan [fineract]
Posted by "mariiaKraievska (via GitHub)" <gi...@apache.org>.
mariiaKraievska commented on code in PR #4350:
URL: https://github.com/apache/fineract/pull/4350#discussion_r1967354473
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3745,4 +3760,39 @@ public void closeAsMarkedForReschedule(final Loan loan, final JsonCommand comman
loanTransactionValidator.validateLoanRescheduleDate(loan);
}
+
+ private void createMissingAccrualTransactionIfNeeded(final BigDecimal newInterest, final Loan loan, final LocalDate chargeOffDate) {
Review Comment:
I considered moving this logic into the LoanAccrualProcessingService, but unfortunately, it wasn't feasible. Doing so introduces a circular dependency issue, making it impossible to use the service within the AdvancedPaymentScheduleTransactionProcessor. Therefore, I decided to move it in the AdvancedPaymentScheduleTransactionProcessor.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org