From 9dd0bd2b250994bdc9604e2348ad1c1c3787a26b Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 29 Apr 2024 14:11:39 +0530 Subject: [PATCH 01/16] CHANGE_ in mail App_Url in env file : GWM --- app/Controllers/EmployeeRestController.php | 1 + app/Views/mail_welcome.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1a66028d..29ec4c2a 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -970,6 +970,7 @@ class EmployeeRestController extends AdminController // $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,


Click on the link below to review your personal and family details:
Review Details" ; $data['employee_name']=$dataToInsert[$a]['name']; $data['policy_name']=$policy['name']; + $data['App_Url'] = $_ENV['App_Url']; $message = view('mail_welcome', $data); diff --git a/app/Views/mail_welcome.php b/app/Views/mail_welcome.php index 9ebdd64b..7b0ba18e 100644 --- a/app/Views/mail_welcome.php +++ b/app/Views/mail_welcome.php @@ -14,7 +14,7 @@

We are glad to welcome you to the employee benefit program, offered by your employer.

From 6f255a4cfb781f06bf31995420ec120b873d2798 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 29 Apr 2024 16:48:25 +0530 Subject: [PATCH 02/16] FIX_ addEmployeeAndDependence API : GWM --- app/Controllers/EmployeeRestController.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 29ec4c2a..33db711e 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -209,13 +209,26 @@ class EmployeeRestController extends AdminController if ($Count > 0) { - if(!isset($data[0]->is_addon_value)) + if(isset($data[0]->id)) { - $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id); + if(!isset($data[0]->is_addon_value)) + { + $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id); + }else{ + $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si); + } + }else{ - $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si); + if(!isset($data[0]->is_addon_value)) + { + $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id); + }else{ + $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si); + } } + + $this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code); From 02becbcba4ae687bb38387d7c1501f16edeb3f69 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 30 Apr 2024 08:42:28 +0530 Subject: [PATCH 03/16] CHNAGE_INCEPTION_COLUMNS_RESTORED --- app/Controllers/EmployeeServiceController.php | 3 +-- public/sample_excel/sample_inception.xls | Bin 9216 -> 9728 bytes 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index e57a84db..855db866 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -34,8 +34,7 @@ class EmployeeServiceController extends AdminController protected $policiesModel; protected $empEndorsementModel; protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]]; - - protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; + protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; diff --git a/public/sample_excel/sample_inception.xls b/public/sample_excel/sample_inception.xls index 2c3ab4e3dce179b06c1ed435e76464af19243977..a8e2aeb15c20e00ca60e044e538801bcfbb8e5fd 100644 GIT binary patch delta 2224 zcmZ{lONbn05XbB5?&-($yxk=3>|=U%vzy(#l%O6W3md`U!HXb14x)oINd{zA*NK{g z_82`0LP&cGc-SBcxw&)At^q*^9s@auhn#W{1;LyY9sgBdcTe|WyXl_(x@xL^_4uks zFN|Ki_GGz6@qvfR_ZxqydKoYNn@lFjRUdB{Kd4>nzB$*VKOvliw+;N@DyVa`O?~Rn zJL7xK>*kD0-;tsvqWRb=-3g*Ke}2}ZZ|EhpO!W9v@PKB>i{9{`P+s(I^RSg5C$c z!7vC)MBUD?7i?V!dLQ+NRif=)=l!igaA9j(-i%LG&Z{MtsMGEChyASq64LGU-W^`* z2iv`F_sWEdbee9Bzo>qy-mK79K5XFlm`YT|xl^C6YgB{$NGh)rsYIU)u;I|!4LrGq zu113D9;6jb;xSlGmZn9-{mR%}SG>R7=o?NI}zA!?B= z_httyqN7mC08*k)j3VBd)TZWUBC{ZS3^KN+sDRZ>s%eL)_0`W8Nf|bT4lTzfTslhE zA1d0HKY6r*vlyH3@q7p-OvJB{vlTpFD;tm0bJ|6jR_So+qJkB78{_kDO9F0@#+UdF z;pZeXzmelN$f9E@zXASZ(t=vkhB?OHM@$Cr*ANb)^0`Xo*j^UF6a+4uAcTm3sZBwc zjS);ixOpX!F+vkEt;q;;sb&_zJOII@EP^G@xm+y@r&Y8Bf%hH9W(mTXnjuat$wGo) zNfj4T%`Ad-0D>h5+&Nr`f;dN!LY;;<3k5+~j13nA;rw-tP{<(^q!6uCGmB6-0HKh} zf^OoFV@jHV(`ySt5F54yVfSl|VCQoeZ90+V6~B#DK5T$=Eu70b2M7h5R$6^@a8ngiPz_XniCd zJpvh<^97d25X1T@>~adrZ#8Uw9{RvK0Y74A2}%hUyTr#8>t}H1>Qw-6GJ0$Fsx_HZ z>*I&BO(WWzyMyc1-TAYo|1@nvlQuql>SFYKD{yw^?%ulbi;CLTOf+geQq|~k@R`v( KJpMbd&Hn*fMitip delta 2001 zcmZ{k&ubG=5Xa}ew?DJpq`%Wf-6pC1DOf9_APB8sQSjoWcvNXcK}5tJdU0d*52#%P z5d;-cPm0OaRzVOwdGjC&o;-OGdr~yc%-d|T)nwV-%)a+#K5yR4w{pC4bajuPgZS48 z;6Fd~L->E{^?Kv(tj)@o;^rx%YJ5<&O?zHNXS{(y2Oh!+F$^%!SpBN_1$x1WB5&$| z9xeVm3XgCVe&4=j6+FT3<>-5+C+g_vKj5-==RfNyY8l{Uyxwqqj>>+AdHscss(k83 zMZaR_<$jzu89nx2)NWZJ5YobRHk4xz4h+NER{4WH7U9!7KtJ?s;!DQwjaSGNz61kC89yZF5==DvlBpIt zBK{4m3W@w%5ELWy$9@$fJXqElRE&@hagY!cBTz+BvK1ai z6G62>P$>k1gHr}uvtTg7VC>gmguR`TV;YDMjzS&>3Bf>wAt)qMTM>*l2nHii<;88gP&hOwIyz7-hjsWx;HNV5YJV7x5MZixGCjel13* z-X(-EgFza_KnNBi1j*FaELbtZI5aL@3l<`bV+frEn}d^w)-2dKK92d-TeBJA%{LM9 zzU>r(%?QP0YAb@>2Ek4tp!{HP6q^)+!&xZBejP>#KL~viPU;{WMj!`t5KihKoHhtf z3c=;zqx=jKO>r3kwU_<6ph6UtJ4z$Ch|m-j7ZIAG;wA_rDlQ{X$+-wuhU#mH%~`&v z(56Fl@uqgwRpkO{%LrPeEpDtWUzR>S_%+M@?_y7npaL|gT02|I$|Q~j(A)=U#t`a) zUO^38g!%irv#FDs+n_QYVr?N@sxRHxW6=E$wIyURq!g3HX!;D(kE8PqWX&M`1oP`+ z%cSa^lstglTkt%_n~3qe6rP88LDKZI9`lj#5TBRul{FtC&{vI@RzMFyCP7A1g+Z|^ zI#yUg1 Date: Tue, 30 Apr 2024 09:14:13 +0530 Subject: [PATCH 04/16] CHANGE_ calculatePremium route : GWM --- app/Config/Routes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 744e04a0..34c19b5b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -269,6 +269,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); + + $routes->post("calculatePremium", "EmployeeRestController::calculatePremium"); }); $routes->post("sendEmail", "EmployeeRestController::send_email"); From b4cc2fb2a4eb8515bace7007367f17d33560717c Mon Sep 17 00:00:00 2001 From: bitbucket Date: Thu, 2 May 2024 10:06:54 +0530 Subject: [PATCH 05/16] CHANGE_ in polict list openForEnrolemnt key and added policy_status key where in where condition : GWM --- app/Controllers/EmployeeRestController.php | 10 +++++++--- app/Models/EmployeeModel.php | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 33db711e..c0a77ef6 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1039,6 +1039,7 @@ public function getEmployeePolicy() $keysToRemove = ["removable_keys"]; // Retrieve employee policy data by passing the employee primary key $empPolicy = $this->employeeModel->getEmployeePolicy($id); + // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id) ->where('is_active', 1 )->where('is_addon_value',0)->findAll(); @@ -1062,6 +1063,7 @@ public function getEmployeePolicy() $array->SlabRates = $getSlabAndGridData['slab_rates']; $array->GridMaster = $getSlabAndGridData['grid_master']; + // Construct value for policy type GPA if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ @@ -1268,8 +1270,10 @@ public function getAddOnPolicy() $GMCEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',0)->findAll(); - $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll(); - // dd($clientPolicy); + $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) + ->where('policy_status', 1) + ->findAll(); + if(count($clientPolicy)) { $PolicyData = []; @@ -1286,7 +1290,7 @@ public function getAddOnPolicy() $responce['client_id'] = $array['client_id']; $responce['client_policy_id'] = $array['id']; $responce['is_addon'] = $array['is_addon']; - $responce['open_for_enrollment'] = $array['open_for_enrollment']; + $responce['OpenForEnrollment'] = $array['open_for_enrollment']; $responce['policy_terms'] = $decodedArray; if(count($getSlabAndGridData['slab_rates'])){ diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index fdd19e40..aea640c9 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -135,6 +135,7 @@ class EmployeeModel extends Model ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('policies', 'policies.id = client_policy.policy_id') + ->where('client_policy.policy_status', 1) ->where('employee_polices.employee_id', $id) ->get() ->getResult(); From ca6eb4a872edc5fba0b4449fc75e01f535057599 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Thu, 2 May 2024 15:32:10 +0530 Subject: [PATCH 06/16] CHANGE_ Ecard download url added in all policy api : GWM --- app/Controllers/EmployeeRestController.php | 44 +++++++++++++++++----- app/Models/EmployeeModel.php | 2 +- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c0a77ef6..02ad65bc 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1029,7 +1029,7 @@ class EmployeeRestController extends AdminController public function getEmployeePolicy() { - try { + // try { $id = $this->request->getGet('id'); $emp_code = $this->request->getGet('emp_code'); @@ -1043,7 +1043,7 @@ public function getEmployeePolicy() // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id) ->where('is_active', 1 )->where('is_addon_value',0)->findAll(); - // dd($empPolicy); + if ($empPolicy) { @@ -1063,13 +1063,17 @@ public function getEmployeePolicy() $array->SlabRates = $getSlabAndGridData['slab_rates']; $array->GridMaster = $getSlabAndGridData['grid_master']; + if($array->tpa_id != null){ + $array->eCardDownload = base_url('download-e-card/') . $array->rand_string; + }else{ $array->eCardDownload = null; } + // Construct value for policy type GPA if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ - + // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); - + $self['is_value_exist'] = true; $self['data']['family_floater_key'] = 'self'; $self['data']['employee_id'] = $id; @@ -1177,15 +1181,16 @@ public function getEmployeePolicy() // $result[] = $array; } + 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); } - } 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 FloterConvertion($array){ @@ -1273,7 +1278,7 @@ public function getAddOnPolicy() $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) ->where('policy_status', 1) ->findAll(); - +// dd( $clientPolicy); if(count($clientPolicy)) { $PolicyData = []; @@ -1292,6 +1297,25 @@ public function getAddOnPolicy() $responce['is_addon'] = $array['is_addon']; $responce['OpenForEnrollment'] = $array['open_for_enrollment']; $responce['policy_terms'] = $decodedArray; + + $tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') + ->join('employee_polices', 'employee_polices.employee_id = employees.id') + ->where('employees.emp_code',$this->request->getGet('emp_code')) + ->where('employees.is_active',1) + ->where('employee_polices.client_policy_id',$array['id']) + ->get() + ->getResult(); + + if(count($tpaArray)) + { + if($tpaArray[0]->tpa_id != null) + $responce['eCardDownload'] = base_url('download-e-card/') . $tpaArray[0]->rand_string; + else + $responce['eCardDownload'] = null; + + }else{ + $responce['eCardDownload'] = null; + } if(count($getSlabAndGridData['slab_rates'])){ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1) @@ -1456,7 +1480,7 @@ public function getAddOnPolicy() 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); } } catch (\Exception $e) { return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index aea640c9..2824f4e1 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -132,7 +132,7 @@ class EmployeeModel extends Model { return $this->db->table('employee_polices') - ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables + ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('policies', 'policies.id = client_policy.policy_id') ->where('client_policy.policy_status', 1) From f3d0127e3a9aa0290ef0663d0810ce63cdd9fac8 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Fri, 3 May 2024 10:58:12 +0530 Subject: [PATCH 07/16] CHANGE_ base policy related changes in getAddOnPolicy API : GWM --- app/Controllers/EmployeeRestController.php | 15 +++++++++++---- app/Views/layout/header.php | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 02ad65bc..49bd9a77 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1272,7 +1272,7 @@ public function getAddOnPolicy() try { $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',1)->findAll(); - $GMCEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',0)->findAll(); + $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) @@ -1327,7 +1327,7 @@ public function getAddOnPolicy() } - if($array['is_addon'] == 3) + if($array['is_addon'] == 3)//dependent add on policy { @@ -1437,14 +1437,21 @@ public function getAddOnPolicy() } //array_push($PolicyData, $responce); - }else if($array['is_addon'] == 2){ + + }else if($array['is_addon'] == 2)//Topup policy + { + $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow(); + $basePolicyAddOnType = $getAddOnType->is_addon; + // if is_addon value is 1 it is GMC if not it is one of the Add On policy + if($basePolicyAddOnType == 1){ $is_addon_value = 0; }else{ $is_addon_value = 1; } $only_si_array = []; $only_si_value = 0; $only_si_premium_value = 0; $only_si_gst_value = 0; - foreach ($GMCEmployeeData as $key => $value) { + $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->findAll(); + foreach ($BasePolicyEmployeeData as $key => $value) { $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; } diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index dc06d7c0..f07176f8 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -607,7 +607,7 @@ $currentUrl = base_url(); $parsedUrl = parse_url($currentUrl); $baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/'; - $redirectUrl = $baseUrl . 'nhanceTicket/staff/login_done?' . http_build_query(['token' => $sessionData]); + $redirectUrl = $baseUrl . 'Ticketing/nhance_login?' . http_build_query(['token' => $sessionData]); ?> From 312f9a50c7e7c6f0d5c529f0c7687f20ce6337fb Mon Sep 17 00:00:00 2001 From: bitbucket Date: Fri, 3 May 2024 14:29:00 +0530 Subject: [PATCH 08/16] CHANGE_ in getCashDepositData API : GWM --- app/Controllers/EmployeeRestController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 49bd9a77..182a0151 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1589,6 +1589,7 @@ public function getCashDepositData() $ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name') ->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 ) ->groupBy('client_policy.insurer_id') ->findAll(); $result = []; @@ -1604,13 +1605,15 @@ public function getCashDepositData() $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; $data['policyDetails'] = []; - $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon') ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.insurer_id', $value['insurerId'] ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.is_active', 1 ) ->findAll(); foreach ($ClientPolicyData as $key => $value) { + echo $value['client_policy_id']; $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']); if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; } $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0); From afabd468887c8f8fbc55027aa3db2e3a72b43e92 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Fri, 3 May 2024 15:40:05 +0530 Subject: [PATCH 09/16] CHANGE_ in getVerifiedUserData API : GWM --- app/Controllers/RestAuthenticationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 0bd7edc6..3af70fc4 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -96,7 +96,7 @@ class RestAuthenticationController extends AdminController $mobile_number = $this->request->getJSON()->mobile_number; $otp = $this->request->getJSON()->otp; - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->first(); + $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); if ($employeeData && $otp == $employeeData["otp"] || $employeeData && isset($this->request->getJSON()->login_by_hr)) { $auth = HttpRequestHelper::getRequestInfo(); if ($auth) { From 65e93a911705f0f5737e2204a197c288df4be4e1 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 4 May 2024 16:40:56 +0530 Subject: [PATCH 10/16] CHANGE_RACK_RATE_CALC,SI_ENHANCE_AT_INCEPTION --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeServiceController.php | 87 ++++++- app/Helpers/excel_util_helper.php | 239 ++++++++++++------ 3 files changed, 234 insertions(+), 94 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 744e04a0..8dc0b85e 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -222,7 +222,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); - +$routes->get("processjob", "JobWorker::processJob"); //Employee login api's diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 855db866..48b19e71 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -350,13 +350,15 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'dependent_addition') { $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active']); - // dd($existing_famility_details); + // dd(($existing_famility_details)); //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites $existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file); - // dd($existing_famility_details); + // dd(array_keys($existing_famility_details[0])); $family = array_merge($family,$existing_famility_details); + // kint::dump($family); + $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array } - // kint::dump($family);die(); + // kint::dump($family);//die(); //check name dup within a family if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') @@ -373,14 +375,14 @@ class EmployeeServiceController extends AdminController } } - if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['is_addon'] != 3)) // 3 is depent addon + if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') && ($policy_details['is_addon'] != 3)) // 3 is dependent addon { $res = check_self_available_in_family($family,$file['action']); // dd($res); if(!$res['is_self_found']) { array_push($result['error_summary'],14); // Self not found - $result['error_data'][ $res['emp_code'] ]['name_of_emp_dep']['error'][] = "Self not found "; + $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found "; } } @@ -501,7 +503,12 @@ class EmployeeServiceController extends AdminController } $columns_to_check = []; - if($file['action'] == 'inception'){ $columns_to_check = $this->inception_excel_columns; } + if($file['action'] == 'inception'){ $columns_to_check = $this->inception_excel_columns; } + if($file['action'] == 'addition'){ $columns_to_check = $this->inception_excel_columns; } + if($file['action'] == 'dependent_addition'){ $columns_to_check = $this->inception_excel_columns; } + if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; } + if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; } + if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; } // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); @@ -515,6 +522,7 @@ class EmployeeServiceController extends AdminController $highestRowAndColumn = $sheet->getHighestRowAndColumn(); $allowedHighestColumn = end($columns_to_check); + // dd($allowedHighestColumn); $excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']); unset($excel_data[0]); @@ -537,6 +545,7 @@ class EmployeeServiceController extends AdminController $existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file); // Kint::dump($existing_famility_details); $family = array_merge($family,$existing_famility_details); + $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array // dd($family); } @@ -826,15 +835,10 @@ class EmployeeServiceController extends AdminController { $familiy_data = $params['familiy_data']; $file = $params['file']; - // dd($file); - // print_r($familiy_data); - // echo '------------------------------------------------------'; - - - + $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']); foreach($familiy_data as $fkey => $value) { - if($file['id'] == null || $value['temp']['source'] == 'excel') //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data) + if($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && in_array($value['temp']['source'],[10,11]) && ($slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($slab_details['slab_rates'][0]['premium_type'] == 1 || $slab_details['slab_rates'][0]['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data) { $employee = $this->employeeModel->checkExistingEmp($value); @@ -842,11 +846,25 @@ class EmployeeServiceController extends AdminController $temp = $value['temp']; unset($value['policy_details']); unset($value['temp']); + + //start implemet of si enhancement of grid type 10,11 + if(count($employee) && (($file['action'] == 'dependent_addition' && in_array($value['temp']['source'],[10,11]) && ($slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($slab_details['slab_rates'][0]['premium_type'] == 1 || $slab_details['slab_rates'][0]['premium_type'] == null)))) + { + $res = $this->employeesSIEnhanceProcessWhileOnbboard(employee:$employee[0],policy_data: $policy_data,file:$file);// where employee holds existing emp data and policy_data holds new si enhancement + if(!$res) + { + //if endorsement not happend no need to update emp/policy details in DB. + break; + } + } + //end implemet of si enhancement of grid type 10,11 + //save employee table if(count($employee)) { $value['updated_by'] = $file['created_by']; $value['id'] = $employee[0]['id']; + $value['emp_status'] = 'active'; $log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id']; // $this->myLogger->logme('error',('Update - ' . $employee[0]['id'].' - '. $employee[0]['emp_code'] .' - '.$employee[0]['name'])); } @@ -895,7 +913,50 @@ class EmployeeServiceController extends AdminController }// for end }//function end + // $employee -> holds existing emp model obj and $policy_data holds new policy changes as array + public function employeesSIEnhanceProcessWhileOnbboard(array $employee,array $policy_data,array $file) + { + $employee = $this->employeeModel->where('emp_code', $employee['emp_code'])->where('name',$employee['name'])->where('client_id',$employee['client_id'])->where('is_active',1)->first(); + + $employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first(); + $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($employee_policy['policy_id'],$employee['client_id']); + + //check si has changed in normal case OR check premium only changed, still treat as SI enhancement in grid type 10 + if($employee_policy['basic_cover_si'] != $policy_data['basic_cover_si'] || ($slab_details['grid_master']['ui_type'] == 10 && $policy_data['premimum'] != null && $policy_data['premimum'] != "" && $employee_policy['premimum'] != $policy_data['premimum'])) + { + $existing_endorsements = $this->empEndorsementModel->where('actions','si') + ->where('table_name','employee_polices') + ->where('endorsement_id is null') + ->where('emp_code',$employee['emp_code']) + ->where('name',$employee['name']) + ->where('field_name','basic_cover_si') + ->findAll(); + // dd($existing_endorsements); + //make entry in endorsement table + if(!count($existing_endorsements)) + { + + foreach ($slab_details['slab_rates'] as $skey => $slab_value) + { + if($slab_value['si'] == $policy_data['basic_cover_si']) + { + $group_key = rand(100000, 999999); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $policy_data['basic_cover_si'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => date('Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]); + $this->myLogger->logme('error',($employee['emp_code'].' - '.$employee['name'].'- ( NEW/OLD SI - '.$employee_policy['basic_cover_si'].'/'.$policy_data['basic_cover_si'].')'. '( NEW/OLD PREMIUM - '.$employee_policy['premium'].'/'.$policy_data['premimum'].') '.' - si enhancement via DA')); + return true; //retun true when endorsement inserted + + } + } + } + return false; //retun false when endorsement not happend + } + return false; //retun false when endorsement not happend + + + } // --------------------------------------------------------------------------------- diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 1e98e9fb..35ccad7e 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -1,6 +1,7 @@ true,'error' => ''); + $is_si_found = false; + $is_age_slab_found = false; if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','SI']))// check rule only of action column data available { $received_si = $row['current_action'] == 'SI' ? $row[3] : $row[6]; - $found = false; foreach ($slab_details['slab_rates'] as $skey => $slab_value) { - if($slab_value['si'] == $received_si) + if($is_si_found && $is_age_slab_found) { - $found = true; break; } + + if(!$is_si_found && $slab_value['si'] == $received_si) //match si amount + { + $is_si_found = true; + } + + // check age slab + if($row[3] != null)// dob + { + $dob = change_date_format($row[3],'d-M-Y','Y-m-d'); + // echo $row[3].' - '.$dob;echo '
'; + $currentDateTime = new DateTime();//die(); + $passedDateTime = new DateTime($dob); + $interval = $currentDateTime->diff($passedDateTime); + // echo $row[0].' - '.$row[3].' - '.$interval->y;echo '
'; + if(!$is_age_slab_found && ($slab_value['age_from'] !== null && $slab_value['age_to'] !== null) && ($slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y) && $slab_value['si'] == $received_si) + { + $is_age_slab_found = true; + } + + }//end of check age slab } - if(!$found) { return array('status' => false,'error' => "Sum insured not found"); } - return array('status' => true); - }else { return array('status' => true); } // in else condition no need to check rule, just return true + + } + + if(!$is_si_found) + { + $return_array['status'] = false; + $return_array['error'] = "Sum insured not found"; + } + if(!$is_age_slab_found) + { + $return_array['status'] = false; + $return_array['error'] = !empty($return_array['error']) ? ($return_array['error'].', '.'Sum insured not configured for this age slab') : 'Sum insured not configured for this age slab'; + } + + return $return_array; } } @@ -247,7 +282,7 @@ if (!function_exists('data_group_by_family')) function data_group_by_family($emp_data,$data_source = 'excel') { $result = []; - // dd($emp_data); + // Kint::dump($emp_data); foreach ($emp_data as $rkey => $row) { if($data_source == 'excel') @@ -305,8 +340,13 @@ if (!function_exists('check_self_available_in_family')) { function check_self_available_in_family($family_data) { - + $is_self_found = false; + + $row_id_from_excel = array_filter($family_data,function($item){ return !isset($item['temp']);}); + // Kint::dump($row_id_from_excel); + $row_id_from_excel = current($row_id_from_excel); // get excel sno/rowid of employee amoung familiy array where this array has both data from excel and db + $row_id_from_excel = $row_id_from_excel[0]; foreach ($family_data as $rkey => $row) { if($row[5] != null && strtolower($row[5]) == 'self')//$row[5] = relationship $row[4] = Gender @@ -317,7 +357,7 @@ if (!function_exists('check_self_available_in_family')) } - return ['is_self_found' => $is_self_found,'emp_code' => $family_data[0][1]]; + return ['is_self_found' => $is_self_found,'emp_code' => $family_data[0][1],'row_id' => $row_id_from_excel]; } } @@ -335,28 +375,31 @@ if (!function_exists('name_and_empid_check_in_db')) foreach ($family_data as $rkey => $row) { - $res = $employeeModel - ->join('client_policy cp',"employees.client_id = cp.client_id") - ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id") - // ->where("cp.id",$policy_id) - ->where("employees.client_id",$client_id) - ->where("employees.is_active",1) - ->where("ep.is_active",1) - // ->where("ep.client_id",$client_id) - ->where('name',$row[2])->where('emp_code',$row[1]) - ->findAll(); - - // dd($employeeModel->getLastQuery()); - - - if(($current_action == 'deletion' || $current_action == 'correction' || $current_action == 'si_enhancement') && !count($res)) - { - array_push($result['del'],$row[0]); - } - if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res)) - { - array_push($result['i'],$row[0]); - } + if(isset($row['temp']) && $row['temp']['source'] != 'db') + { + $res = $employeeModel + ->join('client_policy cp',"employees.client_id = cp.client_id") + ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id") + // ->where("cp.id",$policy_id) + ->where("employees.client_id",$client_id) + ->where("employees.is_active",1) + ->where("ep.is_active",1) + // ->where("ep.client_id",$client_id) + ->where('name',$row[2])->where('emp_code',$row[1]) + ->findAll(); + + // dd($employeeModel->getLastQuery()); + + + if(($current_action == 'deletion' || $current_action == 'correction' || $current_action == 'si_enhancement') && !count($res)) + { + array_push($result['del'],$row[0]); + } + if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res)) + { + array_push($result['i'],$row[0]); + } + } } @@ -466,7 +509,7 @@ if (!function_exists('check_dependent_conflict')) if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) ) { $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch } // || ($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count) @@ -478,7 +521,7 @@ if (!function_exists('check_dependent_conflict')) if((2 < $received_parents_count) || (2 < $received_parent_in_laws_count)) { $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch } } @@ -488,7 +531,7 @@ if (!function_exists('check_dependent_conflict')) { // dd($allowed_adults); $result['status'] = false; - $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch + $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch } @@ -525,7 +568,7 @@ if (!function_exists('calculate_premimum')) function calculate_premimum($family_data,$policy_terms,$slab_details,$fileArr,$default_si = null) { // - // dd($fileArr); + // dd($slab_details); // grid type // 1 = premium => si $result = []; @@ -574,7 +617,7 @@ if (!function_exists('calculate_premimum')) $transformed_familiy_member_data['policy_details']['basic_cover_si'] = isset($emp_details_with_empband_max_age_max_count[ $transformed_familiy_member_data['emp_code'] ]['si']) ? $emp_details_with_empband_max_age_max_count[ $transformed_familiy_member_data['emp_code'] ]['si'] : $transformed_familiy_member_data['policy_details']['basic_cover_si']; - if( $fileArr['id'] == null || (in_array($grid_type,[10,11]) || $transformed_familiy_member_data['temp']['source'] == 'excel'))//if file id is null then data coming from enrollment (from DB) otherwise data coming from xcel, so calculate only data from excel (new entry) note: even data coming from excel for event dependet additon we fetch other dependts from db and calculate premium for whole family + if( $fileArr['id'] == null || $transformed_familiy_member_data['temp']['source'] == 'excel' || ($fileArr['action'] == 'dependent_addition' && in_array($grid_type,[10,11]) && $slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($transformed_familiy_member_data['relationship']) == 'self'))//if file id is null then data coming from enrollment (from DB) otherwise data coming from xcel, so calculate only data from excel (new entry) note: even data coming from excel for event dependet additon we fetch other dependts from db and calculate premium for whole family { $transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$slab_details,$default_si); @@ -652,6 +695,8 @@ if (!function_exists('premium_calculation_manager')) { function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null) { + + $myLogger = \Config\Services::mylogger(); // grid type // 1 = premium => si // dd($emp_data); @@ -687,7 +732,7 @@ if (!function_exists('premium_calculation_manager')) //gird and calculation start $slug = \Config\Services::slug(); $grid_type = $slab_details['grid_master']['ui_type']; - + $is_match_found = false; switch ($grid_type) { case "1": //GPA - Sum Insured (SI) * Multiplier @@ -703,7 +748,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -723,7 +768,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -742,7 +787,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -766,7 +811,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -786,7 +831,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -795,6 +840,28 @@ if (!function_exists('premium_calculation_manager')) //GMC - Employees + Dependent Age band $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; foreach ($slab_details['slab_rates'] as $skey => $slab_value) + { + $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; + if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) + { + // echo $emp_data['name']; + $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; + $emp_data['policy_details']['date_coverage'] = (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'] = $policy_terms['policy_end_date']; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['premium'] = $slab_value['premium']; + $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); + $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); + $is_match_found = true; + break; + } + + } + break; + case "7": + //GMC - Employees + Dependent Age + SI + $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; + foreach ($slab_details['slab_rates'] as $skey => $slab_value) { $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) @@ -807,27 +874,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - break; - } - } - break; - case "7": - //GMC - Employees + Dependent Age + SI - $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; - foreach ($slab_details['slab_rates'] as $skey => $slab_value) - { - $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; - if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) - { - $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; - $emp_data['policy_details']['date_coverage'] = (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'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; - $emp_data['policy_details']['premium'] = $slab_value['premium']; - $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); - $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - - + $is_match_found = true; break; } } @@ -845,11 +892,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['date_coverage'] = (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'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -866,11 +913,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['date_coverage'] = (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'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''); - + $is_match_found = true; break; } } @@ -888,11 +935,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['date_coverage'] = 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'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')); - + $is_match_found = true; break; } } @@ -917,11 +964,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $familiy_si_covered; $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; - $emp_data['policy_details']['premium'] = $slab_value['premium']; - $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['premium'] = get_premium_for_si(slab_details: $slab_details,si_amount: $familiy_si_covered,band: $employee_received_band); + $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')); - + $is_match_found = true; break; } } @@ -942,11 +989,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')); - + $is_match_found = true; break; } } @@ -967,11 +1014,11 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; - $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; + $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')); - + $is_match_found = true; break; } } @@ -980,10 +1027,27 @@ if (!function_exists('premium_calculation_manager')) default: - echo "Not a valid grid"; + $this->myLogger->logme('error',($emp_data['emp_code'].'-'.$emp_data['name'].' - grid type not found')); } - - // unset($emp_data['temp']);//remove temp data + if(!$is_match_found) + { + $log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ' ]'; + if($slab_details['slab_rates'][0]['premium_type'] == 1) + { + $log_message .= ' - skipping, calculating only self..!'; + //reset emp si and others policy level data if premium only for self + $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; + $emp_data['policy_details']['basic_cover_si'] = 0; + $emp_data['policy_details']['premium'] = 0; + $emp_data['policy_details']['rata_premimum'] = 0; + $emp_data['policy_details']['gst'] = 0; + $emp_data['policy_details']['days'] = 0; + } + else { $log_message .= '- skipping, slab rate not found'; } + $myLogger->logme('error',$log_message); + // echo $log_message; + + } return $emp_data; } @@ -1125,4 +1189,19 @@ if(!function_exists('replace_original_data')) } return $current_data; } +} + +if(!function_exists('get_premium_for_si')) +{ + function get_premium_for_si(array $slab_details,string $si_amount,string $band) + { + foreach ($slab_details['slab_rates'] as $skey => $slab_value) + { + if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band) + { + return $slab_value['premium']; + } + } + return 0; + } } \ No newline at end of file From eace58e75fd76b957c5653e25769f53b3645d983 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 6 May 2024 17:12:51 +0530 Subject: [PATCH 11/16] CHANGE_ two GMC and two SiTopup policy related api changes : GWM --- app/Controllers/EmployeeRestController.php | 241 +++++++++++++++++++-- app/Models/EmployeeModel.php | 3 +- app/Views/layout/header.php | 2 +- 3 files changed, 226 insertions(+), 20 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 182a0151..c6e26f17 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -19,6 +19,7 @@ use App\Models\FileModel; use App\Models\ClientPolicyModel; use App\Models\PolicyPremium1Model; use App\Models\PolicyPremium2Model; +use App\Models\PolicyTypeModel; use App\Controllers\Jobs ; use App\Controllers\JobWorker ; @@ -47,6 +48,7 @@ class EmployeeRestController extends AdminController protected $clientPolicyModel; protected $policyPremium1Model; protected $policyPremium2Model; + protected $policyTypeModel; public function __construct() { @@ -62,6 +64,7 @@ class EmployeeRestController extends AdminController $this->clientPolicyModel = new ClientPolicyModel(); $this->policyPremium1Model = new PolicyPremium1Model(); $this->policyPremium2Model = new PolicyPremium2Model(); + $this->policyTypeModel = new PolicyTypeModel(); } @@ -1029,7 +1032,7 @@ class EmployeeRestController extends AdminController public function getEmployeePolicy() { - // try { + try { $id = $this->request->getGet('id'); $emp_code = $this->request->getGet('emp_code'); @@ -1051,8 +1054,8 @@ public function getEmployeePolicy() foreach ($empPolicy as $array) { // Reset employee array $empData = $employeeData; - + // Removes specific keys from the decoded array and assigns the result to $refusingData $decodedArray = json_decode($array->Policy_Terms); $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); @@ -1095,7 +1098,7 @@ public function getEmployeePolicy() }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ - + // Map family floaters that already exist in the employee table $familyFloates = $array->Policy_Terms->family_floaters; @@ -1170,11 +1173,25 @@ public function getEmployeePolicy() } $array->mapped_family_floaters = $data; - + $array->type = "Group Medical Coverage"; + $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, policies.id as PolicyId , client_policy.policy_type_id as policy_type_id, policies.name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') + ->join('policies', 'client_policy.policy_id = policies.id', 'left') + ->where('client_policy.policy_type_id', 3 ) + ->where('client_policy.is_addon', 1 ) + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.is_active', 1 ) + ->get() + ->getResult(); + if($checkGmcParentsPolicyExist) + { + $GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id); + return $this->respond(['status' => 'success','code' => 200,'data' => [$array,$GmcParrentsData]], 200); + + } if($this->request->getGet('policy') == 'GMC'){ - return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200); + return $this->respond(['status' => 'success','code' => 200,'data' => [$array]], 200); } } @@ -1188,11 +1205,139 @@ public function getEmployeePolicy() }else{ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200); } - // } 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 getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id) +{ + + $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id) + ->where('is_active', 1 )->where('is_addon_value',0)->findAll(); + foreach ($GmcParrentsPolicy as $key => $array) { + + + + // Reset employee array + $empData = $employeeData; + + + $array->Policy_Terms = json_decode($array->Policy_Terms); + + + // Retrieve slab rate and grid master data by passing the ClientPolicyId and ClientId + $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); + $array->SlabRates = $getSlabAndGridData['slab_rates']; + $array->GridMaster = $getSlabAndGridData['grid_master']; + + $tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') + ->join('employee_polices', 'employee_polices.employee_id = employees.id') + ->where('employees.emp_code',$emp_code) + ->where('employees.is_active',1) + ->where('employee_polices.client_policy_id',$array->ClientPolicyId) + ->get() + ->getResult(); + + if(count($tpaArray)) + { + + if($tpaArray[0]->tpa_id != null) + $array->eCardDownload = base_url('download-e-card/') . $tpaArray[0]->rand_string; + else + $array->eCardDownload = null; + + }else{ + $array->eCardDownload = null; + } + + // if($array->tpa_id != null){ + // $array->eCardDownload = base_url('download-e-card/') . $array->rand_string; + // }else{ $array->eCardDownload = null; } + $array->eCardDownload = null; + + // 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); + + if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1) + { + $array->floter_text_heading = 'Floater Sum Insured'; + $array->floter_text_description = 'This is a floater sum insured. A floater is a type of sum insured that provides coverage to more than one member ot a family at the same time. Simply put, its a single insurance cover for the entire family.'; + }else{ + $array->floter_text_heading = 'Sum Insured'; + $array->floter_text_description = ''; + } + + // 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) { + $temp['is_value_exist'] = true; + $temp['data']['family_floater_key'] = $familyFloatesValue; + $temp['data']['employee_id'] = $value['id']; + $temp['data']['relationship'] = $value['relationship']; + $temp['data']['name'] = $value['name']; + $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']); + $temp['data']['client_policy_id'] = $array->ClientPolicyId; + $temp['data']['form_type'] = $dependent; + array_push($data,$temp); + unset($empData[$key]); + $floters = array_diff($floters, [$familyFloatesValue]); + break; + } + } + } + } + + // Remove Unwanted floter key from floters array based on either-parents-pil term value + if($familyFloates->{'either-parents-pil'} == 1 && count($floters)) + { + $count_parent = 0; + $count_parent_in_law = 0; + foreach ($floters as $value) { + if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; } + if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;} + } + if($count_parent != 2) { + $floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false); + } + if($count_parent_in_law != 2) { + $floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false); + } + } + + // Add family floter buttons placement data for FE validation + if(count($floters)){ + foreach ($floters as $familyFloatesValue) { + + $temp2['is_value_exist'] = false; + $temp2['data']['family_floater_key'] = $familyFloatesValue; + $temp2['data']['client_policy_id'] = $array->ClientPolicyId; + $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); + $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue); + + array_push($data,$temp2); + + } + } + + $array->mapped_family_floaters = $data; + $array->type = "Group Medical Coverage - Parents"; + + return $array; + + } + +} public function FloterConvertion($array){ $result = []; @@ -1226,7 +1371,7 @@ public function FloterConvertion($array){ public function FloterNotesConvertion($array){ - $result = 'Can Add Self '; + $result = ' '; foreach ($array as $key => $value) { if ($value > 0) { if($value != 0 && $key ==='either-parents-pil') { @@ -1236,6 +1381,7 @@ public function FloterNotesConvertion($array){ $string = ucwords($string); $result .= ' + '.$string; }else if($value != 0 && $key ==='self') { + $result = 'Can Add Self '; }else if($value != 0 && $key ==='childrens') { if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; } }else{ @@ -1278,13 +1424,13 @@ public function getAddOnPolicy() $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) ->where('policy_status', 1) ->findAll(); -// dd( $clientPolicy); + if(count($clientPolicy)) { $PolicyData = []; foreach ($clientPolicy as $key => $array) { $responce = []; - + $decodedArray = json_decode($array['policy_terms']); $policy_terms = $decodedArray; $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array['id'],$array['client_id']); @@ -1297,6 +1443,7 @@ public function getAddOnPolicy() $responce['is_addon'] = $array['is_addon']; $responce['OpenForEnrollment'] = $array['open_for_enrollment']; $responce['policy_terms'] = $decodedArray; + $responce['policy_type_id'] = $array['policy_type_id']; $tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') ->join('employee_polices', 'employee_polices.employee_id = employees.id') @@ -1327,7 +1474,7 @@ public function getAddOnPolicy() } - if($array['is_addon'] == 3)//dependent add on policy + if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy { @@ -1438,9 +1585,17 @@ public function getAddOnPolicy() //array_push($PolicyData, $responce); - }else if($array['is_addon'] == 2)//Topup policy + }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; } + array_push($whereArray,$text); + } + } + $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow(); $basePolicyAddOnType = $getAddOnType->is_addon; @@ -1450,7 +1605,7 @@ public function getAddOnPolicy() $only_si_value = 0; $only_si_premium_value = 0; $only_si_gst_value = 0; - $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->findAll(); + $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->whereIn('family_floater_key',$whereArray)->findAll(); foreach ($BasePolicyEmployeeData as $key => $value) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); @@ -1473,12 +1628,62 @@ public function getAddOnPolicy() $responce['family_floaters_of_only_si_value'] = $only_si_value; $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value; $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value; + $responce['type'] = "Group Medical Coverage - Top Up"; if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){ return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200); } + }else if($array['is_addon'] == 2 && $array['policy_type_id'] == 5)//Parents 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; } + array_push($whereArray,$text); + } + } + + $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow(); + $basePolicyAddOnType = $getAddOnType->is_addon; + // if is_addon value is 1 it is GMC if not it is one of the Add On policy + if($basePolicyAddOnType == 1){ $is_addon_value = 0; }else{ $is_addon_value = 1; } + $only_si_array = []; + $only_si_value = 0; + $only_si_premium_value = 0; + $only_si_gst_value = 0; + $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->whereIn('family_floater_key',$whereArray)->findAll(); + foreach ($BasePolicyEmployeeData as $key => $value) { + + $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->premium;} + 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']; + $temp3['data']['relationship'] = $value['relationship']; + $temp3['data']['name'] = $value['name']; + $temp3['data']['dob'] = $this->convertDateFormatDMY($value['dob']); + $temp3['data']['client_policy_id'] = $array['id']; + $temp3['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + $temp3['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + array_push($only_si_array,$temp3); + + } + + $responce['family_floaters_of_only_si_array'] = $only_si_array; + $responce['family_floaters_of_only_si_value'] = $only_si_value; + $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value; + $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value; + $responce['type'] = "Group Medical Coverage - Parents Top Up"; + + if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){ + return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_parent_topup'=>$responce]], 200); + } + + } } @@ -1605,17 +1810,17 @@ public function getCashDepositData() $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; $data['policyDetails'] = []; - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id , client_policy.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.insurer_id', $value['insurerId'] ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->where('client_policy.is_active', 1 ) ->findAll(); + // dd( $ClientPolicyData); foreach ($ClientPolicyData as $key => $value) { - echo $value['client_policy_id']; - $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']); - if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; } + + $value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type; $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0); $enrolledCount = 0; $draftCount = 0; diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 2824f4e1..f67671b3 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -36,7 +36,8 @@ class EmployeeModel extends Model "updated_at", "is_active", "file_id", - "is_addon_value" + "is_addon_value", + "is_createdby_hr" ]; // Callbacks diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index f07176f8..e0c2e9dc 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -607,7 +607,7 @@ $currentUrl = base_url(); $parsedUrl = parse_url($currentUrl); $baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/'; - $redirectUrl = $baseUrl . 'Ticketing/nhance_login?' . http_build_query(['token' => $sessionData]); + $redirectUrl = $baseUrl . 'Ticketing/staff/login?' . http_build_query(['token' => $sessionData]); ?>
From 7997383173ccb468d02d54e37ad9a4d33a8fc5e4 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 7 May 2024 12:04:01 +0530 Subject: [PATCH 12/16] FEAT_ new api getEmployeeOldPolicy : GWM --- app/Config/Routes.php | 2 + app/Controllers/EmployeeRestController.php | 193 +++++++-------------- 2 files changed, 66 insertions(+), 129 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 55810af4..f5119b25 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c6e26f17..952709da 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -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); + } + +} + } \ No newline at end of file From 5177967b146eb50d1e9f522a0efe2fcacf98b837 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 7 May 2024 14:36:14 +0530 Subject: [PATCH 13/16] FIX_UAT_ISSUES_DOB_SI_BAND_BPAY --- app/Controllers/EmployeeServiceController.php | 32 +++++++---- app/Helpers/excel_util_helper.php | 57 ++++++++++++------- app/Models/EmployeeModel.php | 7 ++- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 48b19e71..0c74db67 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -169,10 +169,12 @@ class EmployeeServiceController extends AdminController { break; } - //iterate each row + + //iterate each row for columns validations foreach ($row as $col_key => $col) { + $is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory']; $format = $columns_to_check[$keys[$col_key]]['format']; $allowed_values = $columns_to_check[$keys[$col_key]]['allowed_values']; @@ -263,19 +265,14 @@ class EmployeeServiceController extends AdminController $result['error_summary'] = array_count_values($result['error_summary']); $status = 'failed'; $failure_reason = ((json_encode($result))); - $this->fileModel->where('id', $file_id)->set(['status' => $status,'reason' => $failure_reason])->update(); + $this->fileModel->where('id', $file_id)->set(['status' => $status,'reason' => $failure_reason])->update(); $this->myLogger->logme("error",'{file_id} uploaded failed',['file_id' => $file_id]); - //return $this->respond(['dataStatus' => true,'code' => 404,'data' => 'file upload failed with errors'], 200); - // dd($failure_reason); - - - //print_r($r); } else //trigger next data validation via job queue server { //proceed next data level validation in JOB queue $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]); + $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]); // $jobWorker = new JobWorker(); // JobWorker::processJob($r); } @@ -375,7 +372,7 @@ class EmployeeServiceController extends AdminController } } - if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') && ($policy_details['is_addon'] != 3)) // 3 is dependent addon + if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') && ($policy_details['policy_type_id'] != 3)) // 3 is GMC parents (base policy or dep addon) { $res = check_self_available_in_family($family,$file['action']); // dd($res); @@ -385,6 +382,18 @@ class EmployeeServiceController extends AdminController $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found "; } } + + //check self avaialbe where self data is not available either in excel or same policy (i.e.) gMC parents + if($policy_details['policy_type_id'] == 3) // 3 is GMC parents (base policy or dep addon) + { + $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active']); + // dd($self_details); + if(!count($self_details)) + { + array_push($result['error_summary'],14); // Self not found + $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found "; + } + } if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception') @@ -460,9 +469,8 @@ class EmployeeServiceController extends AdminController else //inception OR addition OR dependent addition { //proceed next data level validation in JOB queue - $job_details = new Jobs(); - - $r = Jobs::addJob(['job_name' => 'employeesOnboardPreprocess','payload' => ['file_id' => $file_id]]); + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'employeesOnboardPreprocess','payload' => ['file_id' => $file_id]]); // $jobWorker = new JobWorker(); // JobWorker::processJob($r); } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 35ccad7e..0efa5cef 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -79,8 +79,8 @@ if(!function_exists('check_relationship')) $slug = \Config\Services::slug(); $col = $slug->slugify($row[5]); // echo $col;//die(); - // if($col != 'self' && $col != 'spouse') - // { + if($col != 'self' && $col != 'spouse') + { if(!isset($relationship[ $col ])) { return array('status' => false,'error' => 'Rule Conflict: Unknown Relationship'); @@ -105,7 +105,7 @@ if(!function_exists('check_relationship')) } - // } + } return array('status' => true); } else @@ -190,17 +190,27 @@ if(!function_exists('check_si')) } // check age slab - if($row[3] != null)// dob + if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob { $dob = change_date_format($row[3],'d-M-Y','Y-m-d'); // echo $row[3].' - '.$dob;echo '
'; $currentDateTime = new DateTime();//die(); $passedDateTime = new DateTime($dob); $interval = $currentDateTime->diff($passedDateTime); - // echo $row[0].' - '.$row[3].' - '.$interval->y;echo '
'; - if(!$is_age_slab_found && ($slab_value['age_from'] !== null && $slab_value['age_to'] !== null) && ($slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y) && $slab_value['si'] == $received_si) + if(!$is_age_slab_found) { - $is_age_slab_found = true; + if(isset($slab_value['age_from']) && isset($slab_value['age_to'])) + { + if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si) + { + $is_age_slab_found = true;// send true if age slab found + } + } + else + { + $is_age_slab_found = true;// send true if age conditin is not applicable + } + } }//end of check age slab @@ -248,10 +258,19 @@ if (!function_exists('check_dob_diff')) { if($row[3] != null && $row[5] != null) { + if (DateTime::createFromFormat('d-M-Y', $row[3]) === false) + { + return array('status' => false,'error' => 'Not a valid Date'); + } + // return array('status' => true); $dob = change_date_format($row[3],'d-M-Y','Y-m-d'); // echo $row[3].' - '.$dob;echo '
'; $currentDateTime = new DateTime();//die(); + // print_r($currentDateTime); + // die(); $passedDateTime = new DateTime($dob); + // print_r($passedDateTime); + $interval = $currentDateTime->diff($passedDateTime); $slug = \Config\Services::slug(); @@ -429,9 +448,9 @@ if (!function_exists('check_dependent_conflict')) $self_emp_row_id = null; $temp_counts = [2,3,4,5,6,7,8,9,10]; //temp variable for check relation repetaed count $slug = \Config\Services::slug(); - - // if($policy_terms['family_floater'] == true) - // { + // dd($policy_terms); + if(isset($policy_terms['family_floater']) && !empty($policy_terms['family_floaters'])) + { // $temp_string = implode(" ",$policy_terms['family_floaters']); $temp = $policy_terms['family_floaters']; @@ -535,15 +554,12 @@ if (!function_exists('check_dependent_conflict')) } - // } - // else - // { - // if(count($family_data) > 1) - // { - // $result['status'] = false; - // $result['error_data'][] = ['code' => 11,'col_name' => 'sno','msg' => 'Rule conflict: Dependents not allowed','row_id' => $row[0]];//dependents not allowed - // } - // } + } + else + { + $result['status'] = true; + } + return $result; @@ -1031,7 +1047,8 @@ if (!function_exists('premium_calculation_manager')) } if(!$is_match_found) { - $log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ' ]'; + $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; + $log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]'; if($slab_details['slab_rates'][0]['premium_type'] == 1) { $log_message .= ' - skipping, calculating only self..!'; diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 2824f4e1..0a1cdbc7 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -95,7 +95,7 @@ class EmployeeModel extends Model } - public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = []) + public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = []) { $result = $this->select(['employees.id as emp_id', 'employees.client_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit']) ->join('employee_polices', 'employee_polices.employee_id = employees.id') @@ -105,7 +105,7 @@ class EmployeeModel extends Model }) ->where('employee_polices.is_active',1) - // ->where('employees.emp_status', ($emp_status !== null ? $emp_status : 'active')) + ->where('employees.is_active',1) // ->where('employees.emp_code',$emp_code) ->when($emp_code, function($query) use ($emp_code){ return $query->where('employees.emp_code',$emp_code); @@ -114,6 +114,9 @@ class EmployeeModel extends Model ->when(count($emp_status), function($query) use ($emp_status){ return $query->whereIn('employees.emp_status', $emp_status); }) + ->when(count($relationship), function($query) use ($relationship){ + return $query->whereIn('employees.relationship', $relationship); + }) ->when(count($policy_status), function($query) use ($policy_status){ return $query->whereIn('employee_polices.status', $policy_status); }) From 659be68e4b8dcf163224770f4c28ce5c2a91f954 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 8 May 2024 11:28:24 +0530 Subject: [PATCH 14/16] CHANGE_ getEmployeeOldPolicy API : GWM --- app/Controllers/EmployeeRestController.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 952709da..f562ef09 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1894,11 +1894,27 @@ function getEmployeeOldPolicy() $result = []; foreach ($ClientPolicyData as $key => $ClientPolicyValue) { + $terms = json_decode($ClientPolicyValue['policy_terms']); + // dd($terms); $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']; + $data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']); + $data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']); + + if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else + if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else + if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else + if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else + if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; } + + if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; } + else + { + if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; } + } $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') @@ -1930,4 +1946,17 @@ function getEmployeeOldPolicy() } + +private function convertDateFormatDisplay($dateString) +{ + // Attempt to create a DateTime object from the provided date string + $dateTime = \DateTime::createFromFormat('Y-m-d', $dateString); + + if ($dateTime instanceof \DateTime) { + return $dateTime->format('d-M-Y'); + } else { + return null; + } +} + } \ No newline at end of file From d2856d70f231cf4b7187a1112b139026821f0247 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Wed, 8 May 2024 14:14:01 +0530 Subject: [PATCH 15/16] CHANGE_AGE_RADIO_IN_GPA_GMS_POLICY_TERMS : AADHAVAN --- app/Controllers/ClientController.php | 22 ++- app/Views/client_onboarding.php | 4 +- app/Views/policy_gmc_terms.php | 256 +++++++++++++++++++++++++-- app/Views/policy_gpa_terms.php | 54 ++++++ 4 files changed, 319 insertions(+), 17 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 3a058335..773eb420 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1174,7 +1174,8 @@ class ClientController extends AdminController public function policyGMCTerms() { try { - // print_r($this->request->getPost('family_floaters'));die; + // echo "
";
+            // print_r($this->request->getPost());die;
             $this->myLogger->logme('error','Terms CREATE function called');
             
             /*** Client Policy Table Primary Key(ID) ***/
