From a5a368b7db0a5b1f627461ddd9d69835cab8858b Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 31 Jul 2024 08:41:02 +0530 Subject: [PATCH] CHANGE_TESTCASE_DELETED --- tests/unit/PremiumCalculationTestNew.php | 236 ----------------------- 1 file changed, 236 deletions(-) delete mode 100644 tests/unit/PremiumCalculationTestNew.php diff --git a/tests/unit/PremiumCalculationTestNew.php b/tests/unit/PremiumCalculationTestNew.php deleted file mode 100644 index 93eca137..00000000 --- a/tests/unit/PremiumCalculationTestNew.php +++ /dev/null @@ -1,236 +0,0 @@ - 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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit], - [ '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,'unit' => $primary_unit] - ]; - - //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_unit = 'unit1'; - $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,'unit' => $second_unit ], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit], - [ '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,'unit' => $second_unit] - - ]; - - // 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_unit = 'unit1'; - $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,'unit' => $third_unit ], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit], - [ '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,'unit' => $third_unit] - - ]; - - - // 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_unit = 'unit1'; - $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,'unit' => $fourth_unit ], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit], - [ '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,'unit' => $fourth_unit] - - ]; - - //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', '', '', '', '', '', '','','unit1'], - [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['slab_rates'][] = $svalue; - } - // dd($value['slab_rates']); - } - - // dd($all_rack_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]; - $existing_units = ['unit1']; - $data = calculate_premium_new(family_data:$family_details,policy_terms: $policy_details,slab_details : $all_rack_rates,fileArr: $file, existing_units:$existing_units); - - //****************************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; - } -}