FEAT_ new api getEmployeeOldPolicy : GWM

This commit is contained in:
bitbucket 2024-05-07 12:04:01 +05:30
parent e33433ffd6
commit 7997383173
2 changed files with 66 additions and 129 deletions

View File

@ -271,6 +271,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData");
$routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
$routes->get("getEmployeeOldPolicy", "EmployeeRestController::getEmployeeOldPolicy");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -521,134 +521,7 @@ class EmployeeRestController extends AdminController
}
// public function getEmployeePolicy()
// {
// try {
// $id = $this->request->getGet('id');
// $emp_code = $this->request->getGet('emp_code');
// $keysToRemove = ["removable_keys"];
// $empPolicy = $this->employeeModel->getEmployeePolicy($id);
// $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
// if ($empPolicy) {
// $result = [];
// foreach ($empPolicy as $array) {
// $decodedArray = json_decode($array->Policy_Terms);
// $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
// $array->Policy_Terms = $refusingData;
// $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
// $array->SlabRates = $getSlabAndGridData['slab_rates'];
// $array->GridMaster = $getSlabAndGridData['grid_master'];
// if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
// $default_si = $array->Policy_Terms->sumInsured2;
// $index = -1;
// foreach ($array->SlabRates as $key => $value) {
// if ($value['si'] == $default_si) {
// $index = $key;
// break;
// }
// }
// if ($index >= 0) {
// $element =$array->SlabRates[$index];
// array_splice($array->SlabRates, $index, 1);
// array_unshift($array->SlabRates, $element);
// }
// $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
// if($employee_policy){
// $gpaSI['family_floater_key'] = 'self';
// $gpaSI['label'] = 'Self';
// $gpaSI['employee_id'] = $employee_policy->employee_id;
// $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
// $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
// $array->mapped_family_floaters = $gpaSI;
// }else{
// $gpaSI['family_floater_key'] = 'self';
// $gpaSI['label'] = 'Self';
// $gpaSI['employee_id'] = $id;
// $gpaSI['basic_cover_si'] = null;
// $gpaSI['premium'] = null;
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
// $array->mapped_family_floaters = $gpaSI;
// }
// }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
// // re-arranging order of si
// $default_si = $array->Policy_Terms->sum_insured;
// // Filter the array using the callback function
// $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
// $default_premium = $getPremium[0]['premium'];
// $index = -1;
// foreach ($array->SlabRates as $key => $value) {
// if ($value['si'] == $default_si) {
// $index = $key;
// break;
// }
// }
// if ($index >= 0) {
// $element =$array->SlabRates[$index];
// array_splice($array->SlabRates, $index, 1);
// array_unshift($array->SlabRates, $element);
// }
// //map family floates array to employee and dependent
// $familyFloates = $array->Policy_Terms->family_floaters;
// $data = [];
// foreach ($familyFloates 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)->get()->getRow();
// $temp['family_floater_key'] = $familyFloatesValue;
// $temp['label'] = $value['relationship'];
// $temp['name'] = $value['name'];
// $temp['employee_id'] = $value['id'];
// $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
// $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
// $temp['client_policy_id'] = $array->ClientPolicyId;
// array_push($data,$temp);
// unset($empData[$key]);
// break;
// }
// }
// }
// }
// $array->mapped_family_floaters = $data;
// $temp2=[];
// foreach ($array->SlabRates as $key => $value) {
// $value['additional_premium'] = $value['premium'] - $default_premium;
// array_push($temp2,$value);
// }
// $array->SlabRates = $temp2;
// }
// $result[] = $array;
// }
// return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
// }else{
// return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
// }
// } catch (\Exception $e) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
// }
// }
// Get the RelationShip list
@ -1795,6 +1668,7 @@ public function getCashDepositData()
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 1)
->groupBy('client_policy.insurer_id')
->findAll();
$result = [];
@ -1815,6 +1689,7 @@ public function getCashDepositData()
->where('client_policy.insurer_id', $value['insurerId'] )
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 1)
->findAll();
// dd( $ClientPolicyData);
foreach ($ClientPolicyData as $key => $value)
@ -1983,7 +1858,7 @@ public function removeEmpAndEmpPolicyData()
return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
}
@ -1995,4 +1870,64 @@ public function removeEmpAndEmpPolicyData()
function getEmployeeOldPolicy()
{
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 0)
->orderby('client_policy.id' , 'ASC')
->findAll();
// Retrieve employee and dependents data by passing the employee code
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('client_id',$this->request->getGet('client_id'))
->where('is_active', 1 )->findAll();
$whereArrayForId = [];
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
{
$result = [];
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
$data['client_id'] = $ClientPolicyValue['client_id'];
$data['client_policy_id'] = $ClientPolicyValue['id'];
$data['policy_name'] = $ClientPolicyValue['policy_name'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employee_polices.employee_id',$whereArrayForId)
->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
->where('employee_polices.is_active', 1 )->findAll();
$si_value = 0;
$si_premium_value = 0;
$si_gst_value = 0;
foreach ($employee_policy as $key => $value) {
if(isset($value['basic_cover_si'])){ $si_value = $value['basic_cover_si']; }
if(isset($value['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];}
if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];}
}
$data['si_value'] = $si_value;
$data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_premium_value;
$data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_gst_value;
$data['EmployeePolicy'] = $employee_policy;
array_push($result, $data);
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result ], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
}
}
}