[ 
https://issues.apache.org/jira/browse/FINERACT-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Abhishek Chaudhary reassigned FINERACT-2705:
--------------------------------------------

    Assignee: Abhishek Chaudhary

> Post Interest For Savings job aborts all interest postings when one 
> transaction's GL account is unresolved
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2705
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2705
>             Project: Apache Fineract
>          Issue Type: Bug
>          Components: Accounting, Savings
>    Affects Versions: 1.13.0
>            Reporter: Abhishek Chaudhary
>            Assignee: Abhishek Chaudhary
>            Priority: Major
>
> The scheduled job *Post Interest For Saving* writes all journal entries for a 
> posting cycle in a single JDBC batch inside one transaction.
> {{SavingsSchedularInterestPoster.batchUpdateJournalEntries}} decides whether 
> to write journal entries using the *product-level* {{SAVINGS_CONTROL}} and 
> {{INTEREST_ON_SAVINGS}} mappings, but the inserted rows use the 
> *transaction-level* accounts chosen by 
> {{SavingsAccountWritePlatformServiceJpaRepositoryImpl.selectAccountId}}, 
> which resolves accrual-only mappings ({{INTEREST_PAYABLE}}, 
> {{INTEREST_RECEIVABLE}} - introduced in FINERACT-2312). For a cash-based 
> product these mappings do not exist, so the resolved account id is {{0}} and 
> the batch INSERT fails with:
> {code}
> ERROR: insert or update on table "acc_gl_journal_entry" violates foreign key 
> constraint "FK_acc_gl_journal_entry_acc_gl_account"
> Detail: Key (account_id)=(0) is not present in table "acc_gl_account".
> {code}
> Because the whole batch shares one transaction, a *single* account with an 
> unresolved GL mapping rolls back interest posting for *every* savings account 
> in the tenant.
> This was observed deterministically in [PR 
> #6124|https://github.com/apache/fineract/pull/6124] CI on all three databases 
> (MySQL, MariaDB, PostgreSQL), where test sharding co-located a cash-based 
> accounting test ({{AccountTransferTest}}) with 
> {{SavingsInterestPostingTest}}. PR #6124 fixes the cash-based fallback in 
> {{selectAccountId}} for regular interest posting; this ticket makes the job 
> itself resilient:
> * validate the transaction-level GL accounts before enqueueing journal entries
> * skip (with a WARN log) transactions whose accounts are unresolved - e.g. 
> overdraft interest on cash-based products - instead of failing the whole 
> batch for all accounts
> Unit tests included. PR follows.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to