[
https://issues.apache.org/jira/browse/FINERACT-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127604#comment-18127604
]
Abhinav Kumar Jha commented on FINERACT-2957:
---------------------------------------------
I have opened a PR for this: https://github.com/apache/fineract/pull/6667
*Fix:* the mapper now reads {{is_manual}}, so the job splits the posting period
at a manual posting the same way the savings account does. With
{{savings-interest-posting-current-period-end}} enabled, the job also gets the
one day shift from FINERACT-752.
*Verification:* in 23 scenarios, each with the configuration disabled and
enabled, the job now posts exactly what the {{postInterest}} command posts for
an identical account (44 of 44 runs, 8 of 44 on develop). Accounts without
manual postings and pivot mode are unchanged. The new integration test fails on
develop with {{expected 42.2192 but was 186.970800}} and passes with the fix.
> Post Interest For Savings job posts interest again for days already covered
> by a manual interest posting
> --------------------------------------------------------------------------------------------------------
>
> Key: FINERACT-2957
> URL: https://issues.apache.org/jira/browse/FINERACT-2957
> Project: Apache Fineract
> Issue Type: Bug
> Components: Savings
> Affects Versions: 1.15.0
> Environment: Apache Fineract develop, PostgreSQL 18
> Reporter: Abhinav Kumar Jha
> Assignee: Abhinav Kumar Jha
> Priority: Critical
>
> h3. Summary
> When a savings account has a manual interest posting ("post interest as on"),
> the *Post Interest For Savings* job ignores it and posts interest for the
> whole posting period. The days before the manual posting are credited twice.
> - Happens with {{savings-interest-posting-current-period-end}} *disabled (the
> default)* and *enabled*
> - Present since release *1.6.0* (February 2022), and still on the current
> develop branch
> - Separate from FINERACT-752 (fixed in #6665), which fixed a similar
> duplicate in the savings account recalculation path. The job uses a different
> code path.
> h3. Steps to reproduce
> _Fresh tenant database on PostgreSQL 18, business date enabled_
> # Savings product: 11% nominal, monthly compounding, monthly posting, daily
> balance, 365 days
> # Business date *01 March 2019*: activate an account and deposit *20013*
> # Business date *25 March 2019*: post interest as on 25 March 2019
> # Business date *01 April 2019*: run the *Post Interest For Savings* job
> h3. Actual vs expected
> ||Configuration||Manual posting||Job posting (actual)||Job posting
> (expected)||Overpaid||
> |disabled|25 Mar 2019: 144.75|01 Apr 2019: *186.97*|42.22|*144.75*|
> |enabled|24 Mar 2019: 144.75|31 Mar 2019: *186.97*|42.22|*144.75*|
> - *186.97* is the interest for all of March: 20013 x 11% x 31 / 365
> - *42.22* is the interest for 25 to 31 March only: 20013 x 11% x 7 / 365.
> This is also what a savings transaction posts for the same account state.
> h3. Cause
> The job loads accounts through {{SavingAccountMapperForInterestPosting}} in
> {{SavingsAccountReadPlatformServiceImpl}}:
> # The query selects {{tr.is_manual as manualTransaction}}, but the mapper
> never reads that column.
> # It passes a hard-coded {{postInterestAsOn = false}} to
> {{SavingsAccountTransactionData.create(...)}}, and {{createData(...)}} always
> sets {{isManualTransaction}} to false.
> # So {{SavingsAccountInterestPostingServiceImpl.getManualPostingDates}}
> always returns an empty list, and the job never splits the period at the
> manual posting date.
> {code:java}
> // SavingsAccountReadPlatformServiceImpl,
> SavingAccountMapperForInterestPosting
> final boolean postInterestAsOn = false;
> {code}
> This line was introduced by FINERACT-1495 (interest posting performance
> improvement, PR #2027, February 2022).
> h3. Proposed fix
> - Read the {{manualTransaction}} column in the mapper and carry it into
> {{SavingsAccountTransactionData}}, so the job splits the posting period the
> same way the savings account does.
> - With the flag loaded, apply the same period end date handling as
> FINERACT-752 when {{savings-interest-posting-current-period-end}} is enabled.
> - Add an integration test that runs the job after a manual posting with both
> configuration values.
> h3. Related work
> - PR #6614 (FINERACT-2908) also changes
> {{SavingAccountMapperForInterestPosting}}
> - PR #6532 (FINERACT-2869) changes
> {{SavingsAccountInterestPostingServiceImpl}}
> I will coordinate with both.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)