jayyyyqwq opened a new pull request, #6716: URL: https://github.com/apache/fineract/pull/6716
## Description FINERACT-2820 `PostingPeriod` picks the last day of February from the wrong year in two places. For `ANNUAL` compounding, `determineInterestPeriodEndDateFrom` takes the last day of the fiscal year end month and only then adds a year when the date is before the start. With a fiscal year that starts in March, a period that starts on 2023-03-01 ends on 2024-02-28 instead of 2024-02-29. The loop then adds a second period for 2024-02-29, so interest compounds one day early. For `QUATERLY` and `BI_ANNUAL`, `getPeriodEndDate` takes the length of the month from the business date year instead of the year of the period. With a business date in 2024 and a period on 2025-02-28 this throws `DateTimeException: Invalid date 'February 29' as '2025' is not a leap year`. With a business date in 2025 and a period that ends on 2024-02-29, the end date is 2024-02-28, the next start date is 2024-02-29 again, and the loop in `compoundingPeriodsInPostingPeriod` never ends. In my test run the JVM ran out of heap. I changed the annual case to take the last day of the month after the year is added, and used `YearMonth.of(year, month).lengthOfMonth()` in `getPeriodEndDate`. I added `PostingPeriodCompoundingPeriodTest` with four tests: annual in a leap year, annual in a non-leap year (this one passed before too), and the two quarterly cases above. Before the change the first and third fail and the fourth does not finish. After the change all pass, and the other `portfolio.savings` tests in `fineract-core` pass too. I did not run the full build or the integration tests. ## Checklist Please make sure these boxes are checked before submitting your pull request - thanks! - [ ] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#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](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made. - [ ] Follow our [coding conventions](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 - [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute). - [ ] If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately. - [ ] I followed the [AI Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy). Your assigned reviewer(s) will follow our [guidelines for code reviews](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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
