MERGE_FIX_DATA_IMPORT_ISSUE
This commit is contained in:
commit
26eb34e3fd
@ -246,7 +246,6 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi
|
||||
$routes->post("/calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
|
||||
|
||||
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
|
||||
|
||||
@ -1048,11 +1048,19 @@ class ClientController extends AdminController
|
||||
->where("employees.emp_status",'active')
|
||||
->countAllResults();
|
||||
|
||||
if($emp_count == 0){
|
||||
$emp_count = true;
|
||||
}else{
|
||||
$emp_count = false;
|
||||
}
|
||||
|
||||
$data = $this->employeePolicyModel->select('employee_polices.id')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->findAll();
|
||||
|
||||
$emp_count = count($data);
|
||||
|
||||
// if($emp_count == 0){
|
||||
// $emp_count = true;
|
||||
// }else{
|
||||
// $emp_count = false;
|
||||
// }
|
||||
|
||||
|
||||
$data = $this->policesModel->getPolicyPremium($record['policy_id']);
|
||||
|
||||
@ -1262,7 +1262,7 @@ class EmpDataServiceController extends BaseController
|
||||
$description = 'The following amount of Rs. ' . $amount->total_sum . '/- has been debited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
|
||||
|
||||
$data = [
|
||||
'amount' => $amount->total_sum,
|
||||
'amount' => $amount->total_sum ?? 0,
|
||||
'sub_type_id' => 4,
|
||||
'client_id' => $arrayData['client_id'],
|
||||
'insurer_id' => $insurer_id['insurer_id'],
|
||||
|
||||
@ -170,9 +170,10 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
public function addEmployeeAndDependence()
|
||||
{
|
||||
// try {
|
||||
try {
|
||||
$data = $this->request->getJSON();
|
||||
|
||||
|
||||
|
||||
if ($data) {
|
||||
|
||||
$Count = 0;
|
||||
@ -197,10 +198,6 @@ class EmployeeRestController extends AdminController
|
||||
$employee = $this->employeeModel->insert($item);
|
||||
|
||||
if ($employee) {
|
||||
if(!isset($item->is_addon_value))
|
||||
{
|
||||
$this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id);
|
||||
}
|
||||
$Count++;
|
||||
}
|
||||
|
||||
@ -212,8 +209,14 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if(!isset($data[0]->is_addon_value))
|
||||
{
|
||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
|
||||
$this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id);
|
||||
}else{
|
||||
$this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si);
|
||||
}
|
||||
|
||||
|
||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
|
||||
|
||||
|
||||
$result = [];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
@ -222,18 +225,21 @@ class EmployeeRestController extends AdminController
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
|
||||
}
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id)
|
||||
public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null)
|
||||
{
|
||||
|
||||
|
||||
if($basic_cover_si == null)
|
||||
{
|
||||
$client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first();
|
||||
$policy_terms = json_decode($client_policy['policy_terms']);
|
||||
$basic_cover_si = $policy_terms->sum_insured;
|
||||
}
|
||||
|
||||
$checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->first();
|
||||
|
||||
@ -989,6 +995,7 @@ public function getEmployeePolicy()
|
||||
|
||||
// Map family floaters that already exist in the employee table
|
||||
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||
|
||||
// Generate Notes string based on familyFloates terms
|
||||
$array->notes = $this->FloterNotesConvertion($familyFloates);
|
||||
// Convert familyFloaters terms data to plain array
|
||||
@ -1059,9 +1066,9 @@ public function getEmployeePolicy()
|
||||
|
||||
}
|
||||
|
||||
$result[] = $array;
|
||||
// $result[] = $array;
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
|
||||
|
||||
|
||||
}else{
|
||||
@ -1115,6 +1122,8 @@ public function FloterNotesConvertion($array){
|
||||
$string = ucwords($string);
|
||||
$result .= ' + '.$string;
|
||||
}else if($value != 0 && $key ==='self') {
|
||||
}else if($value != 0 && $key ==='childrens') {
|
||||
if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; }
|
||||
}else{
|
||||
$string = str_replace('-', ' ', $key);
|
||||
$string = ucwords($string);
|
||||
@ -1122,7 +1131,7 @@ public function FloterNotesConvertion($array){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1323,7 +1332,7 @@ public function getAddOnPolicy()
|
||||
}
|
||||
|
||||
|
||||
// return $this->respond(['status' => 'success','code' => 200,'data' => ['addon_policy'=>$responce]], 200);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
|
||||
@ -1342,12 +1351,11 @@ public function iAgreeForAddOn()
|
||||
|
||||
$this->employeeModel->where('emp_code', $emp_code )
|
||||
->where('is_active', 1 )
|
||||
->set(array('emp_status'=>'Enrolled'))
|
||||
->set(array('emp_status'=>'enrolled'))
|
||||
->update();
|
||||
$this->employeePolicyModel->where('client_id', $client_id )
|
||||
->where('client_policy_id', $client_policy_id )
|
||||
$this->employeePolicyModel->where('client_policy_id', $client_policy_id )
|
||||
->where('is_active', 1 )
|
||||
->set(array('status'=>'Enrolled'))
|
||||
->set(array('status'=>'enrolled'))
|
||||
->update();
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
|
||||
}
|
||||
@ -1358,12 +1366,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
|
||||
@ -1373,17 +1375,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";
|
||||
}
|
||||
|
||||
@ -106,6 +106,7 @@ class EmployeePolicyModel extends Model
|
||||
{
|
||||
$client_policy_id = $ref_data['client_policy_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
$event = $ref_data['event_type'];
|
||||
|
||||
if($insurer_or_tpa == 'tpa'){
|
||||
|
||||
@ -150,13 +151,11 @@ class EmployeePolicyModel extends Model
|
||||
batch_files.batch_code as bf
|
||||
FROM batch_files
|
||||
LEFT JOIN batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
WHERE batch_files.event_type = 'inception'
|
||||
WHERE batch_files.event_type = '{$event}'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) as batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
WHERE batch_data.bf IS NULL
|
||||
AND batch_data.bl IS NULL
|
||||
AND employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '')
|
||||
AND employee_polices.is_active = 1";
|
||||
|
||||
|
||||
@ -711,7 +711,7 @@ $('body').on('click', '.btnPolicyModel', function() {
|
||||
$('#nameOfThePolicy').html(' - ' + res.policy_name);
|
||||
$('#grid_emp_count').val(res.count);
|
||||
|
||||
if (res.count == false) {
|
||||
if (res.count > 0) {
|
||||
console.log('count -- 2', res.count);
|
||||
$("#btnGridSubmit_2").hide();
|
||||
} else {
|
||||
|
||||
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