From 053a74ff88d5c83fda7efc1971f4eb1f7a69dee2 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 18 Apr 2024 15:18:16 +0530 Subject: [PATCH 1/5] CHANGE_PREMIUM_CALC_API --- app/Controllers/EmployeeRestController.php | 20 +++--- app/Controllers/EmployeeServiceController.php | 2 +- app/Helpers/excel_util_helper.php | 58 +++++++++++++++ .../unit/GridType12PremiumCalculationTest.php | 72 +++++++++++++++++++ 4 files changed, 143 insertions(+), 9 deletions(-) create mode 100644 tests/unit/GridType12PremiumCalculationTest.php diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 71ebec43..db0cfb55 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1330,12 +1330,6 @@ public function iAgreeForAddOn() public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level { helper('excel_util_helper'); - - // $client_policy_id = $this->request->getVar('client_policy_id'); - // $emp_code = $this->request->getVar('emp_code'); - - // dd($default_si); - $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId; $emp_code = $this->request->getVar('emp_code') ?? $empCode; $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy @@ -1345,17 +1339,27 @@ public function calculatePremium($clientPolicyId = null , $empCode = null, $defa $client_id = ($this->clientPolicyModel->select('client_id')->find($client_policy_id))['client_id']; // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($client_id,$client_policy_id); + $policy_type = $policy_terms[0]->is_addon; + $base_policy = $policy_terms[0]->base_policy; $policy_terms = (array) $policy_terms[0];// convert obj to array //get policy slab rates $slab_details = $this->policesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id); - // dd($slab_details); + // print_r($slab_details);die(); $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_code: $emp_code,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); + if(!count($existing_famility_details) && $policy_type == 2)//top up addon only + { + //get basepolicy id then pull emplist from base policy if only current policy is DA addon policy and emplist is zero + // echo 'inside'; + $client_policy_id = $base_policy; + $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_code: $emp_code,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); + } + $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception']; // dd($this->employeeModel->getLastQuery()); - // dd($existing_famility_details);die(); + // print_r($existing_famility_details);die(); $employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db'); // dd($employee_data_group_by_family); foreach ($employee_data_group_by_family as $emp_id => $family) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 808fa7a9..cc5cafeb 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -562,7 +562,7 @@ class EmployeeServiceController extends AdminController // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($client_id,$client_policy_id); $policy_terms = (array) $policy_terms[0];// convert obj to array - + //get policy slab rates $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 34e36e46..41fa05dd 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -873,6 +873,64 @@ if (!function_exists('premium_calculation_manager')) } break; + case "12": + //GMC - Employee + relationship + $max_count = $emp_data['temp']['maxcount']; + $employee_received_band = $emp_data['temp']['band']; + $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; + $emp_data['policy_details']['basic_cover_si'] = null; + foreach ($slab_details['slab_rates'] as $skey => $slab_value) + { + + if($slab_value['si'] == $employee_received_si && ($slab_value['grade'] == $employee_received_band)) + { + //calculate premium based on count + $familiy_si_covered = $employee_received_si * $max_count; + $familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered); + + $emp_data['policy_details']['basic_cover_si'] = (strtolower($emp_data['relationship']) == 'self' ? $familiy_si_covered : null); + $emp_data['policy_details']['date_coverage'] = (strtolower($emp_data['relationship']) == 'self' ? (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']) : ""); + $emp_data['policy_details']['policy_end_date'] = (strtolower($emp_data['relationship']) == 'self' ? $policy_terms['policy_end_date'] : ""); + $emp_data['policy_details']['days'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days : 0); + $emp_data['policy_details']['premium'] = (strtolower($emp_data['relationship']) == 'self' ? $slab_value['premium'] : 0); + $emp_data['policy_details']['rata_premimum'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']) : 0); + $emp_data['policy_details']['gst'] = (strtolower($emp_data['relationship']) == 'self' ? ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')) : 0); + + break; + } + } + break; + + case "13": + //GMC - Employee + relationship + age + $max_count = $emp_data['temp']['maxcount']; + $employee_received_band = $emp_data['temp']['band']; + $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; + $emp_data['policy_details']['basic_cover_si'] = null; + foreach ($slab_details['slab_rates'] as $skey => $slab_value) + { + + if($slab_value['si'] == $employee_received_si && ($slab_value['grade'] == $employee_received_band)) + { + //calculate premium based on count + $familiy_si_covered = $employee_received_si * $max_count; + $familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered); + + $emp_data['policy_details']['basic_cover_si'] = (strtolower($emp_data['relationship']) == 'self' ? $familiy_si_covered : null); + $emp_data['policy_details']['date_coverage'] = (strtolower($emp_data['relationship']) == 'self' ? (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']) : ""); + $emp_data['policy_details']['policy_end_date'] = (strtolower($emp_data['relationship']) == 'self' ? $policy_terms['policy_end_date'] : ""); + $emp_data['policy_details']['days'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days : 0); + $emp_data['policy_details']['premium'] = (strtolower($emp_data['relationship']) == 'self' ? $slab_value['premium'] : 0); + $emp_data['policy_details']['rata_premimum'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']) : 0); + $emp_data['policy_details']['gst'] = (strtolower($emp_data['relationship']) == 'self' ? ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')) : 0); + + break; + } + } + break; + + + default: echo "Not a valid grid"; } diff --git a/tests/unit/GridType12PremiumCalculationTest.php b/tests/unit/GridType12PremiumCalculationTest.php new file mode 100644 index 00000000..9b87a1d3 --- /dev/null +++ b/tests/unit/GridType12PremiumCalculationTest.php @@ -0,0 +1,72 @@ +[ + [ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 12, 'age_from' => null, 'age_to' => null, 'grade' => null, 'si' => 5000000, 'premium' => 50000, 'max_si' => 0,'premium_type' => 1, 'relationship' => 'self'], + [ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 25000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'spouse'], + [ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 20000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'child'], + [ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 18000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'father'], + [ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 15000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'mother'], + [ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 14000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'father-in-law'], + [ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 12000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'mother-in-law']], + + 'grid_master' => ['id' => 4,'policy_type' => 'GMC','ui_type' => 12,'policy_grid_type' => 'Employees + Relationship','is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 0,'basicpay' => 0,'emp_band' => 0,] + ]; + // Sample family data + $family_details = [ + [1, 'Jane Doe', '1990-01-01', 'F', 'Spouse', 10000, '2024-01-01', '2020-01-01', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', 'None', '', '', ''], + [2, 'John Doe', '1990-01-01', 'M', 'Self', '', '', '', '', '', '', '', '', '', '', ''], + [3, 'Peter Doe', '1990-01-01', 'M', 'Father', '', '', '', '', '', '', '', '', '', '', ''], + [4, 'Mary Doe', '1990-01-01', 'F', 'Mother', '', '', '', '', '', '', '', '', '', '', ''], + [5, 'Grace Doe', '1990-01-01', 'F', 'Mother-in-law', '', '', '', '', '', '', '', '', '', '', ''], + [6, 'George Doe', '1990-01-01', 'M', 'Father-in-law', '', '', '', '', '', '', '', '', '', '', ''], + [7, 'Alice Doe', '1995-02-02', 'F', 'Daughter', 8000, '2024-02-01', '2021-01-01', 40000, 'B', 'Supervisor', '9876543210', '', '', '', ''], + [8, 'Bob Doe', '1995-02-02', 'M', 'Son', '', '', '', '', '', '', '', '', '', '', ''], +]; + + + // Sample policy terms + $policy_terms = [ + 'family_floater' => true, + 'family_floaters' => [ + 'childrens' => 2, + 'spouse' => 1, + 'either-parents-pil' => 0, + 'parents' => 2, + 'parents-in-law' => 2, + ], + ]; + + // Sample action array + $actionArr = 'addition'; + + // Call the function + $result = check_dependent_conflict($family_data, $policy_terms, $actionArr); + Kint::dump($result); + // Assert that the status is true (no conflicts) + $this->assertTrue($result['status']); + } + + // public function testIsNull() + // { + // $i = null; + // $this->assertTrue($i); + + // } +} \ No newline at end of file From e5cdd231c2e1d91272c7c70a175b0c0f3fa9ec03 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Thu, 18 Apr 2024 15:57:31 +0530 Subject: [PATCH 2/5] CHANGE_addEmployeeAndDependenceAPI:GWM --- app/Config/Routes.php | 1 - app/Controllers/EmployeeRestController.php | 39 ++++++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fc3ee161..b68ae6c3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -246,7 +246,6 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi $routes->post("/calculatePremium", "EmployeeRestController::calculatePremium"); - $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e1814d9f..613bc1f8 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -170,7 +170,7 @@ class EmployeeRestController extends AdminController public function addEmployeeAndDependence() { - // try { + try { $data = $this->request->getJSON(); if ($data) { @@ -197,10 +197,6 @@ class EmployeeRestController extends AdminController $employee = $this->employeeModel->insert($item); if ($employee) { - if(!isset($item->is_addon_value)) - { - $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id); - } $Count++; } @@ -210,10 +206,16 @@ class EmployeeRestController extends AdminController if ($Count > 0) { - if(!isset($data[0]->is_addon_value)) + if(!isset($item->is_addon_value)) { - $this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code); + $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id); + }else{ + $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id,$item->basic_cover_si); } + + + $this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code); + $result = []; return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); @@ -222,18 +224,19 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404); } } - // } catch (\Exception $e) { - // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - // } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } } - public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id) + public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null) { - + if($basic_cover_si != null){ $client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first(); $policy_terms = json_decode($client_policy['policy_terms']); $basic_cover_si = $policy_terms->sum_insured; + }else{ $basic_cover_si = $basic_cover_si; } $checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->first(); @@ -989,6 +992,7 @@ public function getEmployeePolicy() // Map family floaters that already exist in the employee table $familyFloates = $array->Policy_Terms->family_floaters; + // Generate Notes string based on familyFloates terms $array->notes = $this->FloterNotesConvertion($familyFloates); // Convert familyFloaters terms data to plain array @@ -1115,6 +1119,8 @@ public function FloterNotesConvertion($array){ $string = ucwords($string); $result .= ' + '.$string; }else if($value != 0 && $key ==='self') { + }else if($value != 0 && $key ==='childrens') { + if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; } }else{ $string = str_replace('-', ' ', $key); $string = ucwords($string); @@ -1122,7 +1128,7 @@ public function FloterNotesConvertion($array){ } } } - + return $result; } @@ -1342,12 +1348,11 @@ public function iAgreeForAddOn() $this->employeeModel->where('emp_code', $emp_code ) ->where('is_active', 1 ) - ->set(array('emp_status'=>'Enrolled')) + ->set(array('emp_status'=>'enrolled')) ->update(); - $this->employeePolicyModel->where('client_id', $client_id ) - ->where('client_policy_id', $client_policy_id ) + $this->employeePolicyModel->where('client_policy_id', $client_policy_id ) ->where('is_active', 1 ) - ->set(array('status'=>'Enrolled')) + ->set(array('status'=>'enrolled')) ->update(); return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200); } From 59ed66f84c39256b259b8dcb3547099a321076f2 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Thu, 18 Apr 2024 16:20:50 +0530 Subject: [PATCH 3/5] FIX_addEmployeeAndDependenceAPI:GWM --- app/Controllers/EmployeeRestController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index de4e0dec..4ec8de9d 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1063,9 +1063,9 @@ public function getEmployeePolicy() } - $result[] = $array; + // $result[] = $array; } - + return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); }else{ @@ -1329,7 +1329,7 @@ public function getAddOnPolicy() } - // return $this->respond(['status' => 'success','code' => 200,'data' => ['addon_policy'=>$responce]], 200); + return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); }else{ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); From 6c99f547ab0ae8bd94d016799a8fba8b5548c818 Mon Sep 17 00:00:00 2001 From: sriramv Date: Thu, 18 Apr 2024 16:56:43 +0530 Subject: [PATCH 4/5] 'FIX_EMP_MODULE_ID_ISSUE_IN_RACK_RATE_RV' --- app/Controllers/ClientController.php | 18 +++++++++++++----- app/Controllers/EmpDataServiceController.php | 2 +- app/Models/EmployeePolicyModel.php | 7 +++---- app/Views/policy_grid.php | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 600d054e..baca94e2 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1048,11 +1048,19 @@ class ClientController extends AdminController ->where("employees.emp_status",'active') ->countAllResults(); - if($emp_count == 0){ - $emp_count = true; - }else{ - $emp_count = false; - } + + $data = $this->employeePolicyModel->select('employee_polices.id') + ->where('employee_polices.is_active', 1) + ->where('employee_polices.client_policy_id', $client_policy_id) + ->findAll(); + + $emp_count = count($data); + + // if($emp_count == 0){ + // $emp_count = true; + // }else{ + // $emp_count = false; + // } $data = $this->policesModel->getPolicyPremium($record['policy_id']); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 36e3690c..6f82164a 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1262,7 +1262,7 @@ class EmpDataServiceController extends BaseController $description = 'The following amount of Rs. ' . $amount->total_sum . '/- has been debited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.'; $data = [ - 'amount' => $amount->total_sum, + 'amount' => $amount->total_sum ?? 0, 'sub_type_id' => 4, 'client_id' => $arrayData['client_id'], 'insurer_id' => $insurer_id['insurer_id'], diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 82706219..9e817cd5 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -106,6 +106,7 @@ class EmployeePolicyModel extends Model { $client_policy_id = $ref_data['client_policy_id']; $insurer_or_tpa = $ref_data['insurer_or_tpa']; + $event = $ref_data['event_type']; if($insurer_or_tpa == 'tpa'){ @@ -150,13 +151,11 @@ class EmployeePolicyModel extends Model batch_files.batch_code as bf FROM batch_files LEFT JOIN batch_list ON batch_files.batch_code = batch_list.batch_code - WHERE batch_files.event_type = 'inception' + WHERE batch_files.event_type = '{$event}' AND batch_files.actions = 'export' AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}' ) as batch_data ON employee_polices.id = batch_data.emp_policy_id - WHERE batch_data.bf IS NULL - AND batch_data.bl IS NULL - AND employee_polices.client_policy_id = '{$client_policy_id}' + WHERE employee_polices.client_policy_id = '{$client_policy_id}' AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '') AND employee_polices.is_active = 1"; diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 4a5a8f6c..372e5279 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -711,7 +711,7 @@ $('body').on('click', '.btnPolicyModel', function() { $('#nameOfThePolicy').html(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); - if (res.count == false) { + if (res.count > 0) { console.log('count -- 2', res.count); $("#btnGridSubmit_2").hide(); } else { From d2f7729e78b1aa983b2dbe01b58b5017353130ff Mon Sep 17 00:00:00 2001 From: bitbucket Date: Thu, 18 Apr 2024 17:16:46 +0530 Subject: [PATCH 5/5] FIX_error in add dependent api : GWM --- app/Controllers/EmployeeRestController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 4ec8de9d..c51f62aa 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -172,7 +172,8 @@ class EmployeeRestController extends AdminController { try { $data = $this->request->getJSON(); - + + if ($data) { $Count = 0; @@ -206,11 +207,11 @@ class EmployeeRestController extends AdminController if ($Count > 0) { - if(!isset($item->is_addon_value)) + if(!isset($data[0]->is_addon_value)) { - $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id); + $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id); }else{ - $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id,$item->basic_cover_si); + $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si); } @@ -232,11 +233,13 @@ class EmployeeRestController extends AdminController public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null) { - if($basic_cover_si != null){ + + if($basic_cover_si == null) + { $client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first(); $policy_terms = json_decode($client_policy['policy_terms']); $basic_cover_si = $policy_terms->sum_insured; - }else{ $basic_cover_si = $basic_cover_si; } + } $checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->first();