fix(cashier): fix GL account search SQL bug, running balance, and add CASHIER role permissions

- Fix searchParam SQL syntax: parameterized LIKE with %value% instead of literal %?%
- Fix organizationRunningBalance: correlated subquery for latest journal entry (ORDER BY id DESC LIMIT 1)
- Migration 0317: grant READ_GLACCOUNT, READ_LOAN, READ_SHAREACCOUNT to CASHIER role

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-10 11:17:32 +05:30
co-authored by Claude Sonnet 4.6
parent 6d0c1fe7f6
commit 53b6a94bf8
3 changed files with 325 additions and 272 deletions
@@ -344,4 +344,5 @@
<include file="parts/0314_cashier_staff_unique_constraint.xml" relativeToChangelogFile="true"/>
<include file="parts/0315_grant_cashier_transaction_entry_permissions.xml" relativeToChangelogFile="true"/>
<include file="parts/0316_create_clerk_role_and_permissions.xml" relativeToChangelogFile="true"/>
<include file="parts/0317_grant_cashier_gl_loan_share_read_permissions.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
for licensing details.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<!--
Grant READ permissions to CASHIER role for new account types added
in the Cashier Transaction Entry screen:
- READ_GLACCOUNT : GL account lookup and balance (AC. TP. = GL)
- READ_LOAN : Loan account lookup (AC. TP. = LA)
- READ_SHAREACCOUNT : Share account lookup (AC. TP. = SHR)
-->
<changeSet id="0317_grant_cashier_gl_loan_share_read_permissions" author="fineract">
<sql>
INSERT INTO m_role_permission (role_id, permission_id)
SELECT r.id, p.id
FROM m_role r
JOIN m_permission p ON p.code IN (
'READ_GLACCOUNT',
'READ_LOAN',
'READ_SHAREACCOUNT'
)
WHERE r.name = 'CASHIER'
AND NOT EXISTS (
SELECT 1 FROM m_role_permission rp
WHERE rp.role_id = r.id AND rp.permission_id = p.id
);
</sql>
<rollback>
DELETE FROM m_role_permission
WHERE role_id = (SELECT id FROM m_role WHERE name = 'CASHIER')
AND permission_id IN (
SELECT id FROM m_permission
WHERE code IN (
'READ_GLACCOUNT',
'READ_LOAN',
'READ_SHAREACCOUNT'
)
);
</rollback>
</changeSet>
</databaseChangeLog>