Skip to content

Conversation

@mariiaKraievska
Copy link
Contributor

Description

Describe the changes made and why they were made.

Ignore if these details are present on the associated Apache Fineract JIRA ticket.

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.

return isDueBefore && isAfterOrEqualToLastAccrualDate;
}).sorted(Comparator.comparing(LoanRepaymentScheduleInstallment::getDueDate)).toList();

installments.forEach(installment -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Dont you like the stream foreach? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question! I do like the stream forEach, but here I needed to reset the lastAccrualActivityMarkedToReverse variable after the first iteration. Since Java doesn't allow reassigning variables inside a lambda, I had to use the classic for-each loop to make this work :(

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Thanks!

Still "lastAccrualActivityMarkedToReverse = Optional.empty();" what does this do exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting lastAccrualActivityMarkedToReverse = Optional.empty(); ensures that only the first installment in the loop uses the original value of lastAccrualActivityMarkedToReverse. For all subsequent installments, it will be empty, so they will not be treated as a replay of the previous accrual activity, but as new accrual activities.

This is necessary to publish the correct business event: only the first accrual activity after loan reopen should be a replay, and the rest should be new.

By the way, this line (lastAccrualActivityMarkedToReverse = Optional.empty();) was actually present in the original implementation, but it seems it got lost during a recent refactoring :(

@MarianaDmytrivBinariks MarianaDmytrivBinariks force-pushed the FINERACT-2181/fix-loan-accrual-activity-events-posting branch from fbebab3 to 604de4b Compare July 1, 2025 11:42
@mariiaKraievska mariiaKraievska marked this pull request as ready for review July 1, 2025 14:51
@adamsaghy adamsaghy merged commit 072017c into apache:develop Jul 1, 2025
10 checks passed
@adamsaghy adamsaghy deleted the FINERACT-2181/fix-loan-accrual-activity-events-posting branch July 1, 2025 18:16
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.

3 participants