From dbfd5500f94794e79e9efd026c3c7baf8a2107fc Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 5 Aug 2025 10:43:59 +0530 Subject: [PATCH 01/10] CHANGE_CARRY_FORWORD_PREMIUM_AMT_TO BDS : RV --- app/Controllers/ClientController.php | 44 ++-- app/Controllers/EmpDataServiceController.php | 212 +++++++++++++++++-- app/Models/EmployeePolicyModel.php | 5 + 3 files changed, 213 insertions(+), 48 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index bff1d34f..a61d0917 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5079,44 +5079,30 @@ class ClientController extends AdminController // $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126); // $dashBoardController->sendRemainderMail($client_policy_data); - // $EmpDataServiceController = new EmpDataServiceController(); // $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12); // $ids = array_column($emp_data, 'id'); - // $EmpDataServiceController->sendMailForDownloadingECard($ids); $EmpDataServiceController = new EmpDataServiceController(); - // $return = $EmpDataServiceController->generateExcelForDeletion($batch_data); dd($return); die; - // $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die; - // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 1932]); die; - // $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live - // $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live - // $result = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live - // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live - - // $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data, 1); dd($result); - // $result = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1); + // $res = $EmpDataServiceController->generateExcelForDeletion($batch_data); dd($return); die; + // $res = $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die; + // $res = $EmpDataServiceController->importInceptionFileValidation(['file_id' => 1932]); die; + // $res = $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live + // $res = $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live + // $res = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live + // $res = $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live + // $res = $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 310]); dd($res);//for live + // $res = $EmpDataServiceController->getInceptionBasePremium(["13332","13333","13334","13335","13336"]); dd($res);//for live + // $res = $EmpDataServiceController->getDeletionBasePremium(["13248","13250","13249","13247"], json_decode('{"employeeIds":["13248","13250","13249","13247"],"client_id":"3927","client_policy_id":"6183","client_branch_id":"1874","cd_ac_no":"CD9751909505","endorsement_no":"END1238","count":4,"event_name":"deletion","policy_name":"GMC","user_id":"48"}', true)); dd($res);//for live + // $res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction(json_decode('{"client_policy_id":"6187","endorsement_no":null,"emp_count":5,"action_type":"inception","no_of_insured":3,"no_of_dependent":0}', true)); dd($res);//for live + // $res = $EmpDataServiceController->sendMailForDownloadingECard($ids); + // $res = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data, 1); dd($result); + // $res = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1); // return $this->downloadInsurerExcelExport($batch_data); - // dd($result); die; - - // $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']); + // dd($res); die; // $PolicyTransactionController = new PolicyTransactionController(); // $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']); - // $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->excelFileDataValidation(['file_id' => '1101']); - // dd($res); - - // $EmpDataServiceController = new EmpDataServiceController(); - // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]); - - // $EmpDataServiceController = new EmpDataServiceController(); - // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]); - // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]); - // $EmpDataServiceController->importDeletionValidation(['file_id' => 171]); - // $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]); - // $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]); // $params = [ // 'client_policy_id' => 6090, diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 6da138fd..38a7e190 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -43,6 +43,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader\Exception as SpreadsheetReaderException; use PhpParser\Node\Expr\Cast\Double; +use Kint\Kint; use function PHPUnit\Framework\returnSelf; @@ -1576,6 +1577,7 @@ class EmpDataServiceController extends BaseController if ($insurer_or_tpa == 'tpa' && in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])) { + //verify the TPA ID is not null if ($excel_data[$key][13] === null) { $missing_id[$key][] = [ 'row' => $key, @@ -1585,6 +1587,8 @@ class EmpDataServiceController extends BaseController ]; } } else if ($insurer_or_tpa == 'insurer') { + + //verify the UHID or Risk ID is not null if ($excel_data[$key][14] === null) { $missing_id[$key][] = [ 'row' => $key, @@ -1716,7 +1720,7 @@ class EmpDataServiceController extends BaseController ]; } - if ($insurer_or_tpa == 'tpa' && in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])) { + if ($insurer_or_tpa == 'tpa') { if ($emp_value['uhid'] != $excel_data[$key][14]) { $errors[$key][] = [ @@ -1895,6 +1899,9 @@ class EmpDataServiceController extends BaseController $emp_endorsement_table_data = []; $enrollment_file_id = null; $endorsement_id = null; + $no_of_insured = []; + $no_of_dependent = []; + $emp_count = count($excel_data); $db = \Config\Database::connect(); @@ -1914,7 +1921,7 @@ class EmpDataServiceController extends BaseController $totals = $totals + floatval($amount); $query = $db->table('employee_polices'); - $query->select('employee_polices.id'); + $query->select('employee_polices.id, employees.id as emp_id, employees.emp_code, employees.name as emp_name, employees.relationship'); $query->join('employees', 'employees.id = employee_polices.employee_id'); $query->where('employee_polices.client_policy_id', $client_policy_id); $query->where('employees.client_id', $client_id); @@ -1935,11 +1942,20 @@ class EmpDataServiceController extends BaseController $query->limit(1); $result = $query->get()->getRowArray(); + // Kint::dump($result); + if (isset($result['id']) && $result['id'] !== null) { $emp_policy_ids[] = $result['id']; //for cash deposite $emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[13], 'uhid' => $value[14]); + if (strtolower($result['relationship']) == 'self') { + $no_of_insured[] = ['emp_id' => $result['emp_id'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + }else{ + $no_of_dependent[] = ['emp_id' => $result['emp_id'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + } } + + if(in_array($file['event_type'], ['missed_inception']) && isset($value[18])){ $endorsement_id = $value[18]; @@ -2001,7 +2017,7 @@ class EmpDataServiceController extends BaseController } - // dd($emp_endorsement_table_data, $enrollment_file_id); + // dd($emp_endorsement_table_data, $enrollment_file_id, $no_of_insured, $no_of_dependent); //update the employee policy data (TPAID or UHID) $return = $this->employeePolicyModel->bulkUpdate($emp_details); @@ -2021,6 +2037,10 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme('error', 'Inception Update TPA and UHID -- batch file status : {data}', ['data' => $status_val]); $this->myLogger->logme('error', 'Inception Update TPA and UHID -- total amount for cash deposite : {data}', ['data' => $totals]); + //get the BASE PREMIUM and GST for BDS Entry + $base_bremium_and_gst = $this->getInceptionBasePremium($emp_policy_ids); + $this->myLogger->logme('error', 'Inception Base Premium and GST :'. json_encode($base_bremium_and_gst ?? [])); + //update CD transaction entry if only insurer if ($file['insurer_or_tpa'] == 'insurer') { @@ -2063,6 +2083,10 @@ class EmpDataServiceController extends BaseController 'endorsement_no' => $endorsement_id ?? null, 'emp_count' => $emp_count ?? null, 'action_type' => $file['event_type'] ?? null, + 'no_of_insured' => count($no_of_insured ?? []) ?? null, + 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + 'gst' => $base_bremium_and_gst['gst'] ?? null, ]]); // $this->cashDepositCalculationForInception($depositeData); @@ -3005,6 +3029,8 @@ class EmpDataServiceController extends BaseController $endorsement_id = ''; $enrollment_file_id = ''; $endorsement_details = []; + $no_of_insured = []; + $no_of_dependent = []; $totals = 0; foreach ($excel_data as $key => $value) { @@ -3017,7 +3043,14 @@ class EmpDataServiceController extends BaseController $result = $this->empEndorsementModel - ->select('emp_endorsement.*, employees.id as emp_id, employee_polices.id as emp_policy_id') + ->select(' + emp_endorsement.*, + employees.id as emp_id, + employees.name as emp_name, + employees.emp_code, + employees.relationship, + employee_polices.id as emp_policy_id + ') ->join('employee_polices', 'employee_polices.id = emp_endorsement.pk') ->join('employees', 'employees.emp_code = emp_endorsement.emp_code') ->where('employees.emp_code', $emp_code) @@ -3043,6 +3076,11 @@ class EmpDataServiceController extends BaseController $emp_policy_ids[] = array('id' => $result['emp_policy_id'], 'is_active' => 0); $employeeIds[] = $result['emp_policy_id']; $endorsement_details[] = array('id' => $result['id'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[19], 'status' => 'complete'); + if (strtolower($result['relationship']) == 'self') { + $no_of_insured[] = ['emp_id' => $result['emp_id'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + }else{ + $no_of_dependent[] = ['emp_id' => $result['emp_id'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + } } $empData = $this->employeePolicyModel @@ -3110,6 +3148,11 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]); $this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]); + //get the BASE PREMIUM and GST for BDS Entry + $base_bremium_and_gst = $this->getInceptionBasePremium($employeeIds); + $this->myLogger->logme('error', 'SI Enhancement Base Premium and GST :'. json_encode($base_bremium_and_gst ?? [])); + + //call the cash deposite function if ($file['insurer_or_tpa'] == 'insurer') { @@ -3133,6 +3176,10 @@ class EmpDataServiceController extends BaseController 'endorsement_no' => $endorsement_id ?? null, 'emp_count' => $emp_count ?? null, 'action_type' => $file['event_type'] ?? null, + 'no_of_insured' => count($no_of_insured ?? []) ?? null, + 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + 'gst' => $base_bremium_and_gst['gst'] ?? null, ]]); } @@ -3521,6 +3568,8 @@ class EmpDataServiceController extends BaseController $employee_policy_table_primaryKey = []; $endorsement_id = ''; $enrollment_file_id = null; //files table primary key + $no_of_insured = []; + $no_of_dependent = []; $totals = 0; @@ -3554,6 +3603,12 @@ class EmpDataServiceController extends BaseController $employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => change_date_format($result['date_of_exit']), 'reason_for_exit' => $result['reason_for_exit'], 'claim_status' => $result['claim_status'], 'status' => $result['status']); // $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']); $emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete'); + + if (strtolower($result['relationship']) == 'self') { + $no_of_insured[] = ['emp_id' => $result['employees_primarykey'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + }else{ + $no_of_dependent[] = ['emp_id' => $result['employees_primarykey'], 'emp_code' => $result['emp_code'], 'emp_name' => $result['emp_name'] ]; + } } } @@ -3603,6 +3658,9 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]); $this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]); + $base_bremium_and_gst = $this->getDeletionBasePremium($employee_policy_table_primaryKey, ['client_policy_id' => $client_policy_id]); + $this->myLogger->logme('error', 'Deletion Base Premium and GST :'. json_encode($base_bremium_and_gst ?? [])); + //call the cash deposite function if ($file['insurer_or_tpa'] == 'insurer') { @@ -3626,6 +3684,10 @@ class EmpDataServiceController extends BaseController 'endorsement_no' => $endorsement_id ?? null, 'emp_count' => $emp_count ?? null, 'action_type' => $file['event_type'] ?? null, + 'no_of_insured' => count($no_of_insured ?? []) ?? null, + 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + 'gst' => $base_bremium_and_gst['gst'] ?? null, ]]); } @@ -4290,8 +4352,6 @@ class EmpDataServiceController extends BaseController } - - /** * Below function retrieves the policy name associated with a given client policy ID. * @@ -4308,8 +4368,6 @@ class EmpDataServiceController extends BaseController } - - /** * Below function converts row data into column data format for SI enhancement. * @@ -4866,8 +4924,8 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme("error", "Policy transaction inserted successfully: " . json_encode(['insert_id' => $insert_id])); //do not remove this commented item - // $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id); - // $pt_co_share_id = $this->PTCOShareDetailsModel->insert($coShareDetails); + $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id, $params); + $pt_co_share_id = $this->PTCOShareDetailsModel->insert($coShareDetails); // $this->myLogger->logme("error", "PT Co share data inserted successfully: " . json_encode(['pt_co_share_id' => $pt_co_share_id])); @@ -4903,11 +4961,12 @@ class EmpDataServiceController extends BaseController private function constructBDSData($policy_data, $lead_data, $params) { - + + $this->myLogger->logme("error", "constructBDSData Params: " . json_encode(['policy_data' => $policy_data, 'lead_data' => $lead_data, 'params' => $params])); $action_type_string = $params['action_type']; - if(in_array($params['action_type'], ['dependent_addition', 'missed_inception'])){ + if(in_array($params['action_type'], ['dependent_addition', 'missed_inception'])){ $action_type_string = "addition"; - } + } $policyTransactionData = [ @@ -4928,9 +4987,9 @@ class EmpDataServiceController extends BaseController 'policy_end_date' => $policy_data['policy_end_date'] ?? null, 'data_received_date' => $policy_data['data_received_date'] ?? null, 'closure_date' => $policy_data['closure_date'] ?? null, - 'emp_count' => $policy_data['emp_count'] ?? null, - 'dependent_count' => $policy_data['dependent_count'] ?? null, - 'revenue_type' => ($lead_data['lead_type'] == 1 ? "NA" : ($lead_data['lead_type'] == 2 ? "EA" : "EANR") ) ?? null, + 'emp_count' => $params['no_of_insured'] ?? null, + 'dependent_count' => $params['no_of_dependent'] ?? null, + 'revenue_type' => isset($lead_data['lead_type']) ?($lead_data['lead_type'] == 1 ? "NA" : ($lead_data['lead_type'] == 2 ? "EA" : "EANR") ) : null, 'co_share' => $policy_data['co_share'] ?? 0, 'pre_payable_by' => $policy_data['pre_payable_by'] ?? 1, 'renewal_date' => $policy_data['policy_end_date'] ?? null, @@ -4939,7 +4998,8 @@ class EmpDataServiceController extends BaseController 'is_cd_reduce_from_bds' => 0, 'client_type_id' => 0, - 'status' => "co_insurer_pending", + // 'status' => "co_insurer_pending", + 'status' => "completed", 'action_type' => $action_type_string ?? null, 'endorsement_no' => $params['endorsement_no'] ?? null, @@ -4954,18 +5014,23 @@ class EmpDataServiceController extends BaseController return $policyTransactionData; } - private function ConstructPTShareData($policy_data, $pt_id) + private function ConstructPTShareData($policy_data, $pt_id, $params) { $coShareData = [ 'pt_id' => $pt_id, 'insurer_id' => $policy_data['insurer_id'], 'insurer_branch_id' => $policy_data['insurer_branch_id'], + 'bp_amt' => $params['base_premium'], + 'cop_amt' => $params['base_premium'], + 'bp_gst_amt' => $params['gst'], + 'bp_sgst' => 9, + 'bp_cgst' => 9, 'co_share_type' => 1, + 'co_share_per' => 100, ]; $this->myLogger->logme("error", "Constructed PT co-share data: " . json_encode($coShareData)); - return $coShareData; } @@ -5113,8 +5178,117 @@ class EmpDataServiceController extends BaseController } + // -------------------------------------------------------------------------------------------------------------------------------- + + public function getInceptionBasePremium($ids) + { + $this->myLogger->logme('error', 'getInceptionBasePremium called with the params : ' . json_encode($ids ?? "")); + + // Validate input + if (empty($ids) || !is_array($ids)) { + return ['base_premium' => 0, 'gst' => 0]; + } + // Sanitize IDs to ensure they are integers + $sanitizedIds = array_filter(array_map('intval', $ids), function ($id) { + return $id > 0; + }); + if (empty($sanitizedIds)) { + return ['base_premium' => 0, 'gst' => 0]; + } + // Use parameter binding for security + $placeholders = str_repeat('?,', count($sanitizedIds) - 1) . '?'; + $amount = $this->employeePolicyModel->query(" + SELECT SUM(employee_polices.rata_premimum) AS base_premium, + SUM(employee_polices.gst) AS gst + FROM employee_polices + JOIN employees ON employees.id = employee_polices.employee_id + WHERE employee_polices.id IN ($placeholders) + ", $sanitizedIds)->getRowArray(); + + $this->myLogger->logme('error', 'Get Last Executed Query : '.db_connect()->getLastQuery()); + + // Ensure we return proper numeric values + return [ + 'base_premium' => round($amount['base_premium'] ?? 0, 2), + 'gst' => round($amount['gst'] ?? 0, 2) + ]; + } + + public function getDeletionBasePremium($ids, $params) + { + $this->myLogger->logme('error', 'getDeletionBasePremium called with the params : ' . json_encode(['emp_policy_id' => $ids ?? [], 'params' => $params ?? []] ?? "")); + + // Validate input + if (empty($ids) || !is_array($ids)) { + return ['base_premium' => 0, 'gst' => 0]; + } + + // Sanitize IDs to ensure they are integers + $sanitizedIds = array_filter(array_map('intval', $ids), function ($id) { + return $id > 0; + }); + + if (empty($sanitizedIds)) { + return ['base_premium' => 0, 'gst' => 0]; + } + + // Validate client_policy_id parameter + if (empty($params['client_policy_id'])) { + return ['base_premium' => 0, 'gst' => 0]; + } + + $get_insurer_id_from_client_policy = $this->clientPolicyModel + ->select('insurers.deletion_add_day') + ->join('insurers', 'client_policy.insurer_id = insurers.id') + ->where('client_policy.id', intval($params['client_policy_id'])) + ->first(); + + $add_one_day = 0; + if (isset($get_insurer_id_from_client_policy['deletion_add_day']) && $get_insurer_id_from_client_policy['deletion_add_day'] == 1) { + $add_one_day = 1; + } + + // Use parameter binding for security + $placeholders = str_repeat('?,', count($sanitizedIds) - 1) . '?'; + + // Prepare parameters array (ids repeated twice for both IN clauses) + $queryParams = array_merge($sanitizedIds, $sanitizedIds); + + $amount = $this->employeePolicyModel->query(" + SELECT + SUM(ROUND( + ((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, emp_endorsement.new_value) + ?)) / 365), + 2 + )) AS base_premium, + SUM(ROUND( + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, emp_endorsement.new_value) + ?)) / 365) * 0.18), + 2 + )) AS gst + FROM + employee_polices + JOIN + employees ON employees.id = employee_polices.employee_id + JOIN + emp_endorsement ON emp_endorsement.pk = employee_polices.id + WHERE + employee_polices.id IN ($placeholders) + AND emp_endorsement.pk IN ($placeholders) + AND employee_polices.claim_status = 0 + AND emp_endorsement.field_name = 'date_of_exit' + AND emp_endorsement.is_active = 1 + AND emp_endorsement.actions = 'd' + AND emp_endorsement.status != 'truncated' + ", array_merge([$add_one_day, $add_one_day], $queryParams))->getRowArray(); + + $this->myLogger->logme('error', 'Get Last Executed Query : '.db_connect()->getLastQuery()); + // Ensure we return proper numeric values with rounding + return [ + 'base_premium' => round($amount['base_premium'] ?? 0, 2), + 'gst' => round($amount['gst'] ?? 0, 2) + ]; + } } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index e6b02543..82a8cb3b 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1251,6 +1251,9 @@ class EmployeePolicyModel extends Model ee.id as emp_endorsement_primarykey, ep.id as emp_policy_primarykey, e.id as employees_primarykey, + e.relationship, + e.emp_code, + e.name as emp_name, ee.file_id, ee.group_key, ( @@ -2098,4 +2101,6 @@ class EmployeePolicyModel extends Model // var_dump($this->db->getLastQuery()); return $data; } + + } \ No newline at end of file From 742f81e7ce86ad36b67d35bd5d1de2333e94726e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 5 Aug 2025 11:42:25 +0530 Subject: [PATCH 02/10] CHANGE_STATEMENT_UPLOAD_BDS_CRS : RV --- app/Controllers/ClientController.php | 6 +++--- .../PolicyTransactionController.php | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index a61d0917..c2c94c0f 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5100,9 +5100,9 @@ class ClientController extends AdminController // return $this->downloadInsurerExcelExport($batch_data); // dd($res); die; - // $PolicyTransactionController = new PolicyTransactionController(); - // $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']); - + $PolicyTransactionController = new PolicyTransactionController(); + $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '131']); + dd($res); // $params = [ // 'client_policy_id' => 6090, diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 3d9ee4f6..cd08d50d 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2279,7 +2279,9 @@ class PolicyTransactionController extends BaseController // if all good return true, otherwise return false with messssage foreach ($excel_data as $excel_key => $excel_row) { $is_row_empty = check_row_is_empty_or_null($excel_row); + if (!$is_row_empty) { + // $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row); $is_source_found = 0; // Kint::dump($excel_key,$excel_row[1],$excel_row[2]); @@ -2297,8 +2299,17 @@ class PolicyTransactionController extends BaseController // Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die(); foreach ($source_data as $source_key => $source_row) { $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - // Kint::dump($source_endorsement_no); - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) + // Kint::dump($source_row, $source_endorsement_no, $policy_no, $endorsement_no); + + // if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) + // { + // $is_source_found = 1; + // $line_items = $line_items + 1; + // unset($source_data[$source_key]); + // continue 2; + // } + + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { $is_source_found = 1; $line_items = $line_items + 1; @@ -2395,7 +2406,8 @@ class PolicyTransactionController extends BaseController foreach ($source_data as $source_key => $source_row) { // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { + // if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { $is_source_found = 1; //calculate percentage first From 4a02c5c630e60ed885fcbfcbcdd199d0ff5a66b1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 5 Aug 2025 15:31:10 +0530 Subject: [PATCH 03/10] CHANGE_BDS_CRS : RV --- app/Controllers/ClientController.php | 22 ++++++--------- app/Views/newClientModal.php | 2 +- .../policy_transaction_inception_form.php | 10 +++++-- .../policy_transaction_inception_list.php | 28 +++++++++++++------ 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index c2c94c0f..f7bb29ba 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4213,7 +4213,7 @@ class ClientController extends AdminController $client_data = [ 'client_type' => $postData['client_type'], 'client_name' => $postData['client_name'], - 'short_name' => $postData['short_name'], + 'short_name' => $postData['short_name'] ?? $postData['client_name'], 'pan' => $postData['pan'], 'client_code' => generate_client_code(), ]; @@ -5031,24 +5031,24 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- - $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->excelFileDataValidation(['file_id' => 1629]); die; - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 726]); - // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); - // $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); - // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); $empServiceController = new EmployeeServiceController(); // $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']); // $res = $empServiceController->excelFileDataValidation(['file_id' => '865']); + // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]); + // $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]); + // $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]); // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']); - // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); dd( $res); + // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); + // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '1681']); + // dd( $res); + + // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']); // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']); // dd('-----', $res); - // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- $batch_data = [ @@ -5100,10 +5100,6 @@ class ClientController extends AdminController // return $this->downloadInsurerExcelExport($batch_data); // dd($res); die; - $PolicyTransactionController = new PolicyTransactionController(); - $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '131']); - dd($res); - // $params = [ // 'client_policy_id' => 6090, // 'action_type' => "inception", diff --git a/app/Views/newClientModal.php b/app/Views/newClientModal.php index 7343571a..dfe4d66a 100644 --- a/app/Views/newClientModal.php +++ b/app/Views/newClientModal.php @@ -86,7 +86,7 @@
- +
diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 2d15e411..4c99fe7a 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1399,6 +1399,9 @@ $(document).ready(function(){ $('#email2').prop('required', true); $('#aadhar').prop('required', true); + $('#short_name').closest('.form-group').hide(); + $('#short_name').removeAttr('required'); + } else { $('.branchdiv').show(); @@ -1408,7 +1411,7 @@ $(document).ready(function(){ $('#client_branch_id').prop('required', true); $('#branch_code').prop('required', true); $('#name').prop('required', true); - $('#mobile').prop('required', true); + $('#mobile').prop('required', false); $('#gst').prop('required', true); $('#email').prop('required', true); @@ -1417,6 +1420,9 @@ $(document).ready(function(){ $('#email2').prop('required', false); $('#aadhar').prop('required', false); + $('#short_name').closest('.form-group').show(); + $('#short_name').attr('required', 'required'); + } var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model')); @@ -3713,7 +3719,7 @@ $('#client_type').change(function() { $('#client_branch_id').prop('required', true); $('#branch_code').prop('required', true); $('#name').prop('required', true); - $('#mobile').prop('required', true); + $('#mobile').prop('required', false); $('#gst').prop('required', true); $('#email').prop('required', true); diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index 59218b46..cec7a681 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -188,9 +188,9 @@ table.dataTable tbody td {
-
+
@@ -217,7 +214,13 @@ table.dataTable tbody td { } ?> -
+
+ + + +
+ +
@@ -1216,6 +1219,15 @@ $(document).ready(function(){ if($('#client_type').val()){ $('#client_id').val('').change(); + + if($('#client_type').val() == 2){ + $('#short_name').closest('.form-group').hide(); + $('#short_name').removeAttr('required'); + } else { + $('#short_name').closest('.form-group').show(); + $('#short_name').attr('required', 'required'); + } + var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model')); myModal.show(); }else{ @@ -1512,7 +1524,7 @@ function fetchEmpolyeeList(event) var insurer_id = $('#insurer_id_for_search').val(); var policy_type_id = $('#policy_type_for_search').val(); var date_type = $('#date_type').val(); - var issuer = $('#issuer_for_search').val(); + var issuer = $('#issuer_for_search').val() || 0; var status = $('#policy_status_for_search').val(); console.log(start_date + '-' + end_date); From 56b658ac4250f3bc5f542a929d55609ab3916e37 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 5 Aug 2025 17:36:54 +0530 Subject: [PATCH 04/10] CHNAGE_BDS_CHANGE : RV --- app/Views/insurer_export_templete.php | 49 ++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/app/Views/insurer_export_templete.php b/app/Views/insurer_export_templete.php index 5a1b93ce..33ed64c8 100755 --- a/app/Views/insurer_export_templete.php +++ b/app/Views/insurer_export_templete.php @@ -472,13 +472,9 @@ newRow.className = 'form-row dynamic-form-row'; newRow.innerHTML = ` -
- - -
- $value) { ?> @@ -488,6 +484,11 @@
+
+ + +
+
@@ -719,5 +720,43 @@ } }); + function handleDbColumnChange(element) { + console.log('=== SELECT CHANGE EVENT TRIGGERED ==='); + + let $defaultInput = $(element); + console.log('1. Current select element:', $defaultInput); + console.log('2. Current select value:', $defaultInput.val()); + + let $row = $defaultInput.closest('.form-row, .row'); + console.log('3. Found row element:', $row); + console.log('4. Row exists:', $row.length > 0); + + // Updated to find input instead of select for excel_column_name + let $excelInput = $row.find('input[name="excel_column_name[]"]'); + console.log('5. Target input element:', $excelInput); + console.log('6. Target input exists:', $excelInput.length > 0); + console.log('7. Current target input value:', $excelInput.val()); + + // Get the selected option's text (the display text, not the value) + let selectedText = $defaultInput.find('option:selected').text().trim(); + console.log('8. Selected option text:', selectedText); + console.log('9. Selected text length:', selectedText.length); + + // Also get the selected value for comparison + let selectedValue = $defaultInput.val(); + console.log('10. Selected option value:', selectedValue); + + if (selectedText !== '' && selectedText !== 'Select') { + console.log('11. Setting target input value to:', selectedText); + $excelInput.val(selectedText); + console.log('12. Target input value after setting:', $excelInput.val()); + } else { + console.log('11. Selected text is empty or "Select", clearing target input'); + // $excelInput.val(""); + console.log('12. Target input value after clearing:', $excelInput.val()); + } + + console.log('=== EVENT HANDLING COMPLETE ==='); + } \ No newline at end of file From aa32df6ba9e74ecf9b516fd1953de4bc35f6fbf3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 6 Aug 2025 10:04:36 +0530 Subject: [PATCH 05/10] FIX_CLIENT_ADD : RV --- app/Controllers/ClientController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index f7bb29ba..16c6a485 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -608,6 +608,8 @@ class ClientController extends AdminController $data['policy_types'] = $this->policyTypeModel->findAll(); $data['policy_type'] = ['1' => 'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon']; $data['client_type'] = ['1' => 'Group', '2' => 'Retail']; + $data['clients'] = $this->clientModel->where('is_active', 1)->findAll(); + $data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll(); // echo "
";
         // print_r($data); die;

From d22d2d192e594ceff17860cf13ce5a51ea4c1849 Mon Sep 17 00:00:00 2001
From: "venkatesh.r" 
Date: Wed, 6 Aug 2025 10:53:11 +0530
Subject: [PATCH 06/10] FIX_CD_AC_NO : RV

---
 app/Views/cd_master_list.php    | 4 ++--
 app/Views/client_basic_info.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php
index 64dbaf47..7a63844f 100755
--- a/app/Views/cd_master_list.php
+++ b/app/Views/cd_master_list.php
@@ -280,8 +280,8 @@ table.dataTable thead th {
                 $('#insurer_branch_id').val(res.data.insurer_id).change();
                 $('#insurer_branch_id').prop("disabled", true);
                 $('#opening_date').val(res.data.opening_date);
-                $('#cd_ac_no').val(res.data.cd_ac_no);
-                //$('#cd_ac_no').prop("disabled", true);
+                $('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
+                //$('#cd_ac_no_for_cd_master').prop("disabled", true);
                 $('#opening_bal').val(res.data.opening_bal);
                 if(res.cd_transaction_count <= 1){
                     $('#opening_bal').prop("disabled", false)
diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php
index 2d3eb20d..335b55eb 100755
--- a/app/Views/client_basic_info.php
+++ b/app/Views/client_basic_info.php
@@ -113,7 +113,7 @@ input:checked + .slider:before {
                             
-->
- + +
From a3339baf7c6fe41ee400e8166160980faffec1c4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 6 Aug 2025 15:26:52 +0530 Subject: [PATCH 08/10] FIX_TERMS_FAMILY_FLOATER : RV --- app/Controllers/ClientController.php | 53 ++++++++++++++-------------- app/Views/policy_gmc_terms.php | 20 +++++++---- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 16c6a485..e352f180 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2609,17 +2609,16 @@ class ClientController extends AdminController // $data = []; - foreach ($fields as $field => $needsCleanup) { - $value = $this->request->getPost($field); + // foreach ($fields as $field => $needsCleanup) { + // $value = $this->request->getPost($field); - if ($value !== null && $value !== '') { - $data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value; - }else{ - $data[$field] = $value; - } - } + // if ($value !== null && $value !== '') { + // $data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value; + // }else{ + // $data[$field] = $value; + // } + // } - $data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform(); // print_r($data);die; @@ -2950,25 +2949,25 @@ class ClientController extends AdminController 'air_ambulance' ]; - // Remove commas and assign if present - foreach ($fieldsWithCommaRemoval as $field) { - $value = $this->request->getPost($field); - if ($value !== null) { - $data[$field] = str_replace(',', '', $value); - }else{ - $data[$field] = $value; - } - } + // // Remove commas and assign if present + // foreach ($fieldsWithCommaRemoval as $field) { + // $value = $this->request->getPost($field); + // if ($value !== null) { + // $data[$field] = str_replace(',', '', $value); + // }else{ + // $data[$field] = $value; + // } + // } - // Direct assign if present - foreach ($fieldsWithoutCommaRemoval as $field) { - $value = $this->request->getPost($field); - if ($value !== null) { - $data[$field] = $value; - }else{ - $data[$field] = $value; - } - } + // // Direct assign if present + // foreach ($fieldsWithoutCommaRemoval as $field) { + // $value = $this->request->getPost($field); + // if ($value !== null) { + // $data[$field] = $value; + // }else{ + // $data[$field] = $value; + // } + // } $data['enrollment_display_key'] = $this->enrollmentGPADisplayValueTransform(); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 5358566c..0e420ecd 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1138,12 +1138,14 @@ disableUnwantedTerms(jsonObject); Object.keys(jsonObject).forEach(function(key) { - if (key.includes("special_condition_label") || key.includes( - "special_condition_input")) { + if (key.includes("special_condition_label") || key.includes("special_condition_input")) { if (key.includes("special_condition_label")) { - for (let index = 0; index < jsonObject[key] - .length; index++) { - specialCondition(); + if (jsonObject[key] && Array.isArray(jsonObject[key])) { + for (let index = 0; index < jsonObject[key].length; index++) { + specialCondition(); + } + } else { + console.warn(`jsonObject[${key}] is not a valid array.`); } } @@ -1221,7 +1223,6 @@ `input[name="${key}[]"]`); if (jsonObject[key]) { - console.log(jsonObject[key]); console.log(jsonObject[key]); if (jsonObject[key].childrens) { $('#children').val(jsonObject[key].childrens); @@ -1257,7 +1258,7 @@ } else if (jsonObject[key]['parents-in-law'] == 2) { $('#family_floaters').val('2PIL'); } else if (jsonObject[key]['either-parents-pil'] == 2) { - $('#family_floaters').val('4EPORPIL'); + $('#family_floaters').val('2EPORPIL'); } } @@ -1450,6 +1451,11 @@ } var family_floaters = $('#family_floaters').val(); + + console.log("========================================================"); + console.log("family_floaters", family_floaters); + console.log("========================================================"); + if (family_floaters != 0) { $('.other-member-age').css('display', ''); } else { From e006d76a9933b0395cdb1ad8eaf7fcf32f9503c3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 7 Aug 2025 09:41:04 +0530 Subject: [PATCH 09/10] FIX_LIVE_ISSUE_BDS_ENDOREMENT_BRO_CALC : RV --- app/Controllers/PolicyTransactionController.php | 6 +++++- .../policy_transaction_endorsement_form.php | 16 +++++++++++----- app/Views/policy_transaction_inception_form.php | 9 +++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index cd08d50d..dddedd54 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1209,6 +1209,10 @@ class PolicyTransactionController extends BaseController $client_branch_id = $issue_type['client_branch_id']; } + // if($data['bro_payable_by'] == ""){ + // $data['bro_payable_by'] = $issue_type['bro_payable_by']; + // } + if (!$data['id']) { $data += [ @@ -1224,7 +1228,7 @@ class PolicyTransactionController extends BaseController 'policy_end_date' => $issue_type['policy_end_date'] ?? null, 'revenue_type' => $issue_type['revenue_type'] ?? null, 'co_share' => $issue_type['co_share'] ?? 0, - 'bro_payable_by' => $issue_type['bro_payable_by'] ?? 0, + 'bro_payable_by' => $data['bro_payable_by'] == "" ? $issue_type['bro_payable_by'] ?? 0 : $data['bro_payable_by'], 'installment' => $issue_type['installment'] ?? null, 'installment_data' => $issue_type['installment_data'] ?? null, 'location' => $issue_type['location'] ?? null, diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index eaab26ee..e68ee440 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -427,7 +427,7 @@ Agreed TEP % - + > Agreed Amount @@ -445,7 +445,7 @@ Standard TEP % - + Actual BP Amount @@ -520,6 +520,8 @@