Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
7875c1186a
@ -141,6 +141,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get','post'],'enrollment-list','EmployeeController::enrollmentClientList');
|
||||
$routes->get("empby_client_clientbranch/(:any)/(:any)", "EmployeeController::empby_client_clientbranch/$1/$2");
|
||||
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
|
||||
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
||||
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
||||
});
|
||||
|
||||
|
||||
@ -291,9 +293,9 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
|
||||
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||
|
||||
@ -221,6 +221,7 @@ class EmployeeController extends AdminController
|
||||
|
||||
//process post variable entry in file table
|
||||
$loggedInUserID = get_session_userid();
|
||||
// dd($loggedInUserID);
|
||||
// $loggedInUserID = 8;
|
||||
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
@ -229,7 +230,7 @@ class EmployeeController extends AdminController
|
||||
$action = $this->request->getPost('upload-action-type');
|
||||
$status = 'inprogress';
|
||||
|
||||
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id,'uploaded_by' => 1]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
||||
|
||||
//start validation process
|
||||
@ -245,9 +246,10 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
|
||||
//for TPA/insurer upload
|
||||
$data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
|
||||
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addtion' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
|
||||
//for inception upload
|
||||
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addtion' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrollment'];
|
||||
|
||||
$data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
|
||||
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
|
||||
@ -362,6 +364,10 @@ class EmployeeController extends AdminController
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls';
|
||||
} else if ($actionType == 'deletion') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_deletion.xls';
|
||||
} else if ($actionType == 'enrollment') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/enrollment.xls';
|
||||
}else if ($actionType == 'missed_inception') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls';
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
@ -1507,4 +1513,79 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
public function testRackRate()
|
||||
{
|
||||
if ($this->request->getMethod() == 'get') {
|
||||
$filterData = $this->request->getGet('client_policy_id');
|
||||
//just load UI only
|
||||
$this->loadLayout('rack_rate_test');
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->getMethod() == 'post') {
|
||||
$json = $this->request->getJSON();
|
||||
// return $this->respond(['dataStatus' => false, 'code' => 200, 'data' => $data], 200);
|
||||
// $data = (json_decode(json_encode($data),true));
|
||||
$client_id = $json->client_id;
|
||||
$policy_id = $json->policy_id;
|
||||
$branch_id = $json->branch_id;
|
||||
$tabledata = $json->data;
|
||||
|
||||
if(count($tabledata))
|
||||
{
|
||||
$family_details = [];
|
||||
foreach($tabledata as $key => $row)
|
||||
{
|
||||
$row = (array)$row;
|
||||
if(!$row['column12'])
|
||||
{
|
||||
|
||||
$temp[0] = $row['column1'];//sno
|
||||
$temp[1] = $row['column2'];//emp code
|
||||
$temp[2] = $row['column3'];//name
|
||||
$temp[3] = $row['column4'];//DOB
|
||||
$temp[4] = strtoupper($row['column5']);//Gender
|
||||
$temp[5] = $row['column6'];//relation
|
||||
$temp[6] = $row['column7'];//SI
|
||||
$temp[7] = $row['column8'];//DOC
|
||||
$temp[8] = '';//DOJ
|
||||
$temp[9] = $row['column9'];//BP
|
||||
$temp[10] = $row['column10'];//band
|
||||
$temp[11] = '';//designation
|
||||
$temp[12] = '';//mobile
|
||||
$temp[13] = '';//EMail
|
||||
$temp[14] = '';//CE
|
||||
$temp[15] = '';//RFE
|
||||
$temp[16] = '';//DOE
|
||||
$temp[17] = '';//Unit
|
||||
$temp[18] = $row['column11'];//unit
|
||||
$family_details[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// print_r($family_details);
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
|
||||
//get policy details
|
||||
$policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
|
||||
//get rack rates
|
||||
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
|
||||
//get file array or construnct dummy file array here
|
||||
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1];
|
||||
//get familiy details in inception file format array from post method
|
||||
$family_details = [
|
||||
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '',''],
|
||||
[1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', ''],
|
||||
|
||||
// [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
//[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '',''],
|
||||
[6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
];
|
||||
$data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ class EmployeeRestController extends AdminController
|
||||
$count = 0;
|
||||
for ($a=0; $a <count($dataToInsert) ; $a++)
|
||||
{
|
||||
$employee = $this->employeeModel->checkExistingEmployee($dataToInsert[$a]);
|
||||
$employee = $this->employeeModel->checkExistingEmployee($dataToInsert[$a],$client_branch_id);
|
||||
$emp_id =0;
|
||||
|
||||
$data_after_gpa_or_gmc =[];
|
||||
|
||||
@ -16,6 +16,10 @@ use App\Models\PolicesModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\EmpEndorsementModel;
|
||||
use App\Models\MessageModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\NotificationModel;
|
||||
|
||||
use App\Helpers\sendMailNotification;
|
||||
|
||||
use App\Controllers\Jobs ;
|
||||
use App\Controllers\JobWorker ;
|
||||
@ -35,6 +39,8 @@ class EmployeeServiceController extends AdminController
|
||||
protected $policiesModel;
|
||||
protected $empEndorsementModel;
|
||||
protected $messageModel;
|
||||
protected $clientBranchModel;
|
||||
protected $notificationModel;
|
||||
|
||||
protected $general_relationships = [
|
||||
'self' => [
|
||||
@ -266,6 +272,18 @@ class EmployeeServiceController extends AdminController
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
]
|
||||
,
|
||||
'unit' => [
|
||||
'col_idx' => 18,
|
||||
'col_cell_name' => 'S',
|
||||
'col_name' => 'Unit',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
'custom' => 'check_unit',
|
||||
'params' => ['row', 'existing_units']
|
||||
]
|
||||
];
|
||||
|
||||
protected $deletion_excel_columns = [
|
||||
@ -565,6 +583,15 @@ class EmployeeServiceController extends AdminController
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
'custom' => null
|
||||
],
|
||||
'unit' => [
|
||||
'col_idx' => 12,
|
||||
'col_cell_name' => 'M',
|
||||
'col_name' => 'Unit',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
]
|
||||
];
|
||||
|
||||
@ -586,7 +613,8 @@ class EmployeeServiceController extends AdminController
|
||||
14 => null, // inception: pre_existing_ailments (PRE EXISTING AILMENTS) -> No match in enrollment
|
||||
15 => null, // inception: change_event (Change event) -> No match in enrollment
|
||||
16 => null, // inception: date_of_exit (Date of exit) -> No match in enrollment
|
||||
17 => null // inception: reason_for_exit (Reason for exit) -> No match in enrollment
|
||||
17 => null, // inception: reason_for_exit (Reason for exit) -> No match in enrollment
|
||||
18 => null // inception: reason_for_exit (Reason for exit) -> No match in enrollment
|
||||
];
|
||||
|
||||
protected $enrollment_to_inception_mapping = [
|
||||
@ -619,6 +647,8 @@ class EmployeeServiceController extends AdminController
|
||||
$this->policiesModel = new PolicesModel();
|
||||
$this->empEndorsementModel = new EmpEndorsementModel();
|
||||
$this->messageModel = new MessageModel();
|
||||
$this->clientBranchModel = new ClientBranchModel();
|
||||
$this->notificationModel = new NotificationModel();
|
||||
}
|
||||
|
||||
public function excelFileFormatValidation($params)
|
||||
@ -663,6 +693,7 @@ class EmployeeServiceController extends AdminController
|
||||
if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; }
|
||||
if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
|
||||
if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; }
|
||||
if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; }
|
||||
|
||||
|
||||
$result = ['error_type' => 1,'error_summary' => [], 'error_data' => [] ];
|
||||
@ -722,7 +753,10 @@ class EmployeeServiceController extends AdminController
|
||||
$relationship = $this->general_relationships;
|
||||
//get exisiting mobilr nos
|
||||
$existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']);
|
||||
// dd($existing_mobilenos);
|
||||
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
// dd($existing_units);
|
||||
foreach ($excel_data as $row_key => $row)
|
||||
{
|
||||
//define row wise action/event in temporary variable
|
||||
@ -734,6 +768,7 @@ class EmployeeServiceController extends AdminController
|
||||
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
|
||||
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
|
||||
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
|
||||
else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
|
||||
//1. avoid empty rows
|
||||
if(check_row_is_empty_or_null($row))
|
||||
{
|
||||
@ -862,16 +897,17 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
}
|
||||
else //trigger next data validation via job queue server
|
||||
{
|
||||
if($file['action'] == 'enrollment') // if current action is enrollment call next validation and return result
|
||||
{
|
||||
if($file['action'] == 'enrollment' && $file['uploaded_by'] != 1) // if current action is enrollment and uploaded by HR (0 or NULL) call next validation and return result
|
||||
{
|
||||
// dd();
|
||||
$res = $this->excelFileDataValidation(['file_id' => $file['id']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
//proceed next data level validation in JOB queue
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
|
||||
// $jobWorker = new JobWorker();
|
||||
// JobWorker::processJob($r);
|
||||
|
||||
@ -914,6 +950,7 @@ class EmployeeServiceController extends AdminController
|
||||
if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; }
|
||||
if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
|
||||
if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; }
|
||||
if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; }
|
||||
|
||||
// get policy and rack details
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
|
||||
@ -940,7 +977,7 @@ class EmployeeServiceController extends AdminController
|
||||
$relationship = $this->general_relationships;
|
||||
|
||||
|
||||
if(in_array($file['action'],['inception','addition','dependent_addition','deletion','correction','si_enhancement','enrollment']))// the below funcitons are only for I,DA,A
|
||||
if(in_array($file['action'],['inception','missed_inception','addition','dependent_addition','deletion','correction','si_enhancement','enrollment']))// the below funcitons are only for I,DA,A
|
||||
{
|
||||
$employee_data_group_by_family = data_group_by_family($excel_data,'excel',($file['action'] == 'enrollment' ? 'enrollment' : ''));
|
||||
// dd($employee_data_group_by_family);
|
||||
@ -968,12 +1005,12 @@ class EmployeeServiceController extends AdminController
|
||||
// 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
|
||||
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again bring self to first index of the array
|
||||
}
|
||||
// kint::dump($family);//die();
|
||||
|
||||
//check name dup within a family
|
||||
if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition' || $file['action'] == 'enrollment')
|
||||
if($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition' || $file['action'] == 'enrollment')
|
||||
{
|
||||
$res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data
|
||||
// dd($res);
|
||||
@ -987,7 +1024,7 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if(($policy_details['base_policy'] == null && ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment')) || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
|
||||
if(($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0 && ($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment')) || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
|
||||
{
|
||||
$res = check_self_available_in_family($family,$file['action']);
|
||||
if(!$res['is_self_found'])
|
||||
@ -1010,7 +1047,7 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception' || $file['action'] == 'enrollment')
|
||||
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment')
|
||||
{
|
||||
$res = check_dependent_conflict($family,$policy_terms,$file['action']);
|
||||
// dd($res);
|
||||
@ -1081,14 +1118,18 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'employeesCorrectionProcess','payload' => ['file_id' => $file_id]]);
|
||||
}
|
||||
else if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')//inception OR addition OR dependent addition
|
||||
else if ($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')//inception OR addition OR dependent addition
|
||||
{
|
||||
//proceed next data level validation in JOB queue
|
||||
$job_details = new Jobs();
|
||||
// $job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'employeesOnboardPreprocess','payload' => ['file_id' => $file_id]]);
|
||||
// $jobWorker = new JobWorker();
|
||||
// JobWorker::processJob($r);
|
||||
}
|
||||
else if($file['action'] == 'enrollment' && $file['uploaded_by'] == 1)// enrollment uploaded by nhance user not by hr
|
||||
{
|
||||
$r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => $file_id]]);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
@ -1134,6 +1175,7 @@ class EmployeeServiceController extends AdminController
|
||||
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; }
|
||||
if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; }
|
||||
|
||||
// get policy and rack details
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
|
||||
@ -1155,6 +1197,8 @@ class EmployeeServiceController extends AdminController
|
||||
//get policy slab rates
|
||||
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
|
||||
// dd($slab_details);
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
|
||||
$employee_data_group_by_family = data_group_by_family($excel_data);
|
||||
// dd($employee_data_group_by_family);
|
||||
@ -1175,7 +1219,7 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
|
||||
// Kint::dump($family);die();
|
||||
$data = calculate_premimum($family,$policy_terms,$slab_details,$file);
|
||||
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
|
||||
// dd($data);
|
||||
$employee_data_group_by_family[$emp_id] = $data;
|
||||
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
||||
@ -1204,6 +1248,9 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
|
||||
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
|
||||
|
||||
// $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
|
||||
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']];
|
||||
@ -1214,7 +1261,8 @@ class EmployeeServiceController extends AdminController
|
||||
foreach ($employee_data_group_by_family as $emp_id => $family)
|
||||
{
|
||||
$transformed_famility_details = transform_db_data_to_excel($family);
|
||||
$data = calculate_premimum($transformed_famility_details,$policy_terms,$slab_details,$file);
|
||||
// $data = calculate_premium_new($transformed_famility_details,$policy_terms,$slab_details,$file);
|
||||
$data = calculate_premium_new(family_data:$transformed_famility_details,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
|
||||
// dd($data);
|
||||
$employee_data_group_by_family[$emp_id] = $data;
|
||||
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
||||
@ -1478,10 +1526,9 @@ class EmployeeServiceController extends AdminController
|
||||
{
|
||||
$familiy_data = $params['familiy_data'];
|
||||
$file = $params['file'];
|
||||
$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' || (($file['action'] == 'dependent_addition' && ($slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($slab_details['slab_rates'][0]['premium_type'] == 2 || $slab_details['slab_rates'][0]['premium_type'] == null)))) //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' && ($value['temp']['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data)
|
||||
{
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmp($value,$file['client_branch_id']);
|
||||
@ -1495,7 +1542,7 @@ class EmployeeServiceController extends AdminController
|
||||
// echo '---------------------------------------';
|
||||
|
||||
//start implemet of si enhancement of grid type 10,11
|
||||
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($value['temp']['grid_id'],[10,11]) && ( ($slab_details['slab_rates'][0]['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['additional_rack_rate_acting_self'])) || ($slab_details['slab_rates'][0]['premium_type'] == 2 || $slab_details['slab_rates'][0]['premium_type'] == null)))
|
||||
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($value['temp']['grid_id'],[10,11]) && ( ($value['temp']['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))
|
||||
{
|
||||
$log_message = 'Employee record from DB,Checking SI for - '.$employee[0]['name'].'('.$employee[0]['emp_code'].')';
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
@ -1506,6 +1553,7 @@ class EmployeeServiceController extends AdminController
|
||||
//end implemet of si enhancement of grid type
|
||||
|
||||
//save employee table
|
||||
$value['relationship'] = ucfirst(trim($value['relationship']));
|
||||
if(count($employee))
|
||||
{
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
@ -1514,6 +1562,7 @@ class EmployeeServiceController extends AdminController
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$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']));
|
||||
// echo 'insert emp';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1522,6 +1571,7 @@ class EmployeeServiceController extends AdminController
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
|
||||
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
|
||||
// echo 'update emp';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
@ -1540,6 +1590,7 @@ class EmployeeServiceController extends AdminController
|
||||
$policy_data['status'] = 'active';
|
||||
|
||||
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'insert policy';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1548,6 +1599,7 @@ class EmployeeServiceController extends AdminController
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'active';
|
||||
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'update policy';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
@ -1557,7 +1609,7 @@ class EmployeeServiceController extends AdminController
|
||||
$log_message .= ' with PK ' . $emp_policy_id;
|
||||
|
||||
//make endorsement entry if action is addition OR Dependt addition
|
||||
if(($file['action'] == 'dependent_addition' || $file['action'] == 'addition') && $temp['source'] == 'excel')
|
||||
if(($file['action'] == 'missed_inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition') && $temp['source'] == 'excel')
|
||||
{
|
||||
$log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id;
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
@ -1792,8 +1844,173 @@ class EmployeeServiceController extends AdminController
|
||||
$this->messageModel->insert($msg_data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->fileModel->find($file_id);
|
||||
// dd($file);
|
||||
$return = [];
|
||||
if(!isset($file))
|
||||
{
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
//get excel data
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
|
||||
$columns_to_check = $this->enrollment_excel_columns;
|
||||
$keys = array_keys($columns_to_check);
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
$emp_emails = [];
|
||||
|
||||
//check is welcome notification enabled
|
||||
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
|
||||
// dd($notification);
|
||||
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
|
||||
|
||||
foreach ($excel_data as $key => $row)
|
||||
{
|
||||
// dd($key.'-'.count($excel_data));
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
|
||||
$value['gender'] = $row[4];
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $row[12];
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
|
||||
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
|
||||
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'Father') {
|
||||
$relation = 'parent';
|
||||
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
|
||||
$relation = 'child';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'father in Law' || strtolower(trim($value['relationship'])) === 'mother in Law'){
|
||||
$relation = 'parent_in_law';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
|
||||
$relation = 'spouse';
|
||||
}else{
|
||||
$relation = 'self';
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if($employee !== null)
|
||||
{
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
$emp_id = $this->employeeModel->getInsertID();
|
||||
if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
|
||||
if(count($employee_policy))
|
||||
{
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'insert policy';
|
||||
}
|
||||
else
|
||||
{
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'update policy';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
$emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
|
||||
{
|
||||
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
|
||||
{
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
Kint::dump($emp_emails);
|
||||
Kint::dump($key.'-'.count($excel_data));
|
||||
// if mail count is 20 send bulk mail and reset emp_emails variable
|
||||
if (count($emp_emails) == 20 || $key == count($excel_data) ) {
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
|
||||
echo 'Mail triggered';
|
||||
$emp_emails = [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} //end of for loop
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,25 +21,120 @@ class JobWorker extends AdminController
|
||||
* Constructs the class
|
||||
*/
|
||||
|
||||
private static $event_class_mapping = [
|
||||
'add' => ['type' => 'HC', 'handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC', 'handler' => 'App\\Controllers\\Jobs\SubJob'], 'fancy_date_time_format' => ['type' => 'HF', 'handler' => 'fancy_date_time_format'], 'addNumber' => ['type' => 'HC', 'handler' => 'App\\Model\\HttpRequestHelper'], 'excelFileFormatValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'excelFileDataValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesOnboardPreprocess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeeDisembark' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesSIEnhanceProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesCorrectionProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'send_email' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'bulk_mail' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'insertBatchList' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'importInceptionFileValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importInceptionUpdateTPAandUHID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'cashDepositCalculationForInception' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'sendMailForDownloadingECard' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'importCorrectionValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importCorrectionUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'cashDepositCalculationForSIEnhancement' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importSIEnhancementValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importSIEnhancementUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'cashDepositCalculationForDeletion' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importDeletionValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importDeletionUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
];
|
||||
private static $event_class_mapping = [
|
||||
'add' => [
|
||||
'type' => 'HC', // Handler Category (Possible values: HC, CC, HF)
|
||||
'handler' => 'App\Helpers\HttpRequestHelper',
|
||||
],
|
||||
'sub' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\Jobs\SubJob',
|
||||
],
|
||||
'fancy_date_time_format' => [
|
||||
'type' => 'HF', // Handler Category (Possible values: HC, CC, HF)
|
||||
'handler' => 'fancy_date_time_format', // Likely a custom function
|
||||
],
|
||||
'addNumber' => [
|
||||
'type' => 'HC', // Handler Category
|
||||
'handler' => 'App\Model\HttpRequestHelper',
|
||||
],
|
||||
'excelFileFormatValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'excelFileDataValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'employeesOnboardPreprocess' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'employeeDisembark' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'employeesSIEnhanceProcess' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'employeesCorrectionProcess' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'send_email' => [
|
||||
'type' => 'HC', // Handler Category
|
||||
'handler' => 'App\Helpers\MailHelper',
|
||||
],
|
||||
'bulk_mail' => [
|
||||
'type' => 'HC', // Handler Category
|
||||
'handler' => 'App\Helpers\MailHelper',
|
||||
],
|
||||
'insertBatchList' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
|
||||
// Employee Data Service Events
|
||||
'importInceptionFileValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importInceptionUpdateTPAandUHID' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'cashDepositCalculationForInception' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'sendMailForDownloadingECard' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
|
||||
'importCorrectionValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importCorrectionUpdateEndorsementID' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
|
||||
'cashDepositCalculationForSIEnhancement' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importSIEnhancementValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importSIEnhancementUpdateEndorsementID' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
|
||||
'cashDepositCalculationForDeletion' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importDeletionValidation' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'importDeletionUpdateEndorsementID' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'employeesEnrollmentInsert' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// echo 'HiC';//die();
|
||||
|
||||
@ -69,15 +69,13 @@ class RestAuthenticationController extends AdminController
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$randomNumber = rand(100000, 999999);
|
||||
$randomNumber = 123456;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$otp = $this->employeeModel->where('id', $id)->set('otp', $randomNumber)->update();
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully", 'otp'=>$randomNumber];
|
||||
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
$result = ['user_verification' => false , 'message' => "User not found"];
|
||||
@ -92,13 +90,13 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
public function getVerifiedUserData()
|
||||
{
|
||||
// try {
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$otp = $this->request->getJSON()->otp;
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData && $otp == $employeeData["otp"] || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
@ -108,22 +106,19 @@ class RestAuthenticationController extends AdminController
|
||||
'platform' => $auth['platform'],
|
||||
'broswer' => $auth['browser'],
|
||||
];
|
||||
|
||||
$authdata= $this->authHistoryModel->insert($data);
|
||||
|
||||
$this->authHistoryModel->insert($data);
|
||||
}
|
||||
$otp_null = $this->employeeModel->where('id', $employeeData["id"])->set('otp', null)->update();
|
||||
|
||||
|
||||
|
||||
|
||||
$result = JWTToken::encode($employeeData);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],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 verifyHrWithMobileNumber()
|
||||
@ -190,11 +185,6 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
|
||||
|
||||
public function employeeLogout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getUserIdFromToken()
|
||||
{
|
||||
$id = JWTToken::getUserIdFromToken();
|
||||
|
||||
@ -37,6 +37,9 @@ class AuthJWT implements FilterInterface
|
||||
$model->update($id, $data);
|
||||
return true;
|
||||
}else{
|
||||
|
||||
// if($user_data['token_time_out'] != "" && $user_data['token_time_out'] != NULL)
|
||||
|
||||
$data =["token_time_out" => ''];
|
||||
$model->update($id, $data);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
@ -18,6 +18,7 @@ class MailHelper
|
||||
{
|
||||
|
||||
// print_r($params);die;
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
$emaill = $params['mail'];
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
@ -48,12 +49,16 @@ class MailHelper
|
||||
$email->setMessage($message);
|
||||
|
||||
if ($email->send()) {
|
||||
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
|
||||
} else {
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$myLogger->logme('error', "mail sent failed - $msg");
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ if(!function_exists('check_relationship'))
|
||||
{
|
||||
// print_r($relationship);
|
||||
// echo '<br>';
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
|
||||
{
|
||||
if($row[5] != null && $row[4] != null)//$row[5] = relationship $row[4] = Gender
|
||||
{
|
||||
@ -141,7 +141,7 @@ if(!function_exists('check_doj'))
|
||||
|
||||
function check_doj($row)
|
||||
{
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
|
||||
{
|
||||
$slug = \Config\Services::slug();
|
||||
$relationship = $slug->slugify($row[5]);
|
||||
@ -188,7 +188,7 @@ if(!function_exists('check_employee_band'))
|
||||
{
|
||||
function check_employee_band($row,$policy_terms,$slab_details)
|
||||
{
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
|
||||
{
|
||||
$is_emp_band_needed = $slab_details['grid_master']['emp_band'];
|
||||
// $is_emp_band_needed = true;
|
||||
@ -230,7 +230,7 @@ if(!function_exists('check_si'))
|
||||
$return_array = array('status' => 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
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','SI','MI']))// check rule only of action column data available
|
||||
{
|
||||
$received_si = $row['current_action'] == 'SI' ? $row[3] : $row[6];
|
||||
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
|
||||
@ -247,7 +247,7 @@ if(!function_exists('check_si'))
|
||||
}
|
||||
|
||||
// check age slab
|
||||
if(in_array(strtoupper($row['current_action']), ['I','A','DA']) && (($slab_value['premium_type'] == 1 && strtolower($row['5']) == 'self' ) || ($slab_value['premium_type'] == 2) ) )
|
||||
if(in_array(strtoupper($row['current_action']), ['I','A','DA','MI']) && (($slab_value['premium_type'] == 1 && strtolower($row['5']) == 'self' ) || ($slab_value['premium_type'] == 2) ) )
|
||||
{
|
||||
if($row[3] != '' && $row[3] != null)// dob
|
||||
{
|
||||
@ -311,7 +311,7 @@ if(!function_exists('check_basic_pay'))
|
||||
{
|
||||
function check_basic_pay($row,$policy_terms,$slab_details)
|
||||
{
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
|
||||
{
|
||||
$is_basic_pay_needed = $slab_details['grid_master']['basicpay'];
|
||||
// $is_basic_pay_needed = true;
|
||||
@ -329,7 +329,7 @@ if (!function_exists('check_dob_diff'))
|
||||
{
|
||||
function check_dob_diff($row,$relationships,$default_age_ratio) {
|
||||
// echo 'called';
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
|
||||
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
|
||||
{
|
||||
if($row[3] != null && $row[5] != null)
|
||||
{
|
||||
@ -667,9 +667,10 @@ if (!function_exists('generate_relationship_code'))
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('calculate_premimum'))
|
||||
if (!function_exists('calculate_premium'))
|
||||
{
|
||||
function calculate_premimum($family_data,$policy_terms,$slab_details,$fileArr,$default_si = null)
|
||||
// function calculate_premimum($family_data,$policy_terms,$slab_details,$fileArr,$default_si = null)
|
||||
function calculate_premium(array $family_data,array $policy_terms,array $slab_details,array $fileArr,string $default_si = null,array $existing_units = [])
|
||||
{
|
||||
// dd($family_data);
|
||||
$slug = \Config\Services::slug();
|
||||
@ -865,6 +866,130 @@ if (!function_exists('calculate_premimum'))
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('calculate_premium_new'))
|
||||
{
|
||||
function calculate_premium_new(array $family_data,array $policy_terms,array $slab_details,array $fileArr,string $default_si = null,array $existing_units)
|
||||
{
|
||||
|
||||
//grouping slab details by rack rate name
|
||||
$temp_slab_rates = [];
|
||||
$pre_name = '';
|
||||
$pre_grid_master = [];
|
||||
foreach ($slab_details as $key => $value)
|
||||
{
|
||||
$pre_grid_master = $value['grid_master'];
|
||||
unset($value['grid_master']);
|
||||
if($value['rack_rate_name'] != $pre_name)
|
||||
{
|
||||
$pre_name = $value['rack_rate_name'];
|
||||
$temp_slab_rates[ $value['rack_rate_name'] ]['slab_rates'][] = $value;
|
||||
}
|
||||
$temp_slab_rates[ $value['rack_rate_name'] ]['slab_rates'][] = $value;
|
||||
$temp_slab_rates[ $value['rack_rate_name'] ]['grid_master'] = $pre_grid_master;
|
||||
}
|
||||
// dd($temp_slab_rates);
|
||||
/* 1. construct available/incoming family members composition & count */
|
||||
$incoming_familiy_composition = get_familiy_composition($family_data);
|
||||
// dd($incoming_familiy_composition);
|
||||
|
||||
//2 .get applicable familiy members composition & count from slab details & constrcut an array
|
||||
//3 in for another loop compare slab level applicable familiy composition with available family composition
|
||||
$result = [];
|
||||
foreach($temp_slab_rates as $key => $slab)
|
||||
{
|
||||
// dd($slab);
|
||||
$res = compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition);
|
||||
kint::dump($key);
|
||||
kint::dump($res);
|
||||
|
||||
if($res['is_applicable'])
|
||||
{
|
||||
$temp_slab_rates[$key]['is_applicable'] = true;
|
||||
$temp_slab_rates[$key]['members'] = $res['applicable_members'];
|
||||
|
||||
//get applicable members for current rack rate from over all familiy members and calculate max age and max count,self/acting self and grid type and set it in individual familiy member level
|
||||
$applicable_members_from_familiy = get_applicable_familiy_members($family_data,$res['applicable_members']);
|
||||
// dd( $applicable_members_from_familiy);
|
||||
$is_self_acting_self_set = false;
|
||||
foreach($applicable_members_from_familiy['index'] as $val)
|
||||
{
|
||||
$acting_self = false;
|
||||
if(!$is_self_acting_self_set)
|
||||
{
|
||||
if(strtolower($family_data[$val][5]) == 'self' || !$is_self_acting_self_set) $acting_self = true;
|
||||
$is_self_acting_self_set = true;
|
||||
}
|
||||
|
||||
$family_data[$val]['temp'] = ['max_age' => max($applicable_members_from_familiy['max_age']),'max_count' => $applicable_members_from_familiy['max_count'],'grid_name' => $key,'grid_master' => $slab['grid_master'],'acting_self' => $acting_self,'premium_type' => $slab['slab_rates'][0]['premium_type']];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp_slab_rates[$key]['is_applicable'] = false;
|
||||
}
|
||||
}
|
||||
// dd();
|
||||
|
||||
//4. if macthed then the current rack rate is applicable and find common variables link max age,max count,grade, basic pay,SI, self/acting self for current rack rate
|
||||
|
||||
foreach($family_data as $fkey => $member)
|
||||
{
|
||||
// dd($member);
|
||||
//get grid type either primary or additional based on current member relationship available in primary_rack_rate_applicable_familiy_members or not. if yes then primaty grid type else additional grid type
|
||||
|
||||
$fileArr['grid_info'] = ['type' => isset($member['temp']['grid_name']) ? $member['temp']['grid_name'] : NULL , 'grid_id' => isset($member['temp']['grid_master']['ui_type']) ? $member['temp']['grid_master']['ui_type'] : NULL];
|
||||
|
||||
|
||||
|
||||
//set self (first index of familiy) SI and grade to rest of the familiy
|
||||
$member[6] = $family_data[0][6];
|
||||
$member[10] = $family_data[0][10];
|
||||
$member[18] = $family_data[0][18];
|
||||
//set default unit if unit is not available in self/members level
|
||||
if(empty($member[18])){ $member[18] = $existing_units[0]; }
|
||||
//transform as db row column
|
||||
$transformed_familiy_member_data = transform_excel_data_to_db($member,$fileArr);
|
||||
// kint::dump($transformed_familiy_member_data);
|
||||
//generate relationship code
|
||||
if($transformed_familiy_member_data['temp']['action'] != 'D' && $transformed_familiy_member_data['temp']['action'] != 'C' && $transformed_familiy_member_data['temp']['action'] != 'SI')
|
||||
{
|
||||
$temp_res = generate_relationship_code($transformed_familiy_member_data);
|
||||
$transformed_familiy_member_data['relationship_code'] = $temp_res['relationship_code'];
|
||||
$transformed_familiy_member_data['emp_type'] = $temp_res['emp_type_code'];
|
||||
}
|
||||
|
||||
// // this array hold conditions to allow calculate premium amt
|
||||
$conditions = [
|
||||
'isEmployeeSourceEnrollment' => $fileArr['id'] == null,
|
||||
'isEmployeeSourceExcelFile' => $transformed_familiy_member_data['temp']['source'] == 'excel',
|
||||
'isCurrentActionDependentAddition' => $fileArr['action'] == 'dependent_addition',
|
||||
// 'isPrimaryGridPremiumTypeSingle' => $transformed_familiy_member_data['temp']['premium_type'] == 1,
|
||||
'isCurrentRelationshipSelf' => (strtolower($transformed_familiy_member_data['relationship']) == 'self' || (isset($transformed_familiy_member_data['temp']['acting_self']) && $transformed_familiy_member_data['temp']['acting_self'] === true)),
|
||||
'isBasicCoverCalculatedToCurrentEmployee' => ($transformed_familiy_member_data['policy_details']['basic_cover_si'] != null && $transformed_familiy_member_data['policy_details']['basic_cover_si'] != 0)
|
||||
];
|
||||
|
||||
$primaryGridTypeCondition = $conditions['isCurrentActionDependentAddition'] && $conditions['isPrimaryGridPremiumTypeSingle'] && $conditions['isCurrentRelationshipSelf'] && $conditions['isBasicCoverCalculatedToCurrentEmployee'];
|
||||
|
||||
// // Final combined condition
|
||||
if ($conditions['isEmployeeSourceEnrollment'] || $conditions['isEmployeeSourceExcelFile'] || $primaryGridTypeCondition ) {
|
||||
|
||||
$transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$temp_slab_rates,$default_si);
|
||||
|
||||
$result[] = $transformed_familiy_member_data;
|
||||
}
|
||||
|
||||
|
||||
// $result[] = $transformed_familiy_member_data;
|
||||
}
|
||||
|
||||
// dd($result);
|
||||
return ($result);
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('transform_excel_data_to_db'))
|
||||
{
|
||||
@ -878,14 +1003,16 @@ if (!function_exists('transform_excel_data_to_db'))
|
||||
else if($actionArr['action'] == 'deletion'){ $current_column_action = 'D'; }
|
||||
else if($actionArr['action'] == 'correction'){ $current_column_action = 'C'; }
|
||||
else if($actionArr['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
|
||||
else if($actionArr['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
|
||||
|
||||
if($actionArr['action'] == 'inception' || $actionArr['action'] == 'addition' || $actionArr['action'] == 'dependent_addition')
|
||||
if($actionArr['action'] == 'inception' || $actionArr['action'] == 'missed_inception' || $actionArr['action'] == 'addition' || $actionArr['action'] == 'dependent_addition')
|
||||
{
|
||||
|
||||
$policy['basic_cover_si'] = $memArr[6];
|
||||
$policy['pre_existing_alignments'] = $memArr[14];
|
||||
// $policy['date_of_exit'] = isset($memArr[16]) ? change_date_format($memArr[16],'d-M-Y','Y-m-d') : NULL;
|
||||
// $policy['reason_for_exit'] = $memArr[17];
|
||||
|
||||
$policy['client_policy_id'] = $actionArr['policy_id'];
|
||||
$policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
|
||||
$policy['policy_end_date'] = null;
|
||||
@ -910,6 +1037,9 @@ if (!function_exists('transform_excel_data_to_db'))
|
||||
$result['file_id'] = $actionArr['id'];
|
||||
$result['client_id'] = $actionArr['client_id'];
|
||||
$result['change_event'] = $memArr[15];
|
||||
$result['unit'] = $memArr[18];
|
||||
$result['temp'] = [];
|
||||
if(isset($memArr['temp'])) $result['temp'] = array_merge($result['temp'],$memArr['temp']);
|
||||
$result['temp']['grid_type'] = $actionArr['grid_info']['type'];
|
||||
$result['temp']['grid_id'] = $actionArr['grid_info']['grid_id'];
|
||||
$result['temp']['action'] = isset($memArr['current_action']) ? $memArr['current_action'] : $current_column_action;
|
||||
@ -964,13 +1094,21 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']);
|
||||
// Kint::dump($policy_data);
|
||||
}
|
||||
}
|
||||
//end of fetching data from audit history table
|
||||
|
||||
}//end of fetching data from audit history table
|
||||
|
||||
//gird and calculation start
|
||||
$slug = \Config\Services::slug();
|
||||
$grid_type = $emp_data['temp']['grid_id'];
|
||||
$temp_slab_rates = $emp_data['temp']['grid_type'] == 'primary' ? $slab_details['slab_rates'] : $slab_details['additional_slab_info']['slab_rates'];
|
||||
$slab_index = isset($emp_data['temp']['grid_name']) ? $emp_data['temp']['grid_name'] : false;
|
||||
// echo $emp_data['name'];
|
||||
// kint::dump($slab_index);
|
||||
if ($slab_index === false)
|
||||
{
|
||||
// echo 'not set';
|
||||
return false;
|
||||
}
|
||||
$temp_slab_rates = $slab_details[ $slab_index ]['slab_rates'];
|
||||
|
||||
//if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
|
||||
if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
|
||||
@ -984,6 +1122,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
}
|
||||
// dd($emp_data);
|
||||
$is_match_found = false;
|
||||
$gst = isset($policy_terms['gst']) && $policy_terms['gst'] != 0 ? $policy_terms['gst'] : 18;
|
||||
switch ($grid_type) {
|
||||
case "1":
|
||||
//GPA - Sum Insured (SI) * Multiplier
|
||||
@ -991,7 +1130,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$employee_received_band = $emp_data['temp']['band'];
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if(($slab_value['si'] == $employee_received_si) || ($slab_value['grade'] != null && $slab_value['grade'] == $employee_received_band && $slab_value['si'] == $employee_received_si))
|
||||
if(($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']) || ($slab_value['grade'] != null && $slab_value['grade'] == $employee_received_band && $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit']))
|
||||
{
|
||||
$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']);
|
||||
@ -999,7 +1138,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1011,7 +1150,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if($slab_value['si'] == $employee_received_si)
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'])
|
||||
{
|
||||
$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']);
|
||||
@ -1019,7 +1158,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1030,7 +1169,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if($slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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']);
|
||||
@ -1038,7 +1177,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1053,7 +1192,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_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' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
{
|
||||
// dd($slab_value);
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
@ -1062,7 +1201,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1074,7 +1213,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_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' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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']);
|
||||
@ -1082,7 +1221,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1094,7 +1233,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_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' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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'];
|
||||
@ -1103,7 +1242,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1116,7 +1255,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_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' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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']);
|
||||
@ -1124,7 +1263,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
|
||||
$is_match_found = true;
|
||||
break;
|
||||
@ -1138,7 +1277,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['grade'] == $employee_received_band && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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']['basic_cover_si'] = $slab_value['si'];
|
||||
@ -1147,7 +1286,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1160,7 +1299,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self'])) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_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']);
|
||||
@ -1168,7 +1307,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','');
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1176,7 +1315,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
break;
|
||||
case "10":
|
||||
//GMC - Maximum age of Dependents
|
||||
$max_age = $emp_data['temp']['maxage'];
|
||||
$max_age = $emp_data['temp']['max_age'];
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
// echo $emp_data['name'].'-'.$employee_received_si.'<br>';
|
||||
// echo $emp_data['temp']['grid_type'].'<br>';
|
||||
@ -1184,10 +1323,10 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
// echo $slab_value['si'].'-'.$slab_value['age_from'].'-'.$slab_value['age_to'].'-'.$max_age.'<br>';
|
||||
if( $slab_value['si'] == $employee_received_si &&
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] &&
|
||||
($slab_value['age_from'] <= $max_age && $slab_value['age_to'] >= $max_age) &&
|
||||
(($slab_value['premium_type'] == 1 &&
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self'])) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ) )
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ) )
|
||||
{
|
||||
$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'];
|
||||
@ -1195,7 +1334,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''));
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1203,16 +1342,16 @@ if (!function_exists('premium_calculation_manager'))
|
||||
break;
|
||||
case "11":
|
||||
//GMC - Maximum count per Family
|
||||
$max_count = $emp_data['temp']['maxcount'];
|
||||
$employee_received_band = $emp_data['temp']['band'];
|
||||
$max_count = $emp_data['temp']['max_count'];
|
||||
$employee_received_band = $emp_data['band'];
|
||||
// echo $employee_received_band;
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
$emp_data['policy_details']['basic_cover_si'] = null;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && (($slab_value['premium_type'] == 1 &&
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self'])) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 &&
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
{
|
||||
//calculate premium based on count
|
||||
// echo $emp_data['name'];
|
||||
@ -1223,9 +1362,9 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$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 + 1);
|
||||
$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']['premium'] = get_premium_for_si(slab_details: $temp_slab_rates,si_amount: $familiy_si_covered,band: $employee_received_band,unit:$emp_data['unit']);
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''));
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1241,7 +1380,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['basic_cover_si'] = null;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if( $slab_value['si'] == $employee_received_si && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) )) )
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
{
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
|
||||
@ -1250,7 +1389,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''));
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1266,7 +1405,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if( $slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['primary_rack_rate_acting_self'] || $emp_data['temp']['additional_rack_rate_acting_self']) )) )
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
{
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
|
||||
@ -1275,7 +1414,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['days'] = (calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days + 1);
|
||||
$emp_data['policy_details']['premium'] = $slab_value['premium'];
|
||||
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days);
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
|
||||
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''));
|
||||
$is_match_found = true;
|
||||
break;
|
||||
}
|
||||
@ -1295,7 +1434,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
{
|
||||
$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']['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;
|
||||
@ -1347,6 +1486,7 @@ if (!function_exists('transform_db_data_to_excel'))
|
||||
$row[14] = $value['pre_existing_alignments'];
|
||||
$row[16] = isset($value['date_of_exit']) ? change_date_format($value['date_of_exit'], 'Y-m-d', 'd-M-Y') : NULL;
|
||||
$row[17] = $value['reason_for_exit'];
|
||||
$row[18] = $value['unit'];
|
||||
|
||||
|
||||
$row[7] = isset($value['date_coverage']) ? change_date_format($value['date_coverage'], 'Y-m-d', 'd-M-Y') : NULL;
|
||||
@ -1461,11 +1601,12 @@ if(!function_exists('replace_original_data'))
|
||||
|
||||
if(!function_exists('get_premium_for_si'))
|
||||
{
|
||||
function get_premium_for_si(array $slab_details,string $si_amount,string $band)
|
||||
function get_premium_for_si(array $slab_details,string $si_amount,string $band,string $unit)
|
||||
{
|
||||
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
|
||||
// dd($slab_details);
|
||||
foreach ($slab_details as $skey => $slab_value)
|
||||
{
|
||||
if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['max_si'] == 0)
|
||||
if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['unit'] == $unit && $slab_value['max_si'] == 0)
|
||||
{
|
||||
return $slab_value['premium'];
|
||||
}
|
||||
@ -1632,4 +1773,254 @@ if(!function_exists('transform_enrollment_row_to_inception_row'))
|
||||
$res[17] = null; // inception: reason_for_exit (Reason for exit) -> No match in enrollment
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('get_familiy_composition'))
|
||||
{
|
||||
|
||||
function get_familiy_composition($family_data)
|
||||
{
|
||||
// dd($family_data);
|
||||
$family_composition = [];
|
||||
$slug = \Config\Services::slug();
|
||||
foreach ($family_data as $key => $row)
|
||||
{
|
||||
// Kint::dump($row);
|
||||
$relationship = $slug->slugify($row[5]);
|
||||
// echo $relationship;
|
||||
if($relationship == 'self')
|
||||
{
|
||||
$family_composition['self'] = 1;
|
||||
}
|
||||
else if(!array_key_exists('self', $family_composition))
|
||||
{
|
||||
$family_composition['self'] = 0;
|
||||
}
|
||||
|
||||
if($relationship == 'spouse')
|
||||
{
|
||||
$family_composition['spouse'] = 1;
|
||||
}
|
||||
else if(!array_key_exists('spouse', $family_composition))
|
||||
{
|
||||
$family_composition['spouse'] = 0;
|
||||
}
|
||||
|
||||
if($relationship == 'son' || $relationship == 'daughter')
|
||||
{
|
||||
$family_composition['childrens'] = (isset($family_composition['childrens']) ? $family_composition['childrens'] + 1 : 1);
|
||||
}
|
||||
else if(!array_key_exists('childrens', $family_composition))
|
||||
{
|
||||
$family_composition['childrens'] = 0;
|
||||
}
|
||||
|
||||
if($relationship == 'father' || $relationship == 'mother')
|
||||
{
|
||||
$family_composition['parents'] = (isset($family_composition['parents']) ? $family_composition['parents'] + 1 : 1);
|
||||
}
|
||||
else if(!array_key_exists('parents', $family_composition))
|
||||
{
|
||||
$family_composition['parents'] = 0;
|
||||
}
|
||||
|
||||
if($relationship == 'father-in-law' || $relationship == 'mother-in-law')
|
||||
{
|
||||
$family_composition['parents-in-law'] = (isset($family_composition['parents-in-law']) ? $family_composition['parents-in-law'] + 1 : 1);
|
||||
}
|
||||
else if(!array_key_exists('parents-in-law', $family_composition))
|
||||
{
|
||||
$family_composition['parents-in-law'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ($family_composition);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('compare_incoming_family_slab_with_configured_slab'))
|
||||
{
|
||||
// function compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition)
|
||||
// {
|
||||
// $relationship_mapping = [
|
||||
// "self" => ["self"],
|
||||
// "spouse" => ["spouse"],
|
||||
// "childrens" => ["son", "daughter"],
|
||||
// "parents" => ["father", "mother"],
|
||||
// "parents-in-law" => ["father-in-law", "mother-in-law"],
|
||||
// "either-parents-pil" => ["either-parents-pil"]
|
||||
// ];
|
||||
|
||||
// $result = ['is_applicable' => false,'applicable_members' => []];
|
||||
// $configured_familiy_composition = json_decode($slab['slab_rates'][0]['additional_relationship'],true);
|
||||
// Kint::dump($incoming_familiy_composition);//die();
|
||||
// Kint::dump($configured_familiy_composition);//die();
|
||||
// unset($configured_familiy_composition['either-parents-pil']);
|
||||
// unset($configured_familiy_composition['elders_count']);
|
||||
|
||||
// if(count($configured_familiy_composition))
|
||||
// {
|
||||
// foreach($configured_familiy_composition as $key => $value)
|
||||
// {
|
||||
// if($value != 'NA')
|
||||
// {
|
||||
// // echo 'OUTSIDE - ' . $value . $incoming_familiy_composition[$key];
|
||||
// if(isset($incoming_familiy_composition[$key]) && ($incoming_familiy_composition[$key] == $value || $value == 'any') )
|
||||
// {
|
||||
// // echo 'INSIDE - ' . $value;
|
||||
// $result['is_applicable'] = true;
|
||||
// $result['applicable_members'] = array_merge($result['applicable_members'],$relationship_mapping[ $key ]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $result['is_applicable'] = false;
|
||||
// $result['applicable_members'] = [];
|
||||
// // break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $result['is_applicable'] = false;
|
||||
// $result['applicable_members'] = [];
|
||||
// }
|
||||
// // dd($result);
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
function compare_incoming_family_slab_with_configured_slab($slab, $incoming_familiy_composition)
|
||||
{
|
||||
$relationship_mapping = [
|
||||
"self" => ["self"],
|
||||
"spouse" => ["spouse"],
|
||||
"childrens" => ["son", "daughter"],
|
||||
"parents" => ["father", "mother"],
|
||||
"parents-in-law" => ["father-in-law", "mother-in-law"],
|
||||
"either-parents-pil" => ["either-parents-pil"]
|
||||
];
|
||||
|
||||
$result = ['is_applicable' => false, 'applicable_members' => []];
|
||||
$configured_familiy_composition = json_decode($slab['slab_rates'][0]['additional_relationship'], true);
|
||||
|
||||
// Remove unnecessary keys
|
||||
kint::dump($incoming_familiy_composition);
|
||||
kint::dump($configured_familiy_composition);
|
||||
unset($configured_familiy_composition['either-parents-pil']);
|
||||
unset($configured_familiy_composition['elders_count']);
|
||||
|
||||
// foreach ($configured_familiy_composition as $key => $value) {
|
||||
// if ($value === 0) {
|
||||
// // If any relationship is zero, make the rack rate not applicable
|
||||
// return $result;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (count($configured_familiy_composition)) {
|
||||
foreach ($configured_familiy_composition as $key => $value) {
|
||||
if ( $value != 'NA') {
|
||||
if (isset($incoming_familiy_composition[$key])) {
|
||||
if ($incoming_familiy_composition[$key] == $value || $value == 'any') {
|
||||
$result['is_applicable'] = true;
|
||||
$result['applicable_members'] = array_merge($result['applicable_members'], $relationship_mapping[$key]);
|
||||
} else {
|
||||
$result['is_applicable'] = false;
|
||||
$result['applicable_members'] = [];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$result['is_applicable'] = false;
|
||||
$result['applicable_members'] = [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result['is_applicable'] = false;
|
||||
$result['applicable_members'] = [];
|
||||
}
|
||||
// dd($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!function_exists('get_applicable_familiy_members'))
|
||||
{
|
||||
function get_applicable_familiy_members($family_data,$applicable_members)
|
||||
{
|
||||
$slug = \Config\Services::slug();
|
||||
$result = ['index' => [],'max_age'=> [],'max_count' => 0];
|
||||
foreach ($family_data as $index => $family_member)
|
||||
{
|
||||
if(in_array($slug->slugify($family_member[5]),$applicable_members))
|
||||
{
|
||||
$result['index'] = array_merge($result['index'],[$index]);
|
||||
$result['max_age'] = array_merge($result['max_age'],[calculate_days_bw_dates(from_date: $family_member[3])->y]);
|
||||
}
|
||||
}
|
||||
$result['max_count'] = count($result['index']);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('check_unit'))
|
||||
{
|
||||
function check_unit($row,$existing_units)
|
||||
{
|
||||
|
||||
|
||||
if(in_array($row['current_action'], ['I','A','MI']) )
|
||||
{
|
||||
if(count($existing_units) == 1)
|
||||
{
|
||||
if(empty(trim($row[18])))
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
}
|
||||
|
||||
if(strtolower($row[5]) == 'self')
|
||||
{
|
||||
if(in_array(trim($row[18]),$existing_units)) //18 is unit name
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
else if(!empty(trim($row[18])))
|
||||
{
|
||||
return array('status' => false,'error' => 'wrong unit name');
|
||||
}
|
||||
else
|
||||
{
|
||||
return array('status' => false,'error' => 'name of the unit is mandantory');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty(trim($row[18])))
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(in_array(trim($row[18]),$existing_units)) //18 is unit name
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array('status' => false,'error' => 'wrong unit name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,7 +149,7 @@ class sendMailNotification
|
||||
return $wholeData;
|
||||
} else if($action == 'member_review_and_summary_mail'){
|
||||
|
||||
$array_list = $params['array_list'];
|
||||
$array_list = $params['array_list'];//employeee lst
|
||||
$client_policy_id = $params['client_policy_id'];
|
||||
$emp_code = $params['emp_code'];
|
||||
$client_id = $params['client_id'];
|
||||
|
||||
@ -39,4 +39,14 @@ class ClientBranchModel extends Model
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getExisitingUnits(string $client_id,string $client_branch_id)
|
||||
{
|
||||
$res = $this->select('client_branch.units')
|
||||
->where('client_id', $client_id)
|
||||
->where('id', $client_branch_id)
|
||||
->find();
|
||||
//->getResult();
|
||||
return (json_decode($res[0]['units']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ class EmployeeModel extends Model
|
||||
"client_branch_id",
|
||||
"token_time_out",
|
||||
"emp_type",
|
||||
"unit",
|
||||
"mpin"
|
||||
];
|
||||
|
||||
@ -105,7 +106,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 = [],array $relationship = [],array $client_branch_id = [])
|
||||
{
|
||||
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_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','policies.name as policy_name','client_policy.is_addon'])
|
||||
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_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','employees.unit','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','policies.name as policy_name','client_policy.is_addon'])
|
||||
->join('employee_polices', 'employee_polices.employee_id = employees.id')
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
@ -158,9 +159,9 @@ class EmployeeModel extends Model
|
||||
}
|
||||
|
||||
// for EMP rest API process do not change
|
||||
public function checkExistingEmployee($arr)
|
||||
public function checkExistingEmployee($arr,$client_branch_id)
|
||||
{
|
||||
return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->where('client_id', $arr['client_id'])->first();
|
||||
return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->where('client_id', $arr['client_id'])->where('client_branch_id', $client_branch_id)->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ class FileModel extends Model
|
||||
"client_id",
|
||||
"policy_id",
|
||||
"client_branch_id",
|
||||
"uploaded_by"
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -60,9 +60,20 @@ class PolicesModel extends Model
|
||||
|
||||
if(isset($premium_slab_data[0]['policy_grid_id']))
|
||||
{
|
||||
$grid_id = $premium_slab_data[0]['policy_grid_id'];
|
||||
$policyGridModel = new PolicyGridModel();
|
||||
$grid_type = $policyGridModel->find($grid_id);
|
||||
$pre_grid_id = 0;
|
||||
$grid_type = [];
|
||||
foreach ($premium_slab_data as $key => $value)
|
||||
{
|
||||
if($value['policy_grid_id'] != $pre_grid_id)
|
||||
{
|
||||
$grid_id = $value['policy_grid_id'];
|
||||
$policyGridModel = new PolicyGridModel();
|
||||
$grid_type = $policyGridModel->find($grid_id);
|
||||
$premium_slab_data[$key]['grid_master'] = $grid_type;
|
||||
}
|
||||
$premium_slab_data[$key]['grid_master'] = $grid_type;
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($additional_premium_slab_data[0]['policy_grid_id']))
|
||||
{
|
||||
|
||||
689
app/Views/rack_rate_test.php
Normal file
689
app/Views/rack_rate_test.php
Normal file
@ -0,0 +1,689 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
|
||||
position: relative;
|
||||
left: 79px;
|
||||
}
|
||||
|
||||
/* Add styles for the table and its elements as needed */
|
||||
.disabled {
|
||||
background-color: #ddd; /* Set desired gray color for disabled rows */
|
||||
}
|
||||
|
||||
.small-width {
|
||||
width: 5%;
|
||||
}
|
||||
.medium-width {
|
||||
width: 10%;
|
||||
}
|
||||
.large-width {
|
||||
width: 15%;
|
||||
}
|
||||
.extra-large-width {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h5 class="m-1">
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</h5>
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>Client</label> <br />
|
||||
<select class="form-control" id="clients">
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Branch</label> <br />
|
||||
<select name="branch_id" class="form-control" id="branch_id">
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy</label> <br />
|
||||
<select class="form-control" id="policies">
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="col-6" style="text-align: right;">
|
||||
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
|
||||
</div> -->
|
||||
<div class="col-12" style="text-align: right;">
|
||||
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="calculatePremium(event);" >calc</a>
|
||||
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="addRowToTable(event);">+</a>
|
||||
</div>
|
||||
<!-- <button onclick="addRowToTable()">Add Row</button> -->
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row" id="client_list">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<!-- <div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Endorsement List</h4>
|
||||
</div> -->
|
||||
<div id="suggestion-box" style="display: none; position: absolute; background-color: #fff; border: 1px solid #ccc; padding: 5px; z-index: 100;">
|
||||
Suggestions, pick any one
|
||||
<ul id="suggestions"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="emptable">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="small-width">SNO</th>
|
||||
<th class="small-width">Emp code</th>
|
||||
<th class="large-width">Name</th>
|
||||
<th class="large-width">DOB</th>
|
||||
<th class="small-width">Gender</th>
|
||||
<th class="medium-width">Relation</th>
|
||||
<th class="large-width">SI</th>
|
||||
<th class="medium-width">DOC</th>
|
||||
<th class="medium-width">Basic pay</th>
|
||||
<th class="small-width">Band</th>
|
||||
<th class="small-width">Unit</th>
|
||||
<th class="small-width">Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id='emptablebody'>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" >
|
||||
<div class="modal-dialog modal-dialog-centered" style="max-width:80%;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Center modal</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h5>Overflowing text to show scroll behavior</h5>
|
||||
<p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
|
||||
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Initialize select2
|
||||
$("#clients").select2();
|
||||
$("#policies").select2();
|
||||
$("#branch_id").select2();
|
||||
});
|
||||
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
var clientPoliciesWithBranch = {
|
||||
policies: []
|
||||
};
|
||||
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
||||
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("window loaded");
|
||||
// $('#centermodal').modal('show');
|
||||
fetchClientPolicies();
|
||||
});
|
||||
|
||||
|
||||
function fetchClientPolicies() {
|
||||
|
||||
$('#loader').show();
|
||||
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
||||
console.log('fetchClientPolicies');
|
||||
// console.log(apiURL);
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data);
|
||||
|
||||
|
||||
response.data.forEach(policy => {
|
||||
// console.log('policies', policy.policies);
|
||||
policy.policies.forEach(p => {
|
||||
clientPoliciesWithBranch.policies.push(p);
|
||||
});
|
||||
});
|
||||
|
||||
// console.log(clientPolicies);
|
||||
appendClients(clientPolicies);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_id) {
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
// console.log(typeof item.id)
|
||||
return item.id == client_id;
|
||||
});
|
||||
appendBranch(foundPolicies.branchs);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_branch_id) {
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === client_branch_id;
|
||||
});
|
||||
|
||||
if (foundPolicies) {
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies(foundPolicies);
|
||||
} else {
|
||||
console.log('No policies found for the selected client');
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
|
||||
|
||||
function appendClients(data) {
|
||||
|
||||
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
});
|
||||
if (clientID == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#clients').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendBranch(data) {
|
||||
|
||||
$('#branch_id').empty();
|
||||
$('#branch_id').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.branch_name
|
||||
});
|
||||
if (client_branch_id == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#branch_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendPolicies(data) {
|
||||
|
||||
$('#policies').empty();
|
||||
$('#policies').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
|
||||
// console.log(PolicyID)
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.client_policy_id,
|
||||
text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
|
||||
});
|
||||
if (PolicyID == item.client_policy_id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#policies').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#clients').on('change', function() {
|
||||
|
||||
$('#policies').empty();
|
||||
$('#policies').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
// console.log(selectedClient);
|
||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||||
|
||||
// Check if the selected option exists in apiData
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
return item.id === selectedClient;
|
||||
});
|
||||
// console.log(foundPolicies.branchs);
|
||||
appendBranch(foundPolicies.branchs);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#branch_id').on('change', function() {
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
|
||||
// console.log('selectedBranch', selectedClient);
|
||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === selectedClient;
|
||||
});
|
||||
|
||||
|
||||
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
||||
|
||||
appendPolicies(foundPolicies);
|
||||
toastr.warning('No policies found for the selected client branch.');
|
||||
|
||||
} else {
|
||||
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies(foundPolicies);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Function to convert object to query parameters
|
||||
function objectToQueryString(obj) {
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function calculatePremium() {
|
||||
event.preventDefault(); // Prevent default action
|
||||
let table = document.getElementById('emptable');
|
||||
let tabledata = getTableDataAsJson(table);
|
||||
// return;
|
||||
var client_id = $('#clients').val();
|
||||
var policy_id = $('#policies').val();
|
||||
var branch_id = $('#branch_id').val();
|
||||
// console.log(client_id + '-' + policy_id);
|
||||
// if (client_id == '0' || policy_id == '0') {
|
||||
// alert('Please select values in both dropdowns.');
|
||||
// return;
|
||||
// }
|
||||
|
||||
var queryParams = {
|
||||
client_id: client_id,
|
||||
policy_id: policy_id,
|
||||
branch_id: branch_id,
|
||||
data: tabledata,
|
||||
};
|
||||
|
||||
|
||||
// $('#loader').show();
|
||||
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-rack-rate';
|
||||
console.log('calculatePremium');
|
||||
// console.log(apiURL);
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
data: JSON.stringify(queryParams),
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('centermodal'), { keyboard: true });
|
||||
|
||||
// Show the modal
|
||||
myModal.show();
|
||||
// return;
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
// $("#centermodal").modal('show');
|
||||
console.log('success');
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
|
||||
// $('#loader').hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
document.getElementById('toggleIcon').addEventListener('click', function() {
|
||||
var icon = document.getElementById('icon');
|
||||
icon.classList.toggle('mdi-chevron-down');
|
||||
icon.classList.toggle('mdi-chevron-up');
|
||||
});
|
||||
|
||||
|
||||
function formatNumberToIndianLocale(value, field_name, action) {
|
||||
|
||||
// Check if the value is a valid number (either as a number or as a string)
|
||||
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
|
||||
|
||||
// Convert the value to a number and format it using Indian English locale
|
||||
var return_val = parseFloat(value).toLocaleString('en-IN');
|
||||
|
||||
if (field_name == 'Period of non coverage') {
|
||||
|
||||
return value + ' days';
|
||||
}
|
||||
|
||||
if (field_name == 'Total Amount') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be Refunded )';
|
||||
}
|
||||
|
||||
if (field_name == 'Total') {
|
||||
|
||||
if (action == 'd') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be Refunded )';
|
||||
|
||||
} else if (action == 'si') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be paid )';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '₹ ' + return_val;
|
||||
|
||||
} else {
|
||||
// Return the original value if it's not a valid number
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
$('.close').click(function() {
|
||||
|
||||
$('#table_data').empty();
|
||||
})
|
||||
|
||||
const suggestionBox = document.getElementById("suggestion-box");
|
||||
const suggestionsList = document.getElementById("suggestions");
|
||||
|
||||
function addRowToTable() {
|
||||
const tableBody = document.getElementById("emptablebody");
|
||||
const existingRowCount = tableBody.rows.length;
|
||||
|
||||
const newRow = document.createElement("tr");
|
||||
|
||||
let newCell;
|
||||
|
||||
// SNO with auto-increment
|
||||
newCell = document.createElement("td");
|
||||
newCell.textContent = existingRowCount + 1;
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// Emp code (assuming you want an input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = 'FAM001';
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// Name (assuming you want an input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = '';
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// **HERE'S WHERE YOU ADD CELLS FOR OTHER COLUMNS**
|
||||
|
||||
// DOB (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
// newCell.innerHTML = '<input type="date" class="form-control">'; // Adjust for your needs
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// Gender (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
// newCell.addEventListener("input", handleInput);
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// relationship (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newCell.addEventListener("input", handleInput);
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// SI (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// DOC (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// BP (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
// band (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
// unit (assuming you want a date input field)
|
||||
newCell = document.createElement("td");
|
||||
newCell.innerHTML = ''; // Adjust for your needs
|
||||
newCell.contentEditable = "true"; // Make the cell editable (if needed)
|
||||
newCell.style.border = "1px solid";
|
||||
newRow.appendChild(newCell);
|
||||
|
||||
// ... Add remaining cells and content
|
||||
|
||||
// Create a checkbox for disabled
|
||||
newCell = document.createElement("td");
|
||||
|
||||
newCell.style.border = "1px solid";
|
||||
newCell.innerHTML = '<i class="material-icons" onclick="deleteRow(event)"></i>';
|
||||
const checkBox = document.createElement("input");
|
||||
checkBox.type = "checkbox";
|
||||
checkBox.addEventListener("change", function() {
|
||||
newRow.classList.toggle("disabled");
|
||||
});
|
||||
newCell.appendChild(checkBox);
|
||||
newRow.appendChild(newCell);
|
||||
tableBody.appendChild(newRow);
|
||||
}
|
||||
|
||||
function deleteRow(button) {
|
||||
// console.log(button.target.parentElement.parentElement);
|
||||
// console.log(button.parentNode.parentNode);
|
||||
const tableBody = document.getElementById("emptablebody");
|
||||
const rowToDelete = button.target.parentElement.parentElement;
|
||||
tableBody.removeChild(rowToDelete);
|
||||
}
|
||||
|
||||
let focusedCell;
|
||||
|
||||
function handleInput(event) {
|
||||
focusedCell = event.target;
|
||||
const inputValue = focusedCell.textContent.trim();
|
||||
if (inputValue.length > 1) { // Show suggestions only after 2 characters
|
||||
showSuggestions(inputValue);
|
||||
} else {
|
||||
hideSuggestions();
|
||||
}
|
||||
}
|
||||
|
||||
function showSuggestions(inputValue) {
|
||||
console.log(inputValue);
|
||||
|
||||
const suggestions = ["Self", "Spouse", "Son","Daughter","Father","Mother","Father in law",'Mother in law','M','F']; // Replace with your logic or API call
|
||||
const filteredSuggestions = suggestions.filter(s => s.toLowerCase().startsWith(inputValue.toLowerCase()));
|
||||
console.log(filteredSuggestions);
|
||||
console.log(filteredSuggestions.length);
|
||||
suggestionsList.innerHTML = ""; // Clear previous suggestions
|
||||
if(filteredSuggestions.length)
|
||||
{
|
||||
suggestionBox.style.display = "block"; // Show the suggestion box
|
||||
for (const suggestion of filteredSuggestions) {
|
||||
const listItem = document.createElement("li");
|
||||
listItem.textContent = suggestion;
|
||||
listItem.addEventListener("click", function() {
|
||||
console.log(focusedCell);
|
||||
if (focusedCell) { // Check if a cell is focused
|
||||
focusedCell.textContent = suggestion; // Set the selected suggestion in the focused cell
|
||||
}
|
||||
hideSuggestions();
|
||||
});
|
||||
suggestionsList.appendChild(listItem);
|
||||
}
|
||||
|
||||
// Position the suggestion box near the input field (optional)
|
||||
const cellRect = focusedCell.parentNode.getBoundingClientRect();
|
||||
// console.log(cellRect.left);
|
||||
// console.log(cellRect.right);
|
||||
suggestionBox.style.left = 170 + "px";
|
||||
suggestionBox.style.top = 50 + "px";
|
||||
}
|
||||
}
|
||||
|
||||
function hideSuggestions() {
|
||||
suggestionBox.style.display = "none";
|
||||
suggestionsList.innerHTML = ""; // Clear suggestions
|
||||
}
|
||||
|
||||
|
||||
function getTableDataAsJson(table) {
|
||||
// let index = {'1' : 'sno','2' : 'emp_code'};
|
||||
const tableBody = table.querySelector("tbody");
|
||||
if (!tableBody) {
|
||||
console.error("Error: Table does not have a tbody element.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get all rows
|
||||
const rows = tableBody.querySelectorAll("tr");
|
||||
|
||||
// Create an empty array to store JSON data
|
||||
const jsonData = [];
|
||||
|
||||
// Loop through each row
|
||||
for (const row of rows) {
|
||||
const cells = row.querySelectorAll("td");
|
||||
const rowData = {}; // Create an object to hold cell data
|
||||
|
||||
// Loop through each cell in the row
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
const cellContent = cells[i].textContent.trim();
|
||||
// You can adjust the property name logic if needed (e.g., use cell index as key)
|
||||
const isCheckbox = i === 11;
|
||||
if (isCheckbox) {
|
||||
rowData[`column${i + 1}`] = cells[i].querySelector("input[type='checkbox']").checked;
|
||||
} else {
|
||||
rowData[`column${i + 1}`] = cellContent; // Use descriptive column names (optional)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add the row data object to the JSON array
|
||||
jsonData.push(rowData);
|
||||
}
|
||||
console.log(jsonData);
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
</script>
|
||||
BIN
public/sample_excel/enrollment.xlsx
Normal file
BIN
public/sample_excel/enrollment.xlsx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
228
tests/unit/PremiumCalculationTestNew.php
Normal file
228
tests/unit/PremiumCalculationTestNew.php
Normal file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use Tests\Support\Libraries\ConfigReader;
|
||||
|
||||
use App\Controllers\EmployeeServiceController;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
use Kint\Kint;
|
||||
|
||||
class PremiumCalculationTestNew extends CIUnitTestCase
|
||||
{
|
||||
use DatabaseTestTrait;
|
||||
protected $migrate = false;
|
||||
|
||||
//primary, single parent, double parent, and double parent in law
|
||||
public function testPremiumCalculation($MY_PARAM = 'default')
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
$param = getenv('MY_PARAM');
|
||||
// echo isset($param) && $param != NULL ? $param : $MY_PARAM;
|
||||
|
||||
//first slab
|
||||
$primary_relationship = '{"self":1,"spouse":"any","childrens":"any","parents":"NA","parents-in-law":"NA","either-parents-pil":0}';
|
||||
$primary_grid_id = 7;
|
||||
$primary_grid_type = 2;
|
||||
$primary_max_si = 35000000;
|
||||
$primary_grid_name = 'dependent + age + SI';
|
||||
$primary_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $primary_grid_id,'policy_grid_type' => $primary_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
|
||||
$primary_slabs = [
|
||||
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 500, 'max_si' => $primary_max_si,'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 3500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 4500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => $primary_max_si, 'premium' => 15000, 'max_si' => 0, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 30000000, 'premium' => 30000, 'max_si' => 0, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship]
|
||||
];
|
||||
|
||||
//second slab
|
||||
$second_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":"any","parents-in-law":"NA","either-parents-pil":0}';
|
||||
$second_grid_id = 10;
|
||||
$second_grid_type = 1;
|
||||
$second_max_si = 35000000;
|
||||
$second_grid_name = 'max age';
|
||||
$second_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $second_grid_id,'policy_grid_type' => $second_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
|
||||
$second_slabs = [
|
||||
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 700, 'max_si' => 2500000,'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship ],
|
||||
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1400, 'max_si' => 2000000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2300, 'max_si' => 1800000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2750, 'max_si' => 150000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3500, 'max_si' => 130000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 4250, 'max_si' => 10, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4950, 'max_si' => 5, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 5500, 'max_si' => 5, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship]
|
||||
|
||||
];
|
||||
|
||||
// third slab
|
||||
$third_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":1,"parents-in-law":"NA","either-parents-pil":0}';
|
||||
$third_grid_id = 7;
|
||||
$third_grid_type = 1;
|
||||
$third_max_si = 35000000;
|
||||
$third_grid_name = 'age band';
|
||||
$third_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $third_grid_id,'policy_grid_type' => $third_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
|
||||
$third_slabs = [
|
||||
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 701, 'max_si' => 2500000,'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship ],
|
||||
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1401, 'max_si' => 2000000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2301, 'max_si' => 1800000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2751, 'max_si' => 150000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3501, 'max_si' => 130000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 4251, 'max_si' => 10, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4951, 'max_si' => 5, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 5501, 'max_si' => 5, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship]
|
||||
|
||||
];
|
||||
|
||||
|
||||
// fourth slab
|
||||
$fourth_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":"NA","parents-in-law":2,"either-parents-pil":0}';
|
||||
$fourth_grid_id = 11;
|
||||
$fourth_grid_type = 2;
|
||||
$fourth_max_si = 8000000;
|
||||
$fourth_grid_name = 'age band';
|
||||
$fourth_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $fourth_grid_id,'policy_grid_type' => $fourth_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
|
||||
$fourth_slabs = [
|
||||
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 1111, 'max_si' => $fourth_max_si,'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship ],
|
||||
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 2222, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 3333, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 4444, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 5555, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 6666, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 7777, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 8888, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 8000000, 'premium' => 9999, 'max_si' => 0, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship]
|
||||
|
||||
];
|
||||
|
||||
//overall rack rate
|
||||
$over_all_rack_details = [ 'primary' => [ "slab_rates" => $primary_slabs,'grid_master' => $primary_grid_master],
|
||||
'two parent' => ["slab_rates" => $second_slabs,'grid_master' => $second_grid_master],
|
||||
'single parent' => ["slab_rates" => $third_slabs,'grid_master' => $third_grid_master],
|
||||
'double_parent_in_law' => ["slab_rates" => $fourth_slabs,'grid_master' => $fourth_grid_master]
|
||||
|
||||
];
|
||||
|
||||
// Sample family data
|
||||
$family_details = [
|
||||
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '',''],
|
||||
[1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', ''],
|
||||
|
||||
// [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
//[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '',''],
|
||||
[6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '',''],
|
||||
];
|
||||
|
||||
// Sample policy terms
|
||||
$policy_terms = [
|
||||
'family_floater' => true,
|
||||
'family_floaters' => [
|
||||
'self' => 1,
|
||||
'spouse' => 1,
|
||||
'childrens' => 2,
|
||||
'either-parents-pil' => 0,
|
||||
'parents' => 2,
|
||||
'parents-in-law' => 2,
|
||||
],
|
||||
];
|
||||
//re organize over_all_rack_details
|
||||
$all_rack_rates = [];
|
||||
foreach ($over_all_rack_details as $key => $value) {
|
||||
foreach ($value['slab_rates'] as $skey => $svalue) {
|
||||
$svalue['rack_rate_name'] = $key;
|
||||
$svalue['grid_master'] = $value['grid_master'];
|
||||
$all_rack_rates[] = $svalue;
|
||||
}
|
||||
// dd($value['slab_rates']);
|
||||
}
|
||||
$policy_details = ['base_policy' => null,"policy_start_date" => "2023-02-02","policy_end_date" => "2024-02-02","policy_terms" => json_encode($policy_terms),'gst' => 5];
|
||||
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1];
|
||||
$data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file);
|
||||
//****************************onboard process*******************
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
// $empServiceController->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
||||
|
||||
// dd();
|
||||
//******************************** onboard process****************
|
||||
$policy_created_count = 0;
|
||||
echo "\n";
|
||||
$result_to_display = [];
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if(is_array($value))
|
||||
{
|
||||
$result_to_display[$key]['emp_code'] = $value['emp_code'];
|
||||
$result_to_display[$key]['name'] = $value['name'].'('.calculate_days_bw_dates($value['dob'])->y.')';
|
||||
$result_to_display[$key]['relation'] = $value['relationship'];
|
||||
$temp_grid = ($value['temp']['grid_name']);
|
||||
$temp_grid_type = ($value['temp']['premium_type']);
|
||||
$temp_grid_type = ($temp_grid_type == 1 ? 'S' : 'I');
|
||||
$result_to_display[$key]['premium_type'] = $temp_grid.'#'.$value['temp']['grid_id'].'#'.
|
||||
($value['temp']['acting_self'] == true ? 'Self' : 'No' ) .'#'. ($temp_grid_type) ;
|
||||
$result_to_display[$key]['si'] = $value['policy_details']['basic_cover_si'];
|
||||
$result_to_display[$key]['premium'] = $value['policy_details']['premium'];
|
||||
$result_to_display[$key]['policy days'] = (calculate_days_bw_dates($policy_details['policy_start_date'],$policy_details['policy_end_date'])->days + 1);
|
||||
$result_to_display[$key]['no of days'] = $value['policy_details']['days'];
|
||||
$result_to_display[$key]['rata_premimum'] = $value['policy_details']['rata_premimum'];
|
||||
$result_to_display[$key]['gst'] = $value['policy_details']['gst'];
|
||||
|
||||
if(!empty($value['policy_details']['premium'])){ $policy_created_count = $policy_created_count + 1; }
|
||||
}
|
||||
}
|
||||
|
||||
TableDisplay::displayTable($result_to_display);
|
||||
$this->assertTrue(($policy_created_count >= 1 || $policy_created_count = 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TableDisplay
|
||||
{
|
||||
public static function displayTable(array $data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
echo "No data to display.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate column widths
|
||||
$columns = array_keys($data[0]);
|
||||
$widths = array_map(function ($col) use ($data) {
|
||||
$maxWidth = strlen($col);
|
||||
foreach ($data as $row) {
|
||||
$maxWidth = max($maxWidth, strlen($row[$col]));
|
||||
}
|
||||
return $maxWidth;
|
||||
}, $columns);
|
||||
|
||||
// Print header
|
||||
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
|
||||
foreach ($columns as $i => $col) {
|
||||
echo str_pad($col, $widths[$i]) . " | ";
|
||||
}
|
||||
echo PHP_EOL;
|
||||
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
|
||||
|
||||
// Print rows
|
||||
foreach ($data as $row) {
|
||||
foreach ($columns as $i => $col) {
|
||||
echo str_pad($row[$col], $widths[$i]) . " | ";
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
}
|
||||
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user