FIX_FAMILY_FLOATER
This commit is contained in:
parent
4d9776ec3c
commit
79c22a7b42
@ -1385,8 +1385,8 @@ class EmployeeServiceController extends AdminController
|
|||||||
$existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
|
$existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
|
||||||
// Kint::dump($existing_famility_details);
|
// Kint::dump($existing_famility_details);
|
||||||
$family = array_merge($family,$existing_famility_details);
|
$family = array_merge($family,$existing_famility_details);
|
||||||
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
|
$family = data_group_by_family($family, 'excel', 1)[ $emp_id ];// reason to call this again is bring self to first index of the array
|
||||||
// dd($family);
|
// dd($family);
|
||||||
$self = current(array_filter($family, fn($r) => strtolower($r[5] ?? '') === 'self'));
|
$self = current(array_filter($family, fn($r) => strtolower($r[5] ?? '') === 'self'));
|
||||||
$premium = (int)($self['temp']['rata_premimum'] ?? 0);
|
$premium = (int)($self['temp']['rata_premimum'] ?? 0);
|
||||||
foreach ($family as &$r) if (strtolower($r[5] ?? '') !== 'self') $r['self_rata_premium'] = $premium;
|
foreach ($family as &$r) if (strtolower($r[5] ?? '') !== 'self') $r['self_rata_premium'] = $premium;
|
||||||
@ -1394,9 +1394,9 @@ class EmployeeServiceController extends AdminController
|
|||||||
|
|
||||||
// Kint::dump($family);
|
// Kint::dump($family);
|
||||||
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
|
$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') {
|
if($file['action'] == 'dependent_addition') {
|
||||||
// $data = validatet_family_floter_rata_premium($data);
|
$data = validatet_family_floter_rata_premium($data);
|
||||||
// }
|
}
|
||||||
// dd($data);
|
// dd($data);
|
||||||
$employee_data_group_by_family[$emp_id] = $data;
|
$employee_data_group_by_family[$emp_id] = $data;
|
||||||
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
|
||||||
|
|||||||
@ -375,6 +375,10 @@ if (!function_exists('data_group_by_family')) {
|
|||||||
if ($data_source == 'excel') {
|
if ($data_source == 'excel') {
|
||||||
if (!check_row_is_empty_or_null($row)) {
|
if (!check_row_is_empty_or_null($row)) {
|
||||||
|
|
||||||
|
if(empty($action)){
|
||||||
|
$row['data_from'] = "excel";
|
||||||
|
}
|
||||||
|
|
||||||
// for this condition to avoid 5,00,000 to 500000
|
// for this condition to avoid 5,00,000 to 500000
|
||||||
if($current_column_action == 'SI'){
|
if($current_column_action == 'SI'){
|
||||||
$row[3] = removeNumberFormatting($row[3]);
|
$row[3] = removeNumberFormatting($row[3]);
|
||||||
@ -392,6 +396,8 @@ if (!function_exists('data_group_by_family')) {
|
|||||||
} else {
|
} else {
|
||||||
$result[$row[1]][] = $row;
|
$result[$row[1]][] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if ($data_source = 'db') {
|
} else if ($data_source = 'db') {
|
||||||
if (strtolower($row['relationship']) == 'self' && isset($result[$row['emp_code']])) {
|
if (strtolower($row['relationship']) == 'self' && isset($result[$row['emp_code']])) {
|
||||||
@ -1017,13 +1023,17 @@ if (!function_exists('transform_excel_data_to_db')) {
|
|||||||
$result['self_rata_premium'] = $memArr['self_rata_premium'] ?? 0;
|
$result['self_rata_premium'] = $memArr['self_rata_premium'] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($memArr['data_from'])){
|
||||||
|
$result['data_from'] = $memArr['data_from'] ?? 'excel';
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('premium_calculation_manager')) {
|
if (!function_exists('premium_calculation_manager_old')) {
|
||||||
function premium_calculation_manager($emp_data, $policy_terms, $slab_details, $default_si = null)
|
function premium_calculation_manager_old($emp_data, $policy_terms, $slab_details, $default_si = null)
|
||||||
{
|
{
|
||||||
// dd($emp_data,$policy_terms,$slab_details,$default_si);
|
// dd($emp_data,$policy_terms,$slab_details,$default_si);
|
||||||
|
|
||||||
@ -1429,8 +1439,8 @@ if (!function_exists('premium_calculation_manager')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('premium_calculation_manager_new')) {
|
if (!function_exists('premium_calculation_manager')) {
|
||||||
function premium_calculation_manager_new($emp_data, $policy_terms, $slab_details, $default_si = null)
|
function premium_calculation_manager($emp_data, $policy_terms, $slab_details, $default_si = null)
|
||||||
{
|
{
|
||||||
// dd($emp_data,$policy_terms,$slab_details,$default_si);
|
// dd($emp_data,$policy_terms,$slab_details,$default_si);
|
||||||
|
|
||||||
@ -2875,31 +2885,64 @@ if (!function_exists('is_valid_or_empty_email')) {
|
|||||||
if (!function_exists('validatet_family_floter_rata_premium')) {
|
if (!function_exists('validatet_family_floter_rata_premium')) {
|
||||||
function validatet_family_floter_rata_premium($family){
|
function validatet_family_floter_rata_premium($family){
|
||||||
|
|
||||||
|
// print_rr($family); die;
|
||||||
if (count($family) === 2) {
|
if (count($family) === 2) {
|
||||||
return $family; // skip if only two members
|
return $family; // skip if only two members
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$excelCount = count(array_filter($family, fn($r) => ($r['data_from'] ?? '') === 'excel') ?? []);
|
||||||
|
$reset_family_premium = false;
|
||||||
$dependentRataGiven = false;
|
$dependentRataGiven = false;
|
||||||
|
|
||||||
|
if($excelCount == 1){
|
||||||
|
|
||||||
|
$selfPremium = 0;
|
||||||
|
$familyPremium = 0;
|
||||||
|
|
||||||
|
foreach ($family as $row) {
|
||||||
|
|
||||||
|
// Get self premium
|
||||||
|
if (isset($row['relationship']) && strtolower($row['relationship']) == 'self') {
|
||||||
|
$selfPremium = (float) ($row['policy_details']['rata_premimum'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum the dependents premium
|
||||||
|
if (isset($row['relationship']) && strtolower($row['relationship']) !== 'self')
|
||||||
|
{
|
||||||
|
$familyPremium += (float) ($row['policy_details']['rata_premimum'] ?? 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($selfPremium > $familyPremium || $selfPremium == $familyPremium){
|
||||||
|
$reset_family_premium = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($family as &$row) {
|
foreach ($family as &$row) {
|
||||||
|
|
||||||
// Skip if the member is self
|
// Skip if the member is self
|
||||||
if (strtolower($row['relationship']) == 'self') {
|
if (isset($row['relationship']) && strtolower($row['relationship']) == 'self') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For dependents
|
// For dependents
|
||||||
if (isset($row['temp']['premium_type']) && $row['temp']['premium_type'] == 1) {
|
if (isset($row['temp']['premium_type']) && $row['temp']['premium_type'] == 1) {
|
||||||
|
|
||||||
if (!$dependentRataGiven) {
|
if (!$dependentRataGiven && isset($row['data_from']) && $row['data_from'] === 'excel') {
|
||||||
// First eligible dependent keeps premium
|
// First eligible dependent keeps premium
|
||||||
$dependentRataGiven = true;
|
$dependentRataGiven = true;
|
||||||
} else {
|
} else if(isset($row['data_from']) && $row['data_from'] === 'excel'){
|
||||||
|
$row['policy_details']['rata_premimum'] = 0;
|
||||||
|
$row['policy_details']['gst'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($reset_family_premium == true && isset($row['data_from']) && $row['data_from'] === 'excel'){
|
||||||
$row['policy_details']['rata_premimum'] = 0;
|
$row['policy_details']['rata_premimum'] = 0;
|
||||||
$row['policy_details']['gst'] = 0;
|
$row['policy_details']['gst'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $family;
|
return $family;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user