abhinavjha0239 opened a new pull request, #6665: URL: https://github.com/apache/fineract/pull/6665
## Description Fixes [FINERACT-752](https://issues.apache.org/jira/browse/FINERACT-752). With `savings-interest-posting-current-period-end` enabled, a manual ("post interest as on") interest posting is duplicated when a backdated transaction recalculates interest, and every further backdated transaction adds one more posting for the same period. **Cause** With the configuration enabled, `PostingPeriod` dates a manual posting on the period end date instead of the day after it. On recalculation, `SavingsAccount.calculateInterestUsing` passed that stored date to `SavingsHelper.determineInterestPostingPeriods`, which treats every date as a posting date and ends the period on the previous day. The period moved one day earlier, the existing posting no longer matched it, and another posting was created. **Change** When the configuration is enabled, the stored manual posting dates are shifted forward by one day before the periods are split, so they mark the same period boundary as when the configuration is disabled. Nothing changes when the configuration is disabled. **Test** The configuration description says "There is no difference in the interest amount posted". `testManualInterestPostingIsNotDuplicatedWhenPostingAtPeriodEnd` runs the same scenario (business date 02 April 2019: deposit, post interest as on 25 March, two backdated transactions) with the configuration disabled and enabled, and checks that the interest postings have the same amounts and are dated one day earlier. It fails on develop (`expected: <2> but was: <4>`) and passes with this change. **Reproduction** (steps from the Jira issue, develop `d924f025d2`, PostgreSQL 18) | | Interest postings before the 26 March withdrawal | |---|---| | Configuration disabled | 25 Mar: 144.75 | | Enabled, develop | 23 Mar: 138.72 and 24 Mar: 144.75 | | Enabled, this change | 24 Mar: 144.75 | I also compared develop and this change in 16 API scenarios (as on the first and last day of a month, backdated deposit, several recalculations, undo, quarterly posting, daily compounding, withdrawal fee, pivot mode, business dates). With this change the enabled case matches the disabled case in all transaction scenarios, and the disabled case is unchanged in every scenario. **Notes** - An account that already has the duplicate gets the correct total on the next backdated transaction (the extra posting is reduced to one day of interest). There is no data migration. - The Post Interest For Savings job does not load the manual flag of transactions, so it does not see manual postings and posts their interest again, with the configuration enabled or disabled. That is a separate cause; I will open a separate Jira issue for it, and this PR does not change the job. ## Checklist - [x] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests) - [x] 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. - [x] Create/update [unit or integration tests](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made. - [x] 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 (not applicable, no API change) - [x] [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). - [x] 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). -- 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]
