CHANGE_ : calculate premium
This commit is contained in:
parent
95de1ceeb0
commit
c17a3a3fd3
@ -346,7 +346,6 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $routes->post("getChatResponse", "ChatBotController::getChatResponse");
|
|
||||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||||
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
||||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||||
|
|||||||
@ -27,6 +27,7 @@ use App\Models\NotificationModel;
|
|||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Models\FEContentModel;
|
use App\Models\FEContentModel;
|
||||||
use App\Models\AddImgModel;
|
use App\Models\AddImgModel;
|
||||||
|
use App\Models\ClientBranchModel;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\Jobs ;
|
use App\Controllers\Jobs ;
|
||||||
@ -69,6 +70,8 @@ class EmployeeRestController extends AdminController
|
|||||||
protected $userModel;
|
protected $userModel;
|
||||||
protected $feContentModel;
|
protected $feContentModel;
|
||||||
protected $addImgModel;
|
protected $addImgModel;
|
||||||
|
protected $clientBranchModel;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -90,6 +93,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$this->userModel = new UserModel();
|
$this->userModel = new UserModel();
|
||||||
$this->feContentModel = new FEContentModel();
|
$this->feContentModel = new FEContentModel();
|
||||||
$this->addImgModel = new AddImgModel();
|
$this->addImgModel = new AddImgModel();
|
||||||
|
$this->clientBranchModel = new ClientBranchModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +212,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
public function addEmployeeAndDependence()
|
public function addEmployeeAndDependence()
|
||||||
{
|
{
|
||||||
try {
|
// try {
|
||||||
$data = $this->request->getJSON();
|
$data = $this->request->getJSON();
|
||||||
|
|
||||||
|
|
||||||
@ -216,6 +220,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
$Count = 0;
|
$Count = 0;
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
|
|
||||||
if (isset($item->id)) {
|
if (isset($item->id)) {
|
||||||
//update old data
|
//update old data
|
||||||
$id = $item->id;
|
$id = $item->id;
|
||||||
@ -233,6 +238,8 @@ class EmployeeRestController extends AdminController
|
|||||||
$item->gender = $this->GenderMap($item->relationship , $item->emp_code);
|
$item->gender = $this->GenderMap($item->relationship , $item->emp_code);
|
||||||
$item->dob = $this->convertDateFormatYMD($item->dob);
|
$item->dob = $this->convertDateFormatYMD($item->dob);
|
||||||
$item->emp_status = 'draft';
|
$item->emp_status = 'draft';
|
||||||
|
|
||||||
|
|
||||||
$employee = $this->employeeModel->insert($item);
|
$employee = $this->employeeModel->insert($item);
|
||||||
|
|
||||||
if ($employee) {
|
if ($employee) {
|
||||||
@ -266,7 +273,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
|
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code , $data[0]->client_branch_id);
|
||||||
|
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -276,9 +283,9 @@ class EmployeeRestController extends AdminController
|
|||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,9 +324,9 @@ class EmployeeRestController extends AdminController
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePremiumAmount($client_policy_id , $emp_code)
|
public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id)
|
||||||
{
|
{
|
||||||
$response = $this->calculatePremium($client_policy_id , $emp_code);
|
$response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id);
|
||||||
|
|
||||||
if(count($response[$emp_code]))
|
if(count($response[$emp_code]))
|
||||||
{
|
{
|
||||||
@ -1935,12 +1942,13 @@ class EmployeeRestController extends AdminController
|
|||||||
//Post method - which receives client_policy id and empcode of the family.
|
//Post method - which receives client_policy id and empcode of the family.
|
||||||
//Pull records againest emp code and calculate premium
|
//Pull records againest emp code and calculate premium
|
||||||
// retun array
|
// retun array
|
||||||
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level
|
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null , $client_branch_id = null)//family level
|
||||||
{
|
{
|
||||||
helper('excel_util_helper');
|
helper('excel_util_helper');
|
||||||
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
|
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
|
||||||
$emp_code = $this->request->getVar('emp_code') ?? $empCode;
|
$emp_code = $this->request->getVar('emp_code') ?? $empCode;
|
||||||
$default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
|
$default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
|
||||||
|
|
||||||
// dd($client_policy_id);
|
// dd($client_policy_id);
|
||||||
|
|
||||||
|
|
||||||
@ -1969,13 +1977,17 @@ class EmployeeRestController extends AdminController
|
|||||||
// dd($this->employeeModel->getLastQuery());
|
// dd($this->employeeModel->getLastQuery());
|
||||||
// print_r($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');
|
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
|
||||||
// print_r(($employee_data_group_by_family));die();
|
// print_r(($employee_data_group_by_family));//die();
|
||||||
|
|
||||||
|
|
||||||
|
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $client_branch_id);
|
||||||
|
|
||||||
foreach ($employee_data_group_by_family as $emp_id => $family)
|
foreach ($employee_data_group_by_family as $emp_id => $family)
|
||||||
{
|
{
|
||||||
$transformed_famility_details = transform_db_data_to_excel($family);
|
$transformed_famility_details = transform_db_data_to_excel($family);
|
||||||
// print_r($transformed_famility_details);die();
|
|
||||||
$data = calculate_premium($transformed_famility_details,$policy_terms,$slab_details,$file,$default_si);
|
$data = calculate_premium_new(family_data: $transformed_famility_details,policy_terms:$policy_terms,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units,default_si : $default_si);
|
||||||
// dd($data);
|
|
||||||
$employee_data_group_by_family[$emp_id] = $data;
|
$employee_data_group_by_family[$emp_id] = $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -924,7 +924,19 @@ if (!function_exists('calculate_premium_new'))
|
|||||||
$is_self_acting_self_set = true;
|
$is_self_acting_self_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$family_data[$val]['temp'] = ['max_age' => max($applicable_members_from_familiy['max_age']),'max_count' => $applicable_members_from_familiy['max_count'],'grid_name' => $key,'grid_master' => $slab['grid_master'],'acting_self' => $acting_self,'premium_type' => $slab['slab_rates'][0]['premium_type']];
|
//$family_data[$val]['temp'] = ['max_age' => max($applicable_members_from_familiy['max_age']),'max_count' => $applicable_members_from_familiy['max_count'],'grid_name' => $key,'grid_master' => $slab['grid_master'],'acting_self' => $acting_self,'premium_type' => $slab['slab_rates'][0]['premium_type']];
|
||||||
|
$family_data[$val]['temp'] = array_merge(
|
||||||
|
$family_data[$val]['temp'] ?? [], // existing 'temp' data or an empty array if it doesn't exist
|
||||||
|
[
|
||||||
|
'max_age' => max($applicable_members_from_familiy['max_age']),
|
||||||
|
'max_count' => $applicable_members_from_familiy['max_count'],
|
||||||
|
'grid_name' => $key,
|
||||||
|
'grid_master' => $slab['grid_master'],
|
||||||
|
'acting_self' => $acting_self,
|
||||||
|
'premium_type' => $slab['slab_rates'][0]['premium_type']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -999,7 +1011,6 @@ if (!function_exists('transform_excel_data_to_db'))
|
|||||||
{
|
{
|
||||||
function transform_excel_data_to_db($memArr,$actionArr)
|
function transform_excel_data_to_db($memArr,$actionArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
$current_column_action = null;
|
$current_column_action = null;
|
||||||
if($actionArr['action'] == 'inception'){ $current_column_action = 'I'; }
|
if($actionArr['action'] == 'inception'){ $current_column_action = 'I'; }
|
||||||
else if($actionArr['action'] == 'addition'){ $current_column_action = 'A'; }
|
else if($actionArr['action'] == 'addition'){ $current_column_action = 'A'; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user