From b23a3b19b155e23624ae43a30d22cf58173e18e7 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 21 Nov 2025 14:43:15 +0530 Subject: [PATCH] GWM : invoice module update --- app/Controllers/EnquiryController.php | 6 ++++-- app/Controllers/InvoiceController.php | 8 +++++++- app/Models/InvoiceModel.php | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EnquiryController.php b/app/Controllers/EnquiryController.php index 9ba1a3b..29909d3 100644 --- a/app/Controllers/EnquiryController.php +++ b/app/Controllers/EnquiryController.php @@ -116,12 +116,13 @@ class EnquiryController extends ResourceController } //Get related quotations - $quotations = $this->QuotationModel->select('partner_quotation.*, pe.reg_no , I.name as insurer_name, I.short_name , ipti.insurance_plan_type,pe.broker_id ,PB.name as broker_name,PA.name as agent_name' ) + $quotations = $this->QuotationModel->select('partner_quotation.*, pe.reg_no , I.name as insurer_name, I.short_name , ipti.insurance_plan_type,pe.broker_id ,PB.name as broker_name,PA.name as agent_name , PP.policy_pdf_file_name , PP.id as policy_id' ) ->join('partner_enquiry pe', 'pe.id = partner_quotation.enquiry_id', 'left') ->join('insurers I', 'I.id = partner_quotation.insurer_id', 'left') ->join('partner_insurance_plan_type_master ipti', 'ipti.id = partner_quotation.insurance_plan_type_id', 'left') ->join('partner_brokers PB', 'PB.id = pe.broker_id', 'left') ->join('partner_agent PA', 'PA.id = pe.agent_id', 'left') + ->join('partner_policy PP', 'PP.quotation_id = partner_quotation.id', 'left') ->where('partner_quotation.enquiry_id', $enquiry_id) ->where('partner_quotation.is_active', 1) ->orderBy('partner_quotation.id', 'DESC') @@ -135,13 +136,14 @@ class EnquiryController extends ResourceController if($value['status'] == 'Accepted') { $quotationId = $value['id']; } } - $policies = $this->PolicyModel->select('partner_policy.*, pe.reg_no, I.name as insurer_name, I.short_name , pq.insured_declared_value, ipti.insurance_plan_type, pe.broker_id , PB.name as broker_name,PA.name as agent_name') + $policies = $this->PolicyModel->select('partner_policy.*, pe.reg_no, I.name as insurer_name, I.short_name , pq.insured_declared_value, ipti.insurance_plan_type, pe.broker_id , PB.name as broker_name,PA.name as agent_name, pm.id as payment_mode_id') ->join('partner_enquiry pe', 'pe.id = partner_policy.enquiry_id', 'left') ->join('partner_quotation pq', 'pq.id = partner_policy.quotation_id', 'left') ->join('insurers I', 'I.id = pq.insurer_id', 'left') ->join('partner_insurance_plan_type_master ipti', 'ipti.id = pq.insurance_plan_type_id', 'left') ->join('partner_brokers PB', 'PB.id = pe.broker_id', 'left') ->join('partner_agent PA', 'PA.id = pe.agent_id', 'left') + ->join('partner_payment_mode_master pm', 'pm.id = pq.payment_mode_id', 'left') ->where('partner_policy.quotation_id', $quotationId) ->where('partner_policy.is_active', 1) ->first(); diff --git a/app/Controllers/InvoiceController.php b/app/Controllers/InvoiceController.php index 4e6fe34..f4927fb 100644 --- a/app/Controllers/InvoiceController.php +++ b/app/Controllers/InvoiceController.php @@ -35,7 +35,12 @@ class InvoiceController extends ResourceController { try { - $data = $this->InvoiceModel->where('is_active', 1)->orderBy('id', 'DESC')->findAll(); + $data = $this->InvoiceModel->select('partner_invoice.*, PB.name as broker_name, PA.name as agent_name') + ->join('partner_brokers PB', 'PB.id = partner_invoice.broker_id', 'left') + ->join('partner_agent PA', 'PA.id = partner_invoice.agent_id', 'left') + ->where('is_active', 1) + ->orderBy('id', 'DESC') + ->findAll(); return $this->respond(['status' => 'success', 'code' => 200,'data' => $data ], 200); @@ -94,6 +99,7 @@ class InvoiceController extends ResourceController $invoiceData = [ 'invoice_no' => $input['invoice_no'] ?? '', 'invoice_amount' => $input['invoice_amount'] ?? 0, + 'broker_id' => $input['broker_id'] ?? 0, 'agent_id' => $input['agent_id'] ?? '', 'invoice_date' => $input['invoice_date'] ?? '', 'payout_status' => $input['payout_status'] ?? 0, diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index d5c946e..6b6592e 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -16,6 +16,7 @@ class InvoiceModel extends Model protected $allowedFields = [ 'invoice_no', 'invoice_amount', + 'broker_id', 'agent_id', 'invoice_date', 'payout_status',