From 32411c924b2f011762d9ac906c0c67227eb81bef Mon Sep 17 00:00:00 2001 From: Nitesh Yadav Date: Fri, 25 Sep 2026 10:58:44 +0530 Subject: [PATCH] fix(accounting): stop the Journal Entry view showing a colliding current account's number for a savings GL entry entity_type_enum=2 (PortfolioProductType.SAVING) is written for both savings and current-account journal entries -- current products deliberately share SAVING's GL type space -- so it can't distinguish them, and m_savings_account/m_current_account each have their own id sequence, meaning an entity_id can be a real row in both. The account- number column's COALESCE(ca.account_no, sa.account_no) always preferred the current account's number whenever both matched, so a savings deposit's own journal entry displayed an unrelated current account's number instead of the account it actually posted against. savings_transaction_id is the one reliable signal available on this query: only a genuine savings transaction sets it. Checking it first resolves the correct account whenever it's present, and falls back to the previous behavior only when it's absent (current-account entries, which don't set it). Co-Authored-By: Claude Sonnet 5 --- .../service/JournalEntryReadPlatformServiceImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java index 10fe6b8b8..8115f66ea 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java @@ -105,7 +105,18 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat .append(" journalEntry.currency_code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ") .append(" curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ") .append(" eao.external_id as externalAssetOwner, ") + // entity_type_enum=2 (PortfolioProductType.SAVING) is written for BOTH savings and + // current-account entries -- current products deliberately share SAVING's GL type + // space (see PortfolioProductType.CURRENT's own comment) -- so it cannot tell the two + // apart on its own, and m_savings_account/m_current_account each have their own id + // sequence: an entity_id can be a real row in both, making a plain + // COALESCE(ca.account_no, sa.account_no) pick the current account's number even for + // an entry that is genuinely a savings one. savings_transaction_id is the one + // unambiguous signal available here -- only a real savings transaction sets it -- so + // it decides first; only when it's absent (a current-account entry, or a savings + // entry with no linked transaction row) does the current-account guess apply. .append(" CASE ") + .append(" WHEN journalEntry.entity_type_enum = 2 AND journalEntry.savings_transaction_id IS NOT NULL THEN sa.account_no ") .append(" WHEN journalEntry.entity_type_enum = 2 THEN COALESCE(ca.account_no, sa.account_no) ") .append(" ELSE NULL ") .append(" END as savingsAccountNo ");