@@ -1183,7 +1184,19 @@ class ClientController extends AdminController
             $data['sum_insured']   =str_replace(',', '',$this->request->getPost("sum_insured"));
             $data['family_floater']   =$this->request->getPost("family_floater");
             $data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
-            $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];                
+            $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];        
+            
+            // print_r($this->request->getPost());die;
+            $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
+            $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
+            $data['age_ratio']['spouse']['min'] = $this->request->getPost("spouse_min_age");
+            $data['age_ratio']['spouse']['max'] = $this->request->getPost("spouse_max_age");
+            $data['age_ratio']['child']['min'] = $this->request->getPost("child_min_age");
+            $data['age_ratio']['child']['max'] = $this->request->getPost("child_max_age");
+            $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age");
+            $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age");
+
+
 
                 // if (!in_array("self", $data['family_floaters'])) {
                 //     array_unshift($data['family_floaters'], "self");
@@ -1254,7 +1267,8 @@ class ClientController extends AdminController
                             $data['family_floaters']['either-parents-pil'] =0;
                         }
                     }
-            
+
+                    $data['family_floaters']['elders_count'] =$this->request->getPost("member_count");
 
             $data['waiverofpreexistingdiseases']   =$this->request->getPost("waiverofpreexistingdiseases");
             if ($data['waiverofpreexistingdiseases'] == 1) {
@@ -1371,6 +1385,8 @@ class ClientController extends AdminController
 
             $data['sumInsured2']   =str_replace(',', '', $this->request->getPost("sumInsured2"));
             $data['totalSumInsured'] =str_replace(',', '',$this->request->getPost("totalSumInsured"));
+            $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
+            $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
             $data['accidentalDeathBenefit'] =str_replace(',', '',$this->request->getPost("accidentalDeathBenefit"));
             $data['permanentTotalDisablement'] =str_replace(',', '',$this->request->getPost("permanentTotalDisablement"));
             $data['permanentPartialDisablement'] =$this->request->getPost("permanentPartialDisablement");
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index bca575d2..d2e73c99 100644
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -34,6 +34,7 @@ body {
 
 
 
+
 
@@ -95,8 +96,8 @@ body {
- + diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 25b16341..c6b0de9c 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1,5 +1,13 @@