177 lines
15 KiB
PHP
Executable File
177 lines
15 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
namespace App\Tests;
|
|
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
use Config\App;
|
|
use Config\Services;
|
|
use Tests\Support\Libraries\ConfigReader;
|
|
|
|
// use App\Helpers\excel_util_helper;
|
|
use Kint\Kint;
|
|
|
|
class GridType11PremiumCalculationTest extends CIUnitTestCase
|
|
{
|
|
public function testType11PremiumCalculationWithPremiumTypeOne()
|
|
{
|
|
helper('excel_util_helper');
|
|
|
|
$slab_details = [ 'slab_rates' =>[
|
|
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'A', 'si' => 5000000, 'premium' => 500, 'max_si' => 2500000,'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'B', 'si' => 5000000, 'premium' => 1500, 'max_si' => 2000000, 'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'C', 'si' => 5000000, 'premium' => 400, 'max_si' => 1800000, 'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'D', 'si' => 5000000, 'premium' => 800, 'max_si' => 150000, 'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'E', 'si' => 5000000, 'premium' => 8000, 'max_si' => 130000, 'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'F', 'si' => 5000000, 'premium' => 14000, 'max_si' => 10, 'premium_type' => 1, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'G', 'si' => 5000000, 'premium' => 12000, 'max_si' => 5, 'premium_type' => 1, 'relationship' => null]],
|
|
|
|
'grid_master' => ['id' => 4,'policy_type' => 'GMC','ui_type' => 11,'policy_grid_type' => 'Employees + Relationship + max count','is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0,]
|
|
];
|
|
// Sample family data
|
|
$family_details = [ 'TEST001' =>
|
|
[1,'TEST001','Jane Doe', '01-Jan-1990', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', 'None', '', '', ''],
|
|
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', '', '', '', 'G', '', '', '', '', '', ''],
|
|
[3,'TEST001','Peter Doe', '01-Jan-1990', 'M', 'Father', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[4,'TEST001','Mary Doe', '01-Jan-1990', 'F', 'Mother', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[5,'TEST001','Grace Doe', '01-Jan-1990', 'F', 'Mother in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[6,'TEST001','George Doe', '01-Jan-1990', 'M', 'Father in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', ''],
|
|
[8,'TEST001','Bob Doe', '01-Jan-1990', 'M', 'Son', '5000000', '', '', '', '', '', '', '', '', '', ''],
|
|
];
|
|
|
|
// Sample policy terms
|
|
$policy_terms = [
|
|
'family_floater' => true,
|
|
'family_floaters' => [
|
|
'childrens' => 2,
|
|
'spouse' => 1,
|
|
'either-parents-pil' => 0,
|
|
'parents' => 2,
|
|
'parents-in-law' => 2,
|
|
],
|
|
];
|
|
|
|
$policy_details = ['base_policy' => null,"policy_start_date" => "2023-02-02","policy_end_date" => "2024-02-02","policy_terms" => json_encode($policy_terms)];
|
|
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception'];
|
|
$data = calculate_premimum($family_details,$policy_details,$slab_details,$file);
|
|
$policy_created_count = 0;
|
|
echo "\n";
|
|
foreach ($data as $key => $value)
|
|
{
|
|
echo $value['emp_code'].' - '.$value['name'].' - '.$value['relationship'].' - '.$value['policy_details']['basic_cover_si'].' - '.$value['policy_details']['premium']."\n";
|
|
if(!empty($value['policy_details']['premium'])){ $policy_created_count = $policy_created_count + 1; }
|
|
}
|
|
// Kint::dump($data);
|
|
$this->assertTrue(($policy_created_count = 1 || $policy_created_count = 0));
|
|
}
|
|
|
|
public function testType11PremiumCalculationWithPremiumTypeNull()
|
|
{
|
|
helper('excel_util_helper');
|
|
|
|
$slab_details = [ 'slab_rates' =>[
|
|
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'A', 'si' => 500000, 'premium' => 500, 'max_si' => 2500000,'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'B', 'si' => 5000000, 'premium' => 1500, 'max_si' => 2000000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'C', 'si' => 500000, 'premium' => 400, 'max_si' => 1800000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'D', 'si' => 5000000, 'premium' => 800, 'max_si' => 150000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'E', 'si' => 5000000, 'premium' => 8000, 'max_si' => 130000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'F', 'si' => 5000000, 'premium' => 14000, 'max_si' => 10, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'G', 'si' => 5000000, 'premium' => 12000, 'max_si' => 5, 'premium_type' => NULL, 'relationship' => null]],
|
|
|
|
'grid_master' => ['id' => 4,'policy_type' => 'GMC','ui_type' => 11,'policy_grid_type' => 'Employees + Relationship + max count','is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0,]
|
|
];
|
|
// Sample family data
|
|
$family_details = [ 'TEST001' =>
|
|
[1,'TEST001','Jane Doe', '01-Jan-1988', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', 'None', '', '', ''],
|
|
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '500000', '', '', '', 'C', '', '', '', '', '', ''],
|
|
[3,'TEST001','Peter Doe', '01-Jan-1990', 'M', 'Father', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[4,'TEST001','Mary Doe', '01-Jan-1990', 'F', 'Mother', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[5,'TEST001','Grace Doe', '01-Jan-1990', 'F', 'Mother in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[6,'TEST001','George Doe', '01-Jan-1990', 'M', 'Father in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', ''],
|
|
[8,'TEST001','Bob Doe', '01-Jan-1990', 'M', 'Son', '5000000', '', '', '', '', '', '', '', '', '', ''],
|
|
];
|
|
|
|
// Sample policy terms
|
|
$policy_terms = [
|
|
'family_floater' => true,
|
|
'family_floaters' => [
|
|
'childrens' => 2,
|
|
'spouse' => 1,
|
|
'either-parents-pil' => 0,
|
|
'parents' => 2,
|
|
'parents-in-law' => 2,
|
|
],
|
|
];
|
|
|
|
$policy_details = ['base_policy' => null,"policy_start_date" => "2023-02-02","policy_end_date" => "2024-02-02","policy_terms" => json_encode($policy_terms)];
|
|
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception'];
|
|
$data = calculate_premimum($family_details,$policy_details,$slab_details,$file);
|
|
$policy_created_count = 0;
|
|
echo "\n";
|
|
foreach ($data as $key => $value)
|
|
{
|
|
echo $value['emp_code'].' - '.$value['name'].' - '.$value['relationship'].' - '.$value['policy_details']['basic_cover_si'].' - '.$value['policy_details']['premium']."\n";
|
|
if(!empty($value['policy_details']['premium'])){ $policy_created_count = $policy_created_count + 1; }
|
|
}
|
|
// Kint::dump($data);
|
|
$this->assertTrue($policy_created_count > 1);
|
|
}
|
|
|
|
|
|
public function testType11PremiumCalculationWithPremiumTypeTwo()
|
|
{
|
|
helper('excel_util_helper');
|
|
|
|
$slab_details = [ 'slab_rates' =>[
|
|
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'A', 'si' => 500000, 'premium' => 500, 'max_si' => 2500000,'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'B', 'si' => 5000000, 'premium' => 1500, 'max_si' => 2000000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'C', 'si' => 500000, 'premium' => 400, 'max_si' => 1800000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'D', 'si' => 5000000, 'premium' => 800, 'max_si' => 150000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'E', 'si' => 5000000, 'premium' => 8000, 'max_si' => 130000, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'F', 'si' => 5000000, 'premium' => 14000, 'max_si' => 10, 'premium_type' => NULL, 'relationship' => null],
|
|
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 11, 'age_from' => null, 'age_to' => null, 'grade' => 'G', 'si' => 5000000, 'premium' => 12000, 'max_si' => 5, 'premium_type' => NULL, 'relationship' => null]],
|
|
|
|
'grid_master' => ['id' => 4,'policy_type' => 'GMC','ui_type' => 11,'policy_grid_type' => 'Employees + Relationship + max count','is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0,]
|
|
];
|
|
// Sample family data
|
|
$family_details = [ 'TEST001' =>
|
|
[1,'TEST001','Jane Doe', '01-Jan-1988', 'F', 'Spouse', '', '01-Jan-2024', '01-Jan-2020', 50000, '', 'Manager', '1234567890', 'john.doe@example.com', 'None', '', '', ''],
|
|
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '500000', '', '', '', 'C', '', '', '', '', '', ''],
|
|
[3,'TEST001','Peter Doe', '01-Jan-1990', 'M', 'Father', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[4,'TEST001','Mary Doe', '01-Jan-1990', 'F', 'Mother', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[5,'TEST001','Grace Doe', '01-Jan-1990', 'F', 'Mother in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[6,'TEST001','George Doe', '01-Jan-1990', 'M', 'Father in law', '', '', '', '', '', '', '', '', '', '', ''],
|
|
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', ''],
|
|
[8,'TEST001','Bob Doe', '01-Jan-1990', 'M', 'Son', '5000000', '', '', '', '', '', '', '', '', '', ''],
|
|
];
|
|
|
|
// Sample policy terms
|
|
$policy_terms = [
|
|
'family_floater' => true,
|
|
'family_floaters' => [
|
|
'childrens' => 2,
|
|
'spouse' => 1,
|
|
'either-parents-pil' => 0,
|
|
'parents' => 2,
|
|
'parents-in-law' => 2,
|
|
],
|
|
];
|
|
|
|
$policy_details = ['base_policy' => null,"policy_start_date" => "2023-02-02","policy_end_date" => "2024-02-02","policy_terms" => json_encode($policy_terms)];
|
|
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception'];
|
|
$data = calculate_premimum($family_details,$policy_details,$slab_details,$file);
|
|
$policy_created_count = 0;
|
|
echo "\n";
|
|
foreach ($data as $key => $value)
|
|
{
|
|
echo $value['emp_code'].' - '.$value['name'].' - '.$value['relationship'].' - '.$value['policy_details']['basic_cover_si'].' - '.$value['policy_details']['premium']."\n";
|
|
if(!empty($value['policy_details']['premium'])){ $policy_created_count = $policy_created_count + 1; }
|
|
}
|
|
// Kint::dump($data);
|
|
$this->assertTrue($policy_created_count > 1);
|
|
}
|
|
|
|
|
|
} |