From fc45729beea5cbebce5d80e54005c922eddce44d Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 18 Dec 2025 09:31:53 +0530 Subject: [PATCH] GWM : pos id handled --- app/Controllers/AgentController.php | 4 ++-- app/Controllers/InvoiceController.php | 20 +++++++++----------- app/Controllers/PolicyController.php | 7 +++---- app/Models/AgentModel.php | 3 ++- app/Models/InvoiceModel.php | 3 ++- app/Models/StaffModel.php | 4 +++- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/Controllers/AgentController.php b/app/Controllers/AgentController.php index 659c0c3..d4c9d79 100644 --- a/app/Controllers/AgentController.php +++ b/app/Controllers/AgentController.php @@ -101,7 +101,7 @@ class AgentController extends ResourceController 'sales_executive_id' => $data['sales_executive_id'], 'certificate_file_name' => $certificateFileName, 'created_by' => $data['created_by'], - 'pos_id' => $data['pos_id'] + 'retention_rate' => $data['retention_rate'] ]; $this->AgentModel->insert($insertData); @@ -142,7 +142,7 @@ class AgentController extends ResourceController 'agent_code' => $data['agent_code'] ?? null, 'sales_executive_id' => $data['sales_executive_id'] ?? null, 'updated_by' => $data['updated_by'] ?? null, - 'pos_id' => $data['pos_id'] ?? null + 'retention_rate' => $data['retention_rate'] ?? null ]; if ($certificateFile && $certificateFile->isValid()) { diff --git a/app/Controllers/InvoiceController.php b/app/Controllers/InvoiceController.php index 636cf78..a592dd2 100644 --- a/app/Controllers/InvoiceController.php +++ b/app/Controllers/InvoiceController.php @@ -35,11 +35,11 @@ class InvoiceController extends ResourceController { try { - $data = $this->InvoiceModel->select('partner_invoice.*, PB.name as broker_name, PA.name as agent_name, + $data = $this->InvoiceModel->select('partner_invoice.*, PB.name as broker_name, pos.name as pos_name, FORMAT(partner_invoice.invoice_amount, 2, "en_IN") AS invoice_amount_indian_format, DATE_FORMAT(partner_invoice.invoice_date, "%d-%m-%Y") AS invoice_date_ui_format') ->join('partner_brokers PB', 'PB.id = partner_invoice.broker_id', 'left') - ->join('partner_agent PA', 'PA.id = partner_invoice.agent_id', 'left') + ->join('partner_pos pos', 'pos.id = partner_invoice.pos_id', 'left') ->where('partner_invoice.is_active', 1) ->orderBy('partner_invoice.id', 'DESC') ->findAll(); @@ -102,7 +102,7 @@ class InvoiceController extends ResourceController 'invoice_no' => $input['invoice_no'] ?? '', 'invoice_amount' => $input['invoice_amount'] ?? 0, 'broker_id' => $input['broker_id'] ?? 0, - 'agent_id' => $input['agent_id'] ?? '', + 'pos_id' => $input['pos_id'] ?? 0, 'till_date' => $input['till_date'] ? date('Y-m-d', strtotime($input['till_date'])) : null, 'invoice_date' => $input['invoice_date'] ? date('Y-m-d', strtotime($input['invoice_date'])) : null, 'payout_status' => 1, @@ -197,15 +197,13 @@ class InvoiceController extends ResourceController public function getCommissionRateList() { try { + $input = $this->request->getJSON(true); - if (empty($input['agent_id']) || empty($input['issued_date'])) { - return $this->respond([ - 'status' => 'failed', - 'code' => 400, - 'message'=> 'agent_id and issued_date are required' - ], 400); + if (empty($input['broker_id']) || empty($input['issued_date'])) { + return $this->respond([ 'status' => 'failed', 'code' => 400, 'message'=> 'issued_date are required' ], 400); } + $invoice_id = isset($input['invoice_id']) ? $input['invoice_id'] : ''; @@ -217,7 +215,7 @@ class InvoiceController extends ResourceController 'left' ) ->join('partner_quotation pq','pq.id = partner_policy.quotation_id ', 'left') - ->where('partner_policy.agent_id', $input['agent_id']) + // ->where('partner_policy.pos_id', $input['pos_id']) ->where('partner_policy.issued_date <=', date('Y-m-d', strtotime($input['issued_date']))) ->where('partner_policy.is_active', 1) ->where('partner_policy.is_data_accuracy_checked', 1) @@ -234,7 +232,7 @@ class InvoiceController extends ResourceController ->join('partner_quotation pq','pq.id = partner_policy.quotation_id ', 'left') ->join('partner_invoice_items pii', 'pii.policy_id = partner_policy.id', 'left' ) ->join('partner_invoice pi', 'pi.id = pii.invoice_id AND pi.is_active = 1', 'left') - ->where('partner_policy.agent_id', $input['agent_id']) + // ->where('partner_policy.pos_id', $input['pos_id']) ->where('partner_policy.issued_date <=', date('Y-m-d', strtotime($input['issued_date']))) ->where('partner_policy.is_active', 1) ->where('partner_policy.commission_amount > 0') diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index a55fbc5..283fe81 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -93,7 +93,7 @@ class PolicyController extends ResourceController try { $id = $this->request->getGet('id'); - $record = $this->PolicyModel->select('partner_policy.* , ipti.insurance_plan_type,') + $record = $this->PolicyModel->select('partner_policy.* , ipti.insurance_plan_type,pq.insurer_id') ->join('partner_quotation pq', 'pq.id = partner_policy.quotation_id', 'left') ->join('partner_insurance_plan_type_master ipti', 'ipti.id = pq.insurance_plan_type_id', 'left') ->find($id); @@ -342,7 +342,7 @@ class PolicyController extends ResourceController } //fetch enquiry_id & agent_id - $quotData = $this->QuotationModel->select('partner_quotation.*,E.agent_id,E.name , A.pos_id') + $quotData = $this->QuotationModel->select('partner_quotation.*,E.agent_id,E.name ') ->join('partner_enquiry E', 'E.id = partner_quotation.enquiry_id', 'left') ->join('partner_agent A', 'A.id = E.agent_id', 'left') ->where('partner_quotation.id',$data['quotation_id']) @@ -384,8 +384,7 @@ class PolicyController extends ResourceController 'manager_id' => $data['manager_id'], 'agent_id' => $quotData['agent_id'], 'policy_pdf_file_name' => $pdfFileName, - 'created_by' => $data['created_by'], - 'pos_id' => $quotData['pos_id'] + 'created_by' => $data['created_by'] ]; $policyId = $this->PolicyModel->insert($insertData); diff --git a/app/Models/AgentModel.php b/app/Models/AgentModel.php index 971d4d6..dd5956a 100644 --- a/app/Models/AgentModel.php +++ b/app/Models/AgentModel.php @@ -25,7 +25,8 @@ class AgentModel extends Model 'created_on', 'updated_by', 'updated_on', - 'pos_id' + 'pos_id', + 'retention_rate' ]; protected $useTimestamps = false; // we manually handle created_on & updated_on diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 105994b..fcd4002 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -25,7 +25,8 @@ class InvoiceModel extends Model 'created_at', 'created_by', 'updated_at', - 'updated_by' + 'updated_by', + 'pos_id', ]; // Timestamps diff --git a/app/Models/StaffModel.php b/app/Models/StaffModel.php index 585618e..3b8e9de 100644 --- a/app/Models/StaffModel.php +++ b/app/Models/StaffModel.php @@ -20,7 +20,9 @@ class StaffModel extends Model 'created_by', 'created_on', 'updated_by', - 'updated_on' + 'updated_on', + 'pos_id', + 'retention_rate' ]; protected $useTimestamps = false; // we manually manage created_on / updated_on