feat(cashier): fix current account transactions search and withdrawal validations

CurrentAccountTransactionsApiResource:
- Fixed: search endpoint now queries m_current_account_transaction
  instead of m_savings_account_transaction (wrong table)
- Added remarks column to search query (column exists in CA table)
- Charge Deduction (type=7) mapped in transactionType value
- Removed sat.remarks that caused 500 (column doesn't exist in savings table)

CurrentAccountTransactionWritePlatformServiceImpl:
- Added min required balance validation in withdrawal()
- Throws GeneralPlatformDomainRuleException when balance after withdrawal
  would fall below minRequiredBalance (if enforceMinRequiredBalance=true)

StandingInstructionReadPlatformServiceImpl:
- Fixed SQL WHERE clause: fromAccountType + fromAccount condition
  now correctly adds WHERE when fromAccountId is set

Liquibase 0315:
- Fix standing instruction permission code (trim trailing space on id=449)
- Grant READ permissions to CASHIER role for transaction entry screen

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-05 22:27:59 +05:30
co-authored by Claude Sonnet 4.6
parent 2371ad98b1
commit edaeb674d5
4 changed files with 125 additions and 18 deletions
@@ -10,16 +10,30 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<!--
Grant additional READ permissions to the CASHIER role required for
the Cashier Transaction Entry screen to display full account details:
- READ_CLIENTKYC → PAN, Aadhaar, CKYC number
- READ_CLIENTNOMINEE → nominee list per account
- READ_ADDRESS → client address
- READ_FAMILYMEMBERS → S/D/W/H/O (guardian/spouse name)
- READ_SAVINGSACCOUNT → savings account detail fetch
Fix: m_permission.code for READ_STANDINGINSTRUCTION (id=449) had a trailing
space which caused permission checks to fail (exact string match).
Must run BEFORE the permission grant below.
-->
<changeSet id="0315_fix_standing_instruction_permission_code" author="fineract">
<sql>
UPDATE m_permission
SET code = TRIM(code)
WHERE id = 449
AND code != TRIM(code);
</sql>
<rollback><!-- no rollback needed — trimming is idempotent --></rollback>
</changeSet>
<!--
Grant READ permissions to CASHIER role for Cashier Transaction Entry screen:
- READ_CLIENTKYC, READ_CLIENTNOMINEE, READ_ADDRESS, READ_FAMILYMEMBERS
- READ_SAVINGSACCOUNT, READ_CLIENTIMAGE, READ_DOCUMENT
- READ_SAVINGNOTE, READ_CLIENTNOTE
- READ_STANDINGINSTRUCTION (id 449 — trailing space fixed above)
-->
<changeSet id="0315_grant_cashier_transaction_entry_permissions" author="fineract">
<sql>
-- Grant code-based permissions (includes READ_STANDINGINSTRUCTION after trim fix)
INSERT INTO m_role_permission (role_id, permission_id)
SELECT r.id, p.id
FROM m_role r
@@ -28,7 +42,12 @@
'READ_CLIENTNOMINEE',
'READ_ADDRESS',
'READ_FAMILYMEMBERS',
'READ_SAVINGSACCOUNT'
'READ_SAVINGSACCOUNT',
'READ_CLIENTIMAGE',
'READ_DOCUMENT',
'READ_SAVINGNOTE',
'READ_CLIENTNOTE',
'READ_STANDINGINSTRUCTION'
)
WHERE r.name = 'CASHIER'
AND NOT EXISTS (
@@ -42,11 +61,10 @@
AND permission_id IN (
SELECT id FROM m_permission
WHERE code IN (
'READ_CLIENTKYC',
'READ_CLIENTNOMINEE',
'READ_ADDRESS',
'READ_FAMILYMEMBERS',
'READ_SAVINGSACCOUNT'
'READ_CLIENTKYC', 'READ_CLIENTNOMINEE', 'READ_ADDRESS',
'READ_FAMILYMEMBERS', 'READ_SAVINGSACCOUNT', 'READ_CLIENTIMAGE',
'READ_DOCUMENT', 'READ_SAVINGNOTE', 'READ_CLIENTNOTE',
'READ_STANDINGINSTRUCTION'
)
);
</rollback>