Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
3aec296bc2
@ -1363,12 +1363,6 @@ public function iAgreeForAddOn()
|
||||
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
|
||||
// $client_policy_id = $this->request->getVar('client_policy_id');
|
||||
// $emp_code = $this->request->getVar('emp_code');
|
||||
|
||||
// dd($default_si);
|
||||
|
||||
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
|
||||
$emp_code = $this->request->getVar('emp_code') ?? $empCode;
|
||||
$default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
|
||||
@ -1378,17 +1372,27 @@ public function calculatePremium($clientPolicyId = null , $empCode = null, $defa
|
||||
$client_id = ($this->clientPolicyModel->select('client_id')->find($client_policy_id))['client_id'];
|
||||
// get policy and rack details
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($client_id,$client_policy_id);
|
||||
$policy_type = $policy_terms[0]->is_addon;
|
||||
$base_policy = $policy_terms[0]->base_policy;
|
||||
$policy_terms = (array) $policy_terms[0];// convert obj to array
|
||||
|
||||
//get policy slab rates
|
||||
$slab_details = $this->policesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
|
||||
// dd($slab_details);
|
||||
// print_r($slab_details);die();
|
||||
|
||||
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_code: $emp_code,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
|
||||
|
||||
if(!count($existing_famility_details) && $policy_type == 2)//top up addon only
|
||||
{
|
||||
//get basepolicy id then pull emplist from base policy if only current policy is DA addon policy and emplist is zero
|
||||
// echo 'inside';
|
||||
$client_policy_id = $base_policy;
|
||||
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_code: $emp_code,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
|
||||
}
|
||||
|
||||
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
|
||||
// dd($this->employeeModel->getLastQuery());
|
||||
// dd($existing_famility_details);die();
|
||||
// print_r($existing_famility_details);die();
|
||||
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
|
||||
// dd($employee_data_group_by_family);
|
||||
foreach ($employee_data_group_by_family as $emp_id => $family)
|
||||
|
||||
@ -562,7 +562,7 @@ class EmployeeServiceController extends AdminController
|
||||
// get policy and rack details
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($client_id,$client_policy_id);
|
||||
$policy_terms = (array) $policy_terms[0];// convert obj to array
|
||||
|
||||
|
||||
//get policy slab rates
|
||||
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
|
||||
|
||||
|
||||
@ -873,6 +873,64 @@ if (!function_exists('premium_calculation_manager'))
|
||||
}
|
||||
break;
|
||||
|
||||
case "12":
|
||||
//GMC - Employee + relationship
|
||||
$max_count = $emp_data['temp']['maxcount'];
|
||||
$employee_received_band = $emp_data['temp']['band'];
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
$emp_data['policy_details']['basic_cover_si'] = null;
|
||||
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && ($slab_value['grade'] == $employee_received_band))
|
||||
{
|
||||
//calculate premium based on count
|
||||
$familiy_si_covered = $employee_received_si * $max_count;
|
||||
$familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered);
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = (strtolower($emp_data['relationship']) == 'self' ? $familiy_si_covered : null);
|
||||
$emp_data['policy_details']['date_coverage'] = (strtolower($emp_data['relationship']) == 'self' ? (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']) : "");
|
||||
$emp_data['policy_details']['policy_end_date'] = (strtolower($emp_data['relationship']) == 'self' ? $policy_terms['policy_end_date'] : "");
|
||||
$emp_data['policy_details']['days'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days : 0);
|
||||
$emp_data['policy_details']['premium'] = (strtolower($emp_data['relationship']) == 'self' ? $slab_value['premium'] : 0);
|
||||
$emp_data['policy_details']['rata_premimum'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']) : 0);
|
||||
$emp_data['policy_details']['gst'] = (strtolower($emp_data['relationship']) == 'self' ? ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')) : 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "13":
|
||||
//GMC - Employee + relationship + age
|
||||
$max_count = $emp_data['temp']['maxcount'];
|
||||
$employee_received_band = $emp_data['temp']['band'];
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
$emp_data['policy_details']['basic_cover_si'] = null;
|
||||
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && ($slab_value['grade'] == $employee_received_band))
|
||||
{
|
||||
//calculate premium based on count
|
||||
$familiy_si_covered = $employee_received_si * $max_count;
|
||||
$familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered);
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = (strtolower($emp_data['relationship']) == 'self' ? $familiy_si_covered : null);
|
||||
$emp_data['policy_details']['date_coverage'] = (strtolower($emp_data['relationship']) == 'self' ? (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']) : "");
|
||||
$emp_data['policy_details']['policy_end_date'] = (strtolower($emp_data['relationship']) == 'self' ? $policy_terms['policy_end_date'] : "");
|
||||
$emp_data['policy_details']['days'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days : 0);
|
||||
$emp_data['policy_details']['premium'] = (strtolower($emp_data['relationship']) == 'self' ? $slab_value['premium'] : 0);
|
||||
$emp_data['policy_details']['rata_premimum'] = (strtolower($emp_data['relationship']) == 'self' ? calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']) : 0);
|
||||
$emp_data['policy_details']['gst'] = (strtolower($emp_data['relationship']) == 'self' ? ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')) : 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
echo "Not a valid grid";
|
||||
}
|
||||
|
||||
72
tests/unit/GridType12PremiumCalculationTest.php
Normal file
72
tests/unit/GridType12PremiumCalculationTest.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?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 GridType12PremiumCalculationTest.php extends CIUnitTestCase
|
||||
{
|
||||
public function testType12PremiumCalculation()
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
|
||||
$slab_details = [ 'slab_rates' =>[
|
||||
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 12, 'age_from' => null, 'age_to' => null, 'grade' => null, 'si' => 5000000, 'premium' => 50000, 'max_si' => 0,'premium_type' => 1, 'relationship' => 'self'],
|
||||
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 25000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'spouse'],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 20000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'child'],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 18000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'father'],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 15000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'mother'],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 14000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'father-in-law'],
|
||||
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => 4, 'age_from' => null, 'age_to' => null, 'grade' => '', 'si' => 5000000, 'premium' => 12000, 'max_si' => 0, 'premium_type' => 1, 'relationship' => 'mother-in-law']],
|
||||
|
||||
'grid_master' => ['id' => 4,'policy_type' => 'GMC','ui_type' => 12,'policy_grid_type' => 'Employees + Relationship','is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 0,'basicpay' => 0,'emp_band' => 0,]
|
||||
];
|
||||
// Sample family data
|
||||
$family_details = [
|
||||
[1, 'Jane Doe', '1990-01-01', 'F', 'Spouse', 10000, '2024-01-01', '2020-01-01', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', 'None', '', '', ''],
|
||||
[2, 'John Doe', '1990-01-01', 'M', 'Self', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
[3, 'Peter Doe', '1990-01-01', 'M', 'Father', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
[4, 'Mary Doe', '1990-01-01', 'F', 'Mother', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
[5, 'Grace Doe', '1990-01-01', 'F', 'Mother-in-law', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
[6, 'George Doe', '1990-01-01', 'M', 'Father-in-law', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
[7, 'Alice Doe', '1995-02-02', 'F', 'Daughter', 8000, '2024-02-01', '2021-01-01', 40000, 'B', 'Supervisor', '9876543210', '', '', '', ''],
|
||||
[8, 'Bob Doe', '1995-02-02', 'M', 'Son', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
];
|
||||
|
||||
|
||||
// Sample policy terms
|
||||
$policy_terms = [
|
||||
'family_floater' => true,
|
||||
'family_floaters' => [
|
||||
'childrens' => 2,
|
||||
'spouse' => 1,
|
||||
'either-parents-pil' => 0,
|
||||
'parents' => 2,
|
||||
'parents-in-law' => 2,
|
||||
],
|
||||
];
|
||||
|
||||
// Sample action array
|
||||
$actionArr = 'addition';
|
||||
|
||||
// Call the function
|
||||
$result = check_dependent_conflict($family_data, $policy_terms, $actionArr);
|
||||
Kint::dump($result);
|
||||
// Assert that the status is true (no conflicts)
|
||||
$this->assertTrue($result['status']);
|
||||
}
|
||||
|
||||
// public function testIsNull()
|
||||
// {
|
||||
// $i = null;
|
||||
// $this->assertTrue($i);
|
||||
|
||||
// }
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user