김다연 created FINERACT-3023:
-----------------------------
Summary: Fixed deposit maturity job posts the journal entries of
the maturity payout two or three times
Key: FINERACT-3023
URL: https://issues.apache.org/jira/browse/FINERACT-3023
Project: Apache Fineract
Issue Type: Bug
Components: Savings
Affects Versions: 1.15.0
Reporter: 김다연
When the "Update Deposit Accounts Maturity details" job matures a fixed deposit
with a maturity instruction, the journal entries of the payout transaction are
posted more than once, so the savings control account no longer matches the
account balances.
*Steps to reproduce* (develop 755657010b, PostgreSQL)
# Fixed deposit product with cash based accounting. For instruction 200, also
map the "Liability Transfer" financial activity to a GL account and set
{{transferToSavingsId}} on the deposit.
# Fixed deposit of 100,000 for 14 months with {{"maturityInstructionId"}} 300,
400 or 200, submitted, approved and activated on 2026-01-01.
# Enable the business date, set it to 2027-03-01 and run "Update Deposit
Accounts Maturity details".
# Read the journal entries of the payout ({{GET
/journalentries?savingsId=...}}).
Actual result:
||Maturity instruction||Payout||Journal entries of the payout||
|Reinvest principal and interest (300)|withdrawal 108,445.72|*3 times* (debits
325,337.15)|
|Reinvest principal only (400)|withdrawal 100,000.00|*3 times* (debits
300,000.00)|
|Transfer to savings (200)|transfer 108,445.72|*2 times* (debits 216,891.43)|
Expected result: one debit and one credit for the payout.
With 300, the savings control account gets 208,445.72 in credits (deposit,
interest, new deposit) and 325,337.15 in debits, so it shows -116,891.43 while
the client holds 100,000 in the new deposit.
{{JournalEntryWritePlatformServiceImpl#createJournalEntriesForSavings}} posts
whatever it is given, so the payout is posted once by each of these calls:
* Reinvest (300, 400): {{handleWithdrawal}}, then {{postJournalEntries}} at the
end of {{DepositAccountDomainServiceJpa#handleFDAccountMaturityClosure}} (its
existing transaction ids were taken before the withdrawal), then
{{postJournalEntries}} at the end of
{{DepositAccountWritePlatformServiceJpaRepositoryImpl#updateMaturityDetails}}
(ids taken before the closure).
* Transfer (200): {{transferFunds}}, then {{postJournalEntries}} in
{{updateMaturityDetails}}. The closure itself skips the transfer, as
{{updateAlreadyPostedTransactions}} marks it posted.
*History*
FINERACT-1401 fixed the same double posting for a manual close
({{handleFDAccountClosure}}, PR #1885). {{handleFDAccountMaturityClosure}} and
the posting in {{updateMaturityDetails}} were not changed.
*Suggested fix*
Post the payout once in the job path, and add a test that runs the job for 200,
300 and 400 and checks the journal entries of the payout.
Related: FINERACT-XXXX (new deposit funded with the principal only).
I'd like to work on this and will open a PR.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)