From db0cadbc3213d94fa87ed2bb75cd1214bb823151 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Sat, 11 May 2024 11:46:33 +0530 Subject: [PATCH] CHANGE_ in emp addOn and empPolicy API : GWM --- app/Controllers/EmployeeRestController.php | 54 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 75348d41..84079452 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -304,7 +304,7 @@ class EmployeeRestController extends AdminController ->where('client_policy_id',$value['policy_details']['client_policy_id'] ) ->where('employee_id' , $value['temp']['emp_id'] ) ->where('is_active', 1 ) - ->set(array('premium'=> $value['policy_details']['premium'] , 'rate_premium'=> $value['policy_details']['rate_premium'] , 'gst'=> $value['policy_details']['gst'] )) + ->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] )) ->update(); } @@ -949,6 +949,7 @@ public function getEmployeePolicy() // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); + $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $self['is_value_exist'] = true; $self['data']['family_floater_key'] = 'self'; @@ -958,6 +959,7 @@ public function getEmployeePolicy() $self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']); $self['data']['mobile'] = $selfData[0]['mobile']; $self['data']['client_policy_id'] = $array->ClientPolicyId; + $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; $array->mapped_family_floaters = $self; @@ -996,6 +998,7 @@ public function getEmployeePolicy() if(count($empData)){ foreach ($empData as $key => $value) { if ($value['family_floater_key'] === $dependent) { + $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; $temp['data']['employee_id'] = $value['id']; @@ -1003,7 +1006,12 @@ public function getEmployeePolicy() $temp['data']['name'] = $value['name']; $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']); $temp['data']['client_policy_id'] = $array->ClientPolicyId; - $temp['data']['form_type'] = $dependent; + $temp['data']['form_type'] = $dependent; + $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent; + + $temp['data']['age_validation'] = $decodedArray->age_ratio->$ageKey; + array_push($data,$temp); unset($empData[$key]); $floters = array_diff($floters, [$familyFloatesValue]); @@ -1012,7 +1020,9 @@ public function getEmployeePolicy() } } } - + // dd($data); + + // Remove Unwanted floter key from floters array based on either-parents-pil term value if($familyFloates->{'either-parents-pil'} == 1 && count($floters)) { @@ -1147,13 +1157,16 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) // Convert familyFloaters terms data to plain array $floters = $this->FloterConvertion($familyFloates); - $data = []; foreach ($floters as $familyFloatesValue) { $dependent = preg_replace('/\d/', '', $familyFloatesValue); + + if(count($empData)){ foreach ($empData as $key => $value) { if ($value['family_floater_key'] === $dependent) { + $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); + // dd( $employee_policy); $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; $temp['data']['employee_id'] = $value['id']; @@ -1161,7 +1174,11 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) $temp['data']['name'] = $value['name']; $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']); $temp['data']['client_policy_id'] = $array->ClientPolicyId; - $temp['data']['form_type'] = $dependent; + $temp['data']['form_type'] = $dependent; + $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent; + $temp['data']['age_validation'] = $array->Policy_Terms->age_ratio->$ageKey; + array_push($data,$temp); unset($empData[$key]); $floters = array_diff($floters, [$familyFloatesValue]); @@ -1300,6 +1317,7 @@ public function getAddOnPolicy() if(count($clientPolicy)) { + $band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('family_floater_key','self')->get()->getRow()->band; $PolicyData = []; foreach ($clientPolicy as $key => $array) { $responce = []; @@ -1307,9 +1325,26 @@ public function getAddOnPolicy() $decodedArray = json_decode($array['policy_terms']); $policy_terms = $decodedArray; $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array['id'],$array['client_id']); + $uniqueData = []; + $siValues = []; + foreach ($getSlabAndGridData['slab_rates'] as $item) { + if($getSlabAndGridData['grid_master']['emp_band'] == 1 ){ + if ($item['grade'] == $band) { + $uniqueData[] = $item; + } + }else{ + if (!in_array($item['si'], $siValues)) { + $uniqueData[] = $item; + $siValues[] = $item['si']; + } + } + + } + + $responce['policy_name'] = $this->policesModel->where('id',$array['policy_id'])->get()->getRow()->name; - $responce['SlabRates'] = $getSlabAndGridData['slab_rates']; + $responce['SlabRates'] = $uniqueData; $responce['GridMaster'] = $getSlabAndGridData['grid_master']; $responce['client_id'] = $array['client_id']; $responce['client_policy_id'] = $array['id']; @@ -1460,11 +1495,12 @@ public function getAddOnPolicy() }else if($array['is_addon'] == 2 && $array['policy_type_id'] == 4)//Topup policy { + $whereArray = []; foreach ( $decodedArray->family_floaters as $key => $value) { if($value != 0){ - if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else{ $text = $key; } + if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; } array_push($whereArray,$text); } } @@ -1483,7 +1519,7 @@ public function getAddOnPolicy() $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; } - if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premium;} + if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id']; @@ -1532,7 +1568,7 @@ public function getAddOnPolicy() $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; } - if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premium;} + if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id'];