From 5ee661d254e0b850251426ed672ab6482a704fd7 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 15:01:44 +0530 Subject: [PATCH 01/17] Insurer issue : GWM --- app/Controllers/EnquiryController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Controllers/EnquiryController.php b/app/Controllers/EnquiryController.php index eaa456d..ab71629 100644 --- a/app/Controllers/EnquiryController.php +++ b/app/Controllers/EnquiryController.php @@ -415,6 +415,7 @@ class EnquiryController extends ResourceController ]; + // File updates $idProofFile = $this->request->getFile('id_proof_file_name'); $rcFile = $this->request->getFile('rc_file_name'); @@ -451,6 +452,11 @@ class EnquiryController extends ResourceController $this->enquiryModel->update($id, ['enquiry_status' => 'Assigned']); } + //update insurer data to quotation ( accepted quotation ) + $this->QuotationModel->set([ 'insurer_id' => $data['insurer_id'] ?? $enquiry['insurer_id'],'insurer_branch_id' => $insurerBranchresult['id'] ?? $enquiry['insurer_branch_id']]) + ->where('enquiry_id',$id)->where('status','Accepted') + ->update(); + return $this->respond(['status' => 'success', 'code' => 200, 'message' => 'Enquiry updated successfully'], 200); } catch (\Exception $e) { From eae368228ae0617afcfa0a0c221b3ad2ce1f65c5 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 17:25:13 +0530 Subject: [PATCH 02/17] Insurer issue : GWM --- app/Controllers/PolicyController.php | 114 ++++++++++++++------------- app/Models/PolicyModel.php | 3 +- 2 files changed, 63 insertions(+), 54 deletions(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 05f1211..c31896f 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -180,35 +180,32 @@ class PolicyController extends ResourceController } $updateData = [ - 'quotation_id' => $data['quotation_id'] ?? $policy['quotation_id'], - 'insured_name' => $data['insured_name'] ?? $policy['insured_name'], - 'issued_date' => format_date_for_database($data['issued_date']), - 'start_date' => format_date_for_database($data['start_date']), - 'end_date' => format_date_for_database($data['end_date']), - 'premium_amount' => $data['premium_amount'] ?? $policy['premium_amount'], - 'policy_number' => $data['policy_number'] ?? $policy['policy_number'], - 'payment_mode' => $data['payment_mode'] ?? $policy['payment_mode'], - - // newly added fields - 'tp' => $data['tp'] ?? null, - 'od' => $data['od'] ?? null, - 'pa' => $data['pa'] ?? null, - 'cgst' => $data['cgst'] ?? null, - 'sgst' => $data['sgst'] ?? null, - 'igst' => $data['igst'] ?? null, - 'rto_state_code' => $data['rto_state_code'] ?? null, - 'rto_city_code' => $data['rto_city_code'] ?? null, - 'weight' => $data['weight'] ?? null, - 'fuel_type' => $data['fuel_type'] ?? null, - 'date_of_registration' => !empty($data['date_of_registration']) ? format_date_for_database($data['date_of_registration']) : null, - 'year_of_manufacture' => $data['year_of_manufacture'] ?? null, - 'engine_no' => $data['engine_no'] ?? null, - 'chassis_no' => $data['chassis_no'] ?? null, - 'make' => $data['make'] ?? null, - 'model' => $data['model'] ?? null, - 'cubic_capacity' => $data['cubic_capacity'] ?? null, - 'vehicle_type' => $data['vehicle_type'] ?? null, - 'updated_by' => $data['updated_by'] ?? null + 'insured_name' => $data['insured_name'] ?? $policy['insured_name'], + 'issued_date' => format_date_for_database($data['issued_date']), + 'start_date' => format_date_for_database($data['start_date']), + 'end_date' => format_date_for_database($data['end_date']), + 'premium_amount' => $data['premium_amount'] ?? $policy['premium_amount'], + 'policy_number' => $data['policy_number'] ?? $policy['policy_number'], + 'payment_mode' => $data['payment_mode'] ?? $policy['payment_mode'], + 'tp' => $data['tp'] ?? null, + 'od' => $data['od'] ?? null, + 'pa' => $data['pa'] ?? null, + 'cgst' => $data['cgst'] ?? null, + 'sgst' => $data['sgst'] ?? null, + 'igst' => $data['igst'] ?? null, + 'rto_state_code' => $data['rto_state_code'] ?? null, + 'rto_city_code' => $data['rto_city_code'] ?? null, + 'weight' => $data['weight'] ?? null, + 'fuel_type' => $data['fuel_type'] ?? null, + 'date_of_registration' => !empty($data['date_of_registration']) ? format_date_for_database($data['date_of_registration']) : null, + 'year_of_manufacture' => $data['year_of_manufacture'] ?? null, + 'engine_no' => $data['engine_no'] ?? null, + 'chassis_no' => $data['chassis_no'] ?? null, + 'make' => $data['make'] ?? null, + 'model' => $data['model'] ?? null, + 'cubic_capacity' => $data['cubic_capacity'] ?? null, + 'vehicle_type' => $data['vehicle_type'] ?? null, + 'updated_by' => $data['updated_by'] ?? null ]; $uploadPath = WRITEPATH . 'uploads/policy/'; @@ -240,7 +237,19 @@ class PolicyController extends ResourceController $this->PolicyModel->update($id, $updateData); - // trigger_email('policy_created', ['policy_id' => $id]); + // Call helper to create BDS record after creating client,clientPolicy,vehicle records + $policyData = $this->PolicyModel->select('partner_policy.*,Q.insurer_id,Q.insurer_branch_id,E.name as client_name,E.mobile as client_mobile,E.email as client_email,E.reg_no,E.vehicle_type_id,A.id as agent_id,A.agent_code') + ->join('partner_quotation Q', 'Q.id = partner_policy.quotation_id AND Q.status = "Accepted"', 'left') + ->join('partner_enquiry E', 'E.id = partner_policy.enquiry_id', 'left') + ->join('partner_agent A', 'A.id = partner_policy.agent_id', 'left') + ->where('partner_policy.id',$id) + ->first(); + $bdsLogs = createBDS($policyData, $id); + if (!empty($bdsLogs)) { + foreach ($bdsLogs as $msg) { + log_message('info', '[BDS Entry] ' . $msg); + } + } return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200); @@ -302,10 +311,6 @@ class PolicyController extends ResourceController return $this->respond(['status' => 'success', 'code' => 200, 'data' => $policyId ], 200); } - - - - if (!isset($data['id'])) { @@ -418,6 +423,7 @@ class PolicyController extends ResourceController $policyData['issued_date'] = $data['policy']['issue_date'] ?? null; $policyData['start_date'] = $data['policy']['period']['start'] ?? null; $policyData['end_date'] = $data['policy']['period']['end'] ?? null; + $policyData['broker_name'] = $data['policy']['intermediary_name'] ?? null; $policyData['tp'] = $data['premium']['tp'] ?? null; $policyData['od'] = $data['premium']['od'] ?? null; $policyData['pa'] = $data['premium']['pa'] ?? null; @@ -437,6 +443,8 @@ class PolicyController extends ResourceController $policyData['model'] = $data['vehicle']['model'] ?? null; $policyData['cubic_capacity'] = $data['vehicle']['cubic_capacity'] ?? null; $policyData['vehicle_type'] = $data['vehicle']['vehicle_type'] ?? null; + + log_message('debug', 'Policy Update Payload: ' . json_encode($policyData)); @@ -448,24 +456,24 @@ class PolicyController extends ResourceController $calculateCommission = $this->calculateCommission($policyId); - if($calculateCommission['status'] == 'success') - { - log_message('debug', 'BDS record creating started for ID: '.$policyId); + // if($calculateCommission['status'] == 'success') + // { + // log_message('debug', 'BDS record creating started for ID: '.$policyId); - // Call helper to create BDS record after creating client,clientPolicy,vehicle records - $policyData = $this->PolicyModel->select('partner_policy.*,Q.insurer_id,Q.insurer_branch_id,E.name as client_name,E.mobile as client_mobile,E.email as client_email,E.reg_no,E.vehicle_type_id,A.id as agent_id,A.agent_code') - ->join('partner_quotation Q', 'Q.id = partner_policy.quotation_id AND Q.status = "Accepted"', 'left') - ->join('partner_enquiry E', 'E.id = partner_policy.enquiry_id', 'left') - ->join('partner_agent A', 'A.id = partner_policy.agent_id', 'left') - ->where('partner_policy.id',$policyId) - ->first(); - $bdsLogs = createBDS($policyData, $policyId); - if (!empty($bdsLogs)) { - foreach ($bdsLogs as $msg) { - log_message('info', '[BDS Entry] ' . $msg); - } - } - } + // // Call helper to create BDS record after creating client,clientPolicy,vehicle records + // $policyData = $this->PolicyModel->select('partner_policy.*,Q.insurer_id,Q.insurer_branch_id,E.name as client_name,E.mobile as client_mobile,E.email as client_email,E.reg_no,E.vehicle_type_id,A.id as agent_id,A.agent_code') + // ->join('partner_quotation Q', 'Q.id = partner_policy.quotation_id AND Q.status = "Accepted"', 'left') + // ->join('partner_enquiry E', 'E.id = partner_policy.enquiry_id', 'left') + // ->join('partner_agent A', 'A.id = partner_policy.agent_id', 'left') + // ->where('partner_policy.id',$policyId) + // ->first(); + // $bdsLogs = createBDS($policyData, $policyId); + // if (!empty($bdsLogs)) { + // foreach ($bdsLogs as $msg) { + // log_message('info', '[BDS Entry] ' . $msg); + // } + // } + // } } else { log_message('error', 'Failed to update policy for ID: '.$policyId); @@ -475,7 +483,7 @@ class PolicyController extends ResourceController } - return ['checkPolicyDoc' => $readDoc['status'] , 'calculateCommission' => $calculateCommission['status'] ?? 'failed' , 'createBDS' => 'Started , check log for more details.' ]; + return ['checkPolicyDoc' => $readDoc['status'] , 'calculateCommission' => $calculateCommission['status'] ?? 'failed' ]; } public function checkPolicyDoc($policyId = null , $return = null) @@ -517,7 +525,7 @@ class PolicyController extends ResourceController // The prompt you want to send to the model // $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations"; $prompt = "Read the following motor policy pdf document and convert into JSON format as sample specified. Give me only JSON,not any explanations.while pick up premium break up give own damage, third party ,personal accident and taxes as mentioned in JSON format.Notes:vehicle_type should be like Two Wheeler,Four Feeler,Good Vehicle,Bus, Tractor,Commercial Vehicle.rto_state_code is first two char of reg_no and rto_city_code 3rd & 4th char of reg_no and it should be two digit numeric code. Any date should be in mysql date format"; - $prompt .= '"{\"policy\":{\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"rto_state_code\":\"\",\"rto_city_code\":\"\",\"weight\":\"\",\"fuel_type\":\"\",\"date_of_registration\":\"\",\"year_of_manufacture\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"'; + $prompt .= '"{\"policy\":{\"intermediary_name\":\"\",\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"rto_state_code\":\"\",\"rto_city_code\":\"\",\"weight\":\"\",\"fuel_type\":\"\",\"date_of_registration\":\"\",\"year_of_manufacture\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"'; $payloadPart = null; diff --git a/app/Models/PolicyModel.php b/app/Models/PolicyModel.php index bdbffd6..ba6b2be 100644 --- a/app/Models/PolicyModel.php +++ b/app/Models/PolicyModel.php @@ -48,7 +48,8 @@ class PolicyModel extends Model 'make', 'model', 'cubic_capacity', - 'vehicle_type' + 'vehicle_type', + 'broker_name' ]; protected $useTimestamps = false; From 965ff4db489ea726b02287dc4ca0083a379ba395 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 18:12:17 +0530 Subject: [PATCH 03/17] Insurer issue : GWM --- app/Controllers/PolicyController.php | 6 ++++-- app/Models/PolicyModel.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index c31896f..fe56d18 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -205,7 +205,8 @@ class PolicyController extends ResourceController 'model' => $data['model'] ?? null, 'cubic_capacity' => $data['cubic_capacity'] ?? null, 'vehicle_type' => $data['vehicle_type'] ?? null, - 'updated_by' => $data['updated_by'] ?? null + 'updated_by' => $data['updated_by'] ?? null, + 'is_data_accuracy_checked'=> 1 ]; $uploadPath = WRITEPATH . 'uploads/policy/'; @@ -442,7 +443,8 @@ class PolicyController extends ResourceController $policyData['make'] = $data['vehicle']['make'] ?? null; $policyData['model'] = $data['vehicle']['model'] ?? null; $policyData['cubic_capacity'] = $data['vehicle']['cubic_capacity'] ?? null; - $policyData['vehicle_type'] = $data['vehicle']['vehicle_type'] ?? null; + $policyData['vehicle_type'] = $data['vehicle']['vehicle_type'] ?? null; + $policyData['rc_no'] = $data['vehicle']['reg_no'] ?? null; diff --git a/app/Models/PolicyModel.php b/app/Models/PolicyModel.php index ba6b2be..ba96167 100644 --- a/app/Models/PolicyModel.php +++ b/app/Models/PolicyModel.php @@ -49,7 +49,8 @@ class PolicyModel extends Model 'model', 'cubic_capacity', 'vehicle_type', - 'broker_name' + 'broker_name', + 'is_data_accuracy_checked', ]; protected $useTimestamps = false; From 51648ee9f380c22b1ef00920bac180e6cf8b6dbb Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 18:19:00 +0530 Subject: [PATCH 04/17] validation : GWM --- app/Config/Routes.php | 1 + app/Controllers/PolicyController.php | 45 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index becdca8..08de21a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -116,6 +116,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { $routes->get('policy/downloadPolicyFile', 'PolicyController::downloadPolicyFile'); $routes->post('policy/uploadPolicyFile', 'PolicyController::uploadPolicyFile'); $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); + $routes->get("policy/PolicyFilePath", "PolicyController::PolicyFilePath"); //claims $routes->get('claim/ClaimList', 'ClaimController::ClaimList'); diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index fe56d18..2119298 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -406,6 +406,51 @@ class PolicyController extends ResourceController } } + public function PolicyFilePath() + { + try { + $policyId = $this->request->getGet('policy_id'); + $fileType = $this->request->getGet('file_type'); // policy_pdf , policy_payment_receipt + + if (!$policyId || !$fileType) { + return $this->respond(['status' => 'failed','code' => 400,'data' => 'policy_id and file_type are required'], 200); + } + + // Map file_type to DB column and folder + $fileMap = [ + 'policy_pdf' => ['column' => 'policy_pdf_file_name', 'folder' => 'policy_pdf'], + 'policy_payment_receipt'=> ['column' => 'policy_payment_receipt_file_name', 'folder' => 'policy_payment_receipt'], + ]; + + if (!array_key_exists($fileType, $fileMap)) { + return $this->respond(['status' => 'failed','code' => 400,'data' => 'Invalid file_type'], 200); + } + + $fileColumn = $fileMap[$fileType]['column']; + $folder = $fileMap[$fileType]['folder']; + + // Fetch record from DB + $fileRecord = $this->PolicyModel->where('is_active', 1)->find($policyId); + + if (!$fileRecord || empty($fileRecord[$fileColumn])) { + return $this->respond([ 'status' => 'failed','code' => 404,'data' => 'File not found in database'], 200); + } + + $filePath = WRITEPATH . "uploads/policy/{$folder}/" . $fileRecord[$fileColumn]; + + if (!file_exists($filePath)) { + return $this->respond(['status' => 'failed','code' => 404,'data' => 'File missing on server'], 200); + } + + + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $filePath ], 200); + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'message' => $e->getMessage() ], 500); + } + } + public function readFileAndCalculateCommission(array $data) { $policyId = $data['policy_id']; From 2767a23881765388ac89adc8ae134cf28205eda4 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 18:30:43 +0530 Subject: [PATCH 05/17] validation : GWM --- app/Controllers/PolicyController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 2119298..7457da3 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -180,6 +180,7 @@ class PolicyController extends ResourceController } $updateData = [ + 'rc_no' => $data['rc_no'] ?? $policy['rc_no'], 'insured_name' => $data['insured_name'] ?? $policy['insured_name'], 'issued_date' => format_date_for_database($data['issued_date']), 'start_date' => format_date_for_database($data['start_date']), @@ -205,6 +206,8 @@ class PolicyController extends ResourceController 'model' => $data['model'] ?? null, 'cubic_capacity' => $data['cubic_capacity'] ?? null, 'vehicle_type' => $data['vehicle_type'] ?? null, + 'broker_name' => $data['broker_name'] ?? null, + 'commission_amount' => $data['commission_amount'] ?? null, 'updated_by' => $data['updated_by'] ?? null, 'is_data_accuracy_checked'=> 1 ]; From 3a57d2adabf8789d1ed5b061cd551140216842b6 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 10 Dec 2025 19:08:10 +0530 Subject: [PATCH 06/17] broker : GWM --- app/Controllers/PolicyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 7457da3..a3f48ca 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -333,7 +333,7 @@ class PolicyController extends ResourceController //update enquiry status $quotationData = $this->QuotationModel->where('id',$data['quotation_id'])->first(); if (!empty($quotationData)){ - $enquiryArray = ['vehicle_type_id' => $data['vehicle_type_id'] ?? 0 , 'broker_id' => $data['broker_id'] ?? 0 , 'status'=> 'Policy Created' , 'enquiry_status' => 'Completed' ]; + $enquiryArray = ['status'=> 'Policy Created' , 'enquiry_status' => 'Completed' ]; $this->EnquiryModel->update($quotationData['enquiry_id'], $enquiryArray ); } From c7d68ad680244e7f35c82cf12b2a58c1d458ca68 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 10:26:11 +0530 Subject: [PATCH 07/17] broker : GWM --- app/Controllers/PolicyController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index a3f48ca..7a4dc2c 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -168,7 +168,7 @@ class PolicyController extends ResourceController public function updatePolicy() { try { - $data = $this->request->getPost(); + $data = $this->request->getJSON(true); if (!isset($data['id'])) { return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'ID Required'], 200); } @@ -440,13 +440,14 @@ class PolicyController extends ResourceController } $filePath = WRITEPATH . "uploads/policy/{$folder}/" . $fileRecord[$fileColumn]; + $publicUrl = base_url("uploads/policy/{$folder}/" . $fileRecord[$fileColumn]); if (!file_exists($filePath)) { return $this->respond(['status' => 'failed','code' => 404,'data' => 'File missing on server'], 200); } - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $filePath ], 200); + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $publicUrl ], 200); } catch (\Exception $e) { From 95129d10c16e7eb75b47cbc609794086fd06ca84 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 10:37:37 +0530 Subject: [PATCH 08/17] broker : GWM --- app/Controllers/PolicyController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 7a4dc2c..b2017f9 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -447,7 +447,16 @@ class PolicyController extends ResourceController } - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $publicUrl ], 200); + // return $this->respond(['status' => 'success', 'code' => 200, 'data' => $publicUrl ], 200); + + // Detect the file mime type + $mime = mime_content_type($filePath); + + // Stream file to browser / Flutter + return $this->response + ->setHeader('Content-Type', $mime) + ->setHeader('Content-Disposition', 'inline; filename="' . $fileRecord[$fileColumn] . '"') + ->setBody(file_get_contents($filePath)); } catch (\Exception $e) { From 6a7e60393f013e466ab9153fa27138e5b379701d Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 11:31:07 +0530 Subject: [PATCH 09/17] GWM : --- app/Config/Routes.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 08de21a..99689e0 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -116,7 +116,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { $routes->get('policy/downloadPolicyFile', 'PolicyController::downloadPolicyFile'); $routes->post('policy/uploadPolicyFile', 'PolicyController::uploadPolicyFile'); $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); - $routes->get("policy/PolicyFilePath", "PolicyController::PolicyFilePath"); + //claims $routes->get('claim/ClaimList', 'ClaimController::ClaimList'); @@ -154,6 +154,8 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { }); + $routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath"); + // $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); // $routes->get("dashboard/businessDashboard", "DashboardController::businessDashboard"); // $routes->get("dashboard/partnerDashboard", "DashboardController::partnerDashboard"); From 93d642b270dd54d6b7e3cdbe12b6e5103db2848d Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 12:19:28 +0530 Subject: [PATCH 10/17] GWM : api test --- app/Config/Routes.php | 8 ++ app/Controllers/EnquiryController.php | 7 ++ app/Controllers/PolicyController.php | 101 ++++++++++++++++++++++---- 3 files changed, 101 insertions(+), 15 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 99689e0..6fdba95 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -156,6 +156,14 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { $routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath"); + $routes->group('test', [ ], function ($routes) { + + $routes->get("policyCommissionCalculationAndGeminiPolicyRead", "PolicyController::policyCommissionCalculationAndGeminiPolicyRead"); + + }); + + + // $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies"); // $routes->get("dashboard/businessDashboard", "DashboardController::businessDashboard"); // $routes->get("dashboard/partnerDashboard", "DashboardController::partnerDashboard"); diff --git a/app/Controllers/EnquiryController.php b/app/Controllers/EnquiryController.php index ab71629..f7420fd 100644 --- a/app/Controllers/EnquiryController.php +++ b/app/Controllers/EnquiryController.php @@ -700,6 +700,13 @@ class EnquiryController extends ResourceController ])->setStatusCode(400); } + if ($reg_no == 'New' || $reg_no == 'new' || $reg_no == 'NEW') { + return $this->response->setJSON([ + "status" => "not exists", + "message" => "No active record found for this vehicle number in enquiries." + ]); + } + // --- 2. Step 1: Check in partner_enquiry (Active/Latest Record) --- // Get the LATEST ACTIVE enquiry record for the registration number $enquiry = $this->db->table("partner_enquiry") diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index b2017f9..779ae96 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -568,7 +568,12 @@ class PolicyController extends ResourceController // Check if the file exists if (!file_exists($filePath)) { log_message('info',"Error: File not found at {$filePath}"); - return ['status'=>"failed", 'message'=> "File not found at {$filePath}"]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "File not found at {$filePath}"], 200); + }else{ + return ['status'=>"failed", 'message'=> "File not found at {$filePath}"]; + } } // Get the file's MIME type using the finfo extension @@ -665,7 +670,12 @@ class PolicyController extends ResourceController if (curl_errno($ch)) { $curl_error = curl_error($ch); log_message('info',"cURL Error: " . $curl_error); - return ['status'=>"failed", 'message'=> "cURL Error: " . $curl_error]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "cURL Error: " . $curl_error], 200); + }else{ + return ['status'=>"failed", 'message'=> "cURL Error: " . $curl_error]; + } } $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); @@ -675,7 +685,12 @@ class PolicyController extends ResourceController // Check for non-successful HTTP status codes if ($http_code < 200 || $http_code >= 300) { log_message('info',"API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)); - return ['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)], 200); + }else{ + return ['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)]; + } } // Decode the JSON response @@ -704,7 +719,12 @@ class PolicyController extends ResourceController if (empty($json_string)) { log_message('info',"Could not extract a valid JSON string from the generated text."); - return ['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."], 200); + }else{ + return ['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."]; + } } // Decode the extracted JSON string @@ -712,11 +732,24 @@ class PolicyController extends ResourceController log_message('info', "Extracted and decoded final JSON data successfully."); - return ['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data]; + if($return == true) + { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $final_data ], 200); + }else + { + return ['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data]; + } + + } else { log_message('info',"Response structure invalid or no generated text candidate found."); - return ['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"], 200); + }else{ + return ['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"]; + } } } catch (\Exception $e) { @@ -725,12 +758,17 @@ class PolicyController extends ResourceController // curl_close($ch); // } log_message('error', "Fatal Error: " . $e->getMessage()); - return ['status'=>"failed", 'message'=> "Error: " . $e->getMessage()]; + if($return == true) + { + return $this->respond(['status'=>"failed", 'message'=> "Error: " . $e->getMessage()], 200); + }else{ + return ['status'=>"failed", 'message'=> "Error: " . $e->getMessage()]; + } } } - public function calculateCommission($policyId = null) + public function calculateCommission($policyId = null , $return = null) { log_message('debug', 'calculateCommission() started with policyId: ' . $policyId); @@ -799,7 +837,13 @@ class PolicyController extends ResourceController if ($error) { log_message('error', 'cURL Error: ' . $error); - return ['status'=>"failed", 'message'=> 'cURL Error: ' . $error]; + if($return == true) + { + return $this->respond( ['status'=>"failed", 'message'=> 'cURL Error: ' . $error], 200); + }else{ + return ['status'=>"failed", 'message'=> 'cURL Error: ' . $error]; + } + } else { log_message('debug', 'API Response: ' . $response); @@ -819,21 +863,48 @@ class PolicyController extends ResourceController log_message('debug', 'Updating Policy (ID=75) With: ' . json_encode($policyData)); - // Update record - $this->PolicyModel->update($policyId, $policyData); + if($return == true) + { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $policyData ], 200); + }else{ + // Update record + $this->PolicyModel->update($policyId, $policyData); + log_message('debug', 'Policy update successful!'); + return ['status'=>"success", 'message'=> "Commission Updated!"]; + } - log_message('debug', 'Policy update successful!'); - - return ['status'=>"success", 'message'=> "Commission Updated!"]; + } else { log_message('debug', 'calculateCommission() - Invalid API Response'); - return ['status'=>"failed", 'message'=> "Invalid API Response!"]; + if($return == true) + { + return $this->respond( ['status'=>"failed", 'message'=> "Invalid API Response!"], 200); + }else{ + return ['status'=>"failed", 'message'=> "Invalid API Response!"]; + } } } } + public function policyCommissionCalculationAndGeminiPolicyRead() + { + + $type = $this->request->getGet('type'); + $policyId = $this->request->getGet('policy_id'); + + if($type == 'commission') + { + return $this->calculateCommission($policyId , true); + + }else if($type == 'read') + { + return $this->checkPolicyDoc($policyId , true); + } + + } + public function searchThePolicies() { From 34c3092db045eb24d9e18f85dbb188b84609d300 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 12:27:09 +0530 Subject: [PATCH 11/17] GWM : api test --- app/Controllers/PolicyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 779ae96..936a721 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -799,7 +799,7 @@ class PolicyController extends ResourceController "premium" => $record['premium_amount'], "od_premium" => $record['od'], "tp_premium" => $record['tp'], - "cubic_capcity" => $record['cubic_capacity'], + "cubic_capacity" => $record['cubic_capacity'], "weight" => $record['weight'], "make" => $record['make'], "model" => $record['model'], From df3f5c69716d3c0484f3d37e31e6b0e7d1f1f08e Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 12:37:57 +0530 Subject: [PATCH 12/17] GWM : api test --- app/Controllers/PolicyController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 936a721..b84349b 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -772,7 +772,7 @@ class PolicyController extends ResourceController { log_message('debug', 'calculateCommission() started with policyId: ' . $policyId); - $record = $this->PolicyModel->select('partner_policy.* , pe.insurer_id , VT.vehicle_type , ipti.insurance_plan_type,') + $record = $this->PolicyModel->select('partner_policy.* , pe.insurer_id , VT.vehicle_type as vehicle_type_master , ipti.insurance_plan_type,') ->join('partner_enquiry pe', 'pe.id = partner_policy.enquiry_id', 'left') ->join('vehicle_type VT', 'VT.id = pe.vehicle_type_id', 'left') ->join('partner_quotation pq', 'pq.id = partner_policy.quotation_id', 'left') @@ -853,6 +853,11 @@ class PolicyController extends ResourceController // Optional: Debug API result // print_r($result); + if($return == true) + { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result , 'payload' => $postData ], 200); + } + if (!empty($result) && isset($result['success']) && $result['success'] === true) { // Safely extract values From e1162fcfa83b4466ccfa8d0aaed08a4bb29aae0e Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 13:13:24 +0530 Subject: [PATCH 13/17] GWM : api test --- app/Controllers/PolicyController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index b84349b..686cbc3 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -772,11 +772,13 @@ class PolicyController extends ResourceController { log_message('debug', 'calculateCommission() started with policyId: ' . $policyId); - $record = $this->PolicyModel->select('partner_policy.* , pe.insurer_id , VT.vehicle_type as vehicle_type_master , ipti.insurance_plan_type,') + $record = $this->PolicyModel->select('partner_policy.* , rto_state.rto_state_name as rto_state_code , ,pe.insurer_id , VT.vehicle_type as vehicle_type_master , ipti.insurance_plan_type,') ->join('partner_enquiry pe', 'pe.id = partner_policy.enquiry_id', 'left') ->join('vehicle_type VT', 'VT.id = pe.vehicle_type_id', 'left') ->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') + ->join('rto_master rto_state', 'rto_state.rto_state = partner_policy.rto_state_code', 'left') + // ->join('rto_master rto_city', 'rto_city.rto_code = partner_policy.rto_city_code', 'left') ->where('partner_policy.id', $policyId) ->first(); From 4edf49d849239f2d56f2364dc71d1830763f13d3 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 11 Dec 2025 18:00:00 +0530 Subject: [PATCH 14/17] GWM : Merge --- app/Config/Routes.php | 4 ++-- app/Controllers/PolicyController.php | 4 ++-- app/Models/EnquiryModel.php | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6fdba95..f24d266 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -27,7 +27,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { //api's with token - $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) { +// $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) { //logout $routes->get('auth/logout', 'StaffAuthController::logout'); @@ -152,7 +152,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { - }); +// }); $routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath"); diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 686cbc3..4ab6a29 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -782,9 +782,9 @@ class PolicyController extends ResourceController ->where('partner_policy.id', $policyId) ->first(); - $apiUrl = "https://venbait.in/nhance/dev/getCommission"; + $apiUrl = env('COMMISSION_CALCULATION_URL'); - $token = "A7fP3xQ9mD2vT6sR1bW8kJ4yC0gN5zH3uL9pE2rF7cV1tX6hB0qM4dG8nS5aU3jK7"; + $token = env('COMMISSION_CALCULATION_TOKEN'); $manufactureYear = (int) $record['year_of_manufacture']; $currentYear = (int) date("Y"); diff --git a/app/Models/EnquiryModel.php b/app/Models/EnquiryModel.php index b4c43bd..e969bb0 100644 --- a/app/Models/EnquiryModel.php +++ b/app/Models/EnquiryModel.php @@ -53,11 +53,13 @@ class EnquiryModel extends Model P.policy_number, P.id as policy_id, P.policy_pdf_file_name, + P.is_data_accuracy_checked, PB.name as broker_name, pm.id as payment_mode_id , pm.value as payment_mode_value, ipti.insurance_plan_type ') + ->select('CASE WHEN P.client_id IS NOT NULL THEN 1 ELSE 0 END AS is_bds_pushed', false) ->join('vehicle_type VT', 'VT.id = partner_enquiry.vehicle_type_id', 'left') ->join('partner_agent A', 'A.id = partner_enquiry.agent_id', 'left') ->join('partner_staff S', 'S.id = partner_enquiry.assigned_to', 'left') From 436ee4357cbaa5596899ef9301ab37dfcd1b1c85 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 12 Dec 2025 10:54:06 +0530 Subject: [PATCH 15/17] GWM : commission --- app/Models/PolicyModel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/PolicyModel.php b/app/Models/PolicyModel.php index ba96167..19a0365 100644 --- a/app/Models/PolicyModel.php +++ b/app/Models/PolicyModel.php @@ -50,6 +50,7 @@ class PolicyModel extends Model 'cubic_capacity', 'vehicle_type', 'broker_name', + 'commission_amount', 'is_data_accuracy_checked', ]; From 5dfab1ad12480b6e2b240ec749ada8925c8a4a62 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 12 Dec 2025 11:00:39 +0530 Subject: [PATCH 16/17] GWM : commission --- app/Controllers/PolicyController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index 4ab6a29..b3bb805 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -782,9 +782,9 @@ class PolicyController extends ResourceController ->where('partner_policy.id', $policyId) ->first(); - $apiUrl = env('COMMISSION_CALCULATION_URL'); + $apiUrl = getenv('COMMISSION_CALCULATION_URL'); - $token = env('COMMISSION_CALCULATION_TOKEN'); + $token = getenv('COMMISSION_CALCULATION_TOKEN'); $manufactureYear = (int) $record['year_of_manufacture']; $currentYear = (int) date("Y"); From 5a53b0aa895386185a7e659c21a93ee03b1784f4 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 12 Dec 2025 11:05:14 +0530 Subject: [PATCH 17/17] GWM : route issue --- app/Config/Routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f24d266..6fdba95 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -27,7 +27,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { //api's with token -// $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) { + $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) { //logout $routes->get('auth/logout', 'StaffAuthController::logout'); @@ -152,7 +152,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { -// }); + }); $routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath");