From e80e18600d8500b1945fa0b12d9781d4b3d09439 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 13:49:58 +0530 Subject: [PATCH] Fix org-case invoice scoping --- app/Controllers/Billing/CaseMaster.php | 4 ++++ app/Models/OrganizationCaseModel.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/Controllers/Billing/CaseMaster.php b/app/Controllers/Billing/CaseMaster.php index 1369c6d..02ac3a2 100644 --- a/app/Controllers/Billing/CaseMaster.php +++ b/app/Controllers/Billing/CaseMaster.php @@ -562,6 +562,7 @@ class CaseMaster extends BaseController and ( o.insurance_case_id = cast(c.id as char) or o.insurance_case_id = c.case_id_code + or o.p_id = c.p_id ) union all @@ -585,6 +586,7 @@ class CaseMaster extends BaseController and ( i.insurance_case_id = c.id or i.insurance_case_id = c.case_id_code + or i.attach_id = c.p_id ) ) v order by v.Charge_type, v.Adate @@ -626,6 +628,7 @@ class CaseMaster extends BaseController ->groupStart() ->where('insurance_case_id', (string) $caseId) ->orWhere('insurance_case_id', (string) ($caseRow->case_id_code ?? '')) + ->orWhere('p_id', (int) ($caseRow->p_id ?? 0)) ->groupEnd() ->get() ->getRow(); @@ -644,6 +647,7 @@ class CaseMaster extends BaseController ->groupStart() ->where('insurance_case_id', $caseId) ->orWhere('insurance_case_id', (string) ($caseRow->case_id_code ?? '')) + ->orWhere('attach_id', (int) ($caseRow->p_id ?? 0)) ->groupEnd() ->get() ->getRow(); diff --git a/app/Models/OrganizationCaseModel.php b/app/Models/OrganizationCaseModel.php index fc10abb..3d5043c 100644 --- a/app/Models/OrganizationCaseModel.php +++ b/app/Models/OrganizationCaseModel.php @@ -52,6 +52,7 @@ class OrganizationCaseModel extends Model and ( o.insurance_case_id = cast(c.id as char) or o.insurance_case_id = c.case_id_code + or o.p_id = c.p_id ) union all @@ -75,6 +76,7 @@ class OrganizationCaseModel extends Model and ( i.insurance_case_id = c.id or i.insurance_case_id = c.case_id_code + or i.attach_id = c.p_id ) ) v order by v.Charge_type, v.Adate