FIX_THE_FAMILY_FLOATERS_ISSUE
This commit is contained in:
parent
a60bf20b9b
commit
7884681d47
@ -5689,6 +5689,7 @@ class ClientController extends AdminController
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '1126']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1183]);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1169]);
|
||||
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
|
||||
// $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]);
|
||||
|
||||
@ -1387,13 +1387,16 @@ class EmployeeServiceController extends AdminController
|
||||
$family = array_merge($family,$existing_famility_details);
|
||||
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
|
||||
// dd($family);
|
||||
// $self = current(array_filter($family, fn($r) => strtolower($r[5] ?? '') === 'self'));
|
||||
// $premium = (int)($self['temp']['rata_premimum'] ?? 0);
|
||||
// foreach ($family as &$r) if (strtolower($r[5] ?? '') !== 'self') $r['self_rata_premium'] = $premium;
|
||||
$self = current(array_filter($family, fn($r) => strtolower($r[5] ?? '') === 'self'));
|
||||
$premium = (int)($self['temp']['rata_premimum'] ?? 0);
|
||||
foreach ($family as &$r) if (strtolower($r[5] ?? '') !== 'self') $r['self_rata_premium'] = $premium;
|
||||
}
|
||||
|
||||
// Kint::dump($family);
|
||||
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
|
||||
if($file['action'] == 'dependent_addition') {
|
||||
$data = validatet_family_floter_rata_premium($data);
|
||||
}
|
||||
// dd($data);
|
||||
$employee_data_group_by_family[$emp_id] = $data;
|
||||
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
||||
|
||||
@ -50,7 +50,6 @@ if (!function_exists('check_columns_name')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_row_is_empty_or_null')) {
|
||||
|
||||
function check_row_is_empty_or_null($arr)
|
||||
@ -89,7 +88,6 @@ if (!function_exists('check_excel_date_format')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_relationship')) {
|
||||
function check_relationship($row, $relationship, $policy_terms)
|
||||
{
|
||||
@ -132,7 +130,6 @@ if (!function_exists('check_relationship')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_doj')) {
|
||||
|
||||
function check_doj($row)
|
||||
@ -179,7 +176,6 @@ if (!function_exists('check_doc')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_employee_band')) {
|
||||
function check_employee_band($row, $policy_terms, $slab_details)
|
||||
{
|
||||
@ -218,7 +214,6 @@ if (!function_exists('check_employee_band')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_si')) {
|
||||
function check_si($row, $policy_details, $slab_details)
|
||||
{
|
||||
@ -326,7 +321,6 @@ if (!function_exists('check_basic_pay')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_dob_diff')) {
|
||||
function check_dob_diff($row, $relationships, $default_age_ratio, $policy_details)
|
||||
{
|
||||
@ -464,8 +458,6 @@ if (!function_exists('check_self_available_in_family')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('name_and_empid_check_in_db')) {
|
||||
function name_and_empid_check_in_db($family_data, $actionArr)
|
||||
{
|
||||
@ -955,7 +947,6 @@ if (!function_exists('calculate_premium_new')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('transform_excel_data_to_db')) {
|
||||
function transform_excel_data_to_db($memArr, $actionArr)
|
||||
{
|
||||
@ -1022,16 +1013,15 @@ if (!function_exists('transform_excel_data_to_db')) {
|
||||
$result['temp']['rata_premimum'] = isset($memArr['temp']['rata_premimum']) ? $memArr['temp']['rata_premimum'] : 0;
|
||||
$result['policy_details'] = $policy;
|
||||
|
||||
// if(isset($memArr['self_rata_premium'])){
|
||||
// $result['self_rata_premium'] = $memArr['self_rata_premium'] ?? 0;
|
||||
// }
|
||||
if(isset($memArr['self_rata_premium'])){
|
||||
$result['self_rata_premium'] = $memArr['self_rata_premium'] ?? 0;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('premium_calculation_manager_old')) {
|
||||
function premium_calculation_manager_old($emp_data, $policy_terms, $slab_details, $default_si = null)
|
||||
{
|
||||
@ -1844,14 +1834,13 @@ if (!function_exists('premium_calculation_manager')) {
|
||||
$emp_data['policy_details']['basic_cover_si'] = 0;
|
||||
$emp_data['policy_details']['premium'] = 0;
|
||||
|
||||
// if(isset($emp_data['self_rata_premium']) && !empty($emp_data['self_rata_premium'])){
|
||||
// $self_rata_premium = (int)($emp_data['self_rata_premium'] ?? 0);
|
||||
// $dependent_rata_premium = (int)($emp_data['policy_details']['rata_premimum'] ?? 0);
|
||||
// $actual_rata_premium = abs($dependent_rata_premium - $self_rata_premium);
|
||||
// $emp_data['policy_details']['rata_premimum'] = $actual_rata_premium;
|
||||
// $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
|
||||
// }
|
||||
|
||||
if(isset($emp_data['self_rata_premium']) && !empty($emp_data['self_rata_premium'])){
|
||||
$self_rata_premium = (int)($emp_data['self_rata_premium'] ?? 0);
|
||||
$dependent_rata_premium = (int)($emp_data['policy_details']['rata_premimum'] ?? 0);
|
||||
$actual_rata_premium = abs($dependent_rata_premium - $self_rata_premium);
|
||||
$emp_data['policy_details']['rata_premimum'] = $actual_rata_premium;
|
||||
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
|
||||
}
|
||||
|
||||
}else if(strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 1 && ($emp_data['temp']['action'] == 'I' || $emp_data['temp']['action'] == 'A' || $emp_data['temp']['action'] == 'MI')){
|
||||
|
||||
@ -1867,7 +1856,6 @@ if (!function_exists('premium_calculation_manager')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('calculate_pro_rata_premimum')) {
|
||||
function calculate_pro_rata_premimum($premium, $employee_policy_coverage_days, $policy_coverage_days)
|
||||
{
|
||||
@ -1990,7 +1978,6 @@ if (!function_exists('get_emp_policy_records_from_audit_history')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('replace_original_data')) {
|
||||
function replace_original_data(array $original_data, array $current_data)
|
||||
{
|
||||
@ -2062,7 +2049,6 @@ if (!function_exists('remap_default_age_ratio_into_relationship')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('check_dup_mobileno')) {
|
||||
function check_dup_mobileno(array $row, array $existing_mobilenos)
|
||||
{
|
||||
@ -2192,7 +2178,6 @@ if (!function_exists('convert_string_to_date')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('transform_enrollment_row_to_inception_row')) {
|
||||
function transform_enrollment_row_to_inception_row($row)
|
||||
{
|
||||
@ -2428,7 +2413,6 @@ if (!function_exists('check_unit')) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('transform_si_excel_row_to_calculatable_format')) {
|
||||
function transform_si_excel_row_to_calculatable_format(array $employee, array $employee_policy, array $maxage_and_maxcount, array $slab_details, string $applicable_slab_name, string $augmented_si, array $grid_master)
|
||||
{
|
||||
@ -2888,3 +2872,36 @@ if (!function_exists('is_valid_or_empty_email')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('validatet_family_floter_rata_premium')) {
|
||||
function validatet_family_floter_rata_premium($family){
|
||||
|
||||
if (count($family) === 2) {
|
||||
return $family; // skip if only two members
|
||||
}
|
||||
|
||||
$dependentRataGiven = false;
|
||||
|
||||
foreach ($family as &$row) {
|
||||
|
||||
// Skip if the member is self
|
||||
if (strtolower($row['relationship']) == 'self') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For dependents
|
||||
if (isset($row['temp']['premium_type']) && $row['temp']['premium_type'] == 1) {
|
||||
|
||||
if (!$dependentRataGiven) {
|
||||
// First eligible dependent keeps premium
|
||||
$dependentRataGiven = true;
|
||||
} else {
|
||||
$row['policy_details']['rata_premimum'] = 0;
|
||||
$row['policy_details']['gst'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $family;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user