FIX_SI_ENHANEMENT_ISSUE_IN_DATA_VALIDATION

This commit is contained in:
velz 2024-06-04 09:37:24 +05:30
parent c635cebbe3
commit 91343c736c

View File

@ -349,110 +349,114 @@ class EmployeeServiceController extends AdminController
unset($excel_data[0]); unset($excel_data[0]);
$relationship = $this->general_relationships; $relationship = $this->general_relationships;
$employee_data_group_by_family = data_group_by_family($excel_data);
$is_self_available_in_policy_terms = false; if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A
if($policy_details['policy_type_id'] == 3) // GMC parents
{ {
$temp = $policy_terms['family_floaters']; $employee_data_group_by_family = data_group_by_family($excel_data);
$temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []);
$is_self_available_in_policy_terms = isset($temp['self']) ? true : false;
}
// dd($employee_data_group_by_family);
foreach ($employee_data_group_by_family as $emp_id => $family)
{
//if action is DA then get all familiy members,transfrom them into excel array, addd data source as db or excel $is_self_available_in_policy_terms = false;
if($file['action'] == 'dependent_addition') if($policy_details['policy_type_id'] == 3) // GMC parents
{
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]);
// dd(($existing_famility_details));
//transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites
$existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
// dd(array_keys($existing_famility_details[0]));
$family = array_merge($family,$existing_famility_details);
// kint::dump($family);
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
}
// kint::dump($family);//die();
//check name dup within a family
if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')
{
$res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data
// dd($res);
if(count($res))
{ {
foreach($res as $k => $rowid) $temp = $policy_terms['family_floaters'];
$temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []);
$is_self_available_in_policy_terms = isset($temp['self']) ? true : false;
}
// dd($employee_data_group_by_family);
foreach ($employee_data_group_by_family as $emp_id => $family)
{ {
array_push($result['error_summary'],7); // dup entry in excel file
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Twofold Name found within family";
}
}
}
//check self availbale in uploaded file //if action is DA then get all familiy members,transfrom them into excel array, addd data source as db or excel
if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon) if($file['action'] == 'dependent_addition')
{ {
// dd('file check'); $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]);
$res = check_self_available_in_family($family,$file['action']); // dd(($existing_famility_details));
// dd($res); //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites
if(!$res['is_self_found']) $existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
{ // dd(array_keys($existing_famility_details[0]));
array_push($result['error_summary'],14); // Self not found $family = array_merge($family,$existing_famility_details);
$result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found in uploaded file"; // kint::dump($family);
} $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
} }
// kint::dump($family);//die();
//check name dup within a family
//check self avaialbe either same policy DB level(i.e.) gMC parents if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')
if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon) {
{ $res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]); // dd($res);
// dd($self_details); if(count($res))
if(!count($self_details)) {
{ foreach($res as $k => $rowid)
array_push($result['error_summary'],14); // Self not found {
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System"; array_push($result['error_summary'],7); // dup entry in excel file
} $result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Twofold Name found within family";
} }
}
}
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception') //check self availbale in uploaded file
{ if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
$res = check_dependent_conflict($family,$policy_terms,$file['action']); {
// dd($res); // dd('file check');
if(!$res['status']) $res = check_self_available_in_family($family,$file['action']);
{ // dd($res);
foreach($res['error_data'] as $key => $value) if(!$res['is_self_found'])
{ {
array_push($result['error_summary'],$value['code']); array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $value['row_id'] ][($value['col_name'])]['error'][] = $value['msg']; $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found in uploaded file";
} }
} }
}
//check dup with empid and name with db //check self avaialbe either same policy DB level(i.e.) gMC parents
$res = name_and_empid_check_in_db($family,$file); if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon)
// dd($res); {
// echo '<br/>'; $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ]);
// print_r($res); // dd($self_details);
if(count($res['del'])) if(!count($self_details))
{ {
foreach($res['del'] as $k => $rowid) array_push($result['error_summary'],14); // Self not found
{ $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System";
array_push($result['error_summary'],10); //record not avail for deletion }
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record Not found "; }
}
}
if(count($res['i'])) if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception')
{ {
foreach($res['i'] as $k => $rowid) $res = check_dependent_conflict($family,$policy_terms,$file['action']);
{ // dd($res);
array_push($result['error_summary'],9); //dup entry if(!$res['status'])
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists"; {
} foreach($res['error_data'] as $key => $value)
} {
} array_push($result['error_summary'],$value['code']);
$result['error_data'][ $value['row_id'] ][($value['col_name'])]['error'][] = $value['msg'];
}
}
}
//check dup with empid and name with db
$res = name_and_empid_check_in_db($family,$file);
// dd($res);
// echo '<br/>';
// print_r($res);
if(count($res['del']))
{
foreach($res['del'] as $k => $rowid)
{
array_push($result['error_summary'],10); //record not avail for deletion
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record Not found ";
}
}
if(count($res['i']))
{
foreach($res['i'] as $k => $rowid)
{
array_push($result['error_summary'],9); //dup entry
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists";
}
}
}// end of foreach
}// end of if current action I,DA,A
// s($result); // s($result);
// die(); // die();