CHANGE_in calculatePremium : GWM
This commit is contained in:
parent
b5e466f31d
commit
68ca777e17
@ -1441,6 +1441,64 @@ public function iAgreeForAddOn()
|
|||||||
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Post method - which receives client_policy id and empcode of the family.
|
||||||
|
//Pull records againest emp code and calculate premium
|
||||||
|
// retun array
|
||||||
|
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') ?? $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
|
||||||
|
// dd($client_policy_id);
|
||||||
|
|
||||||
|
|
||||||
|
$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);
|
||||||
|
// 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());
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
$transformed_famility_details = transform_db_data_to_excel($family);
|
||||||
|
$data = calculate_premimum($transformed_famility_details,$policy_terms,$slab_details,$file,$default_si);
|
||||||
|
// dd($data);
|
||||||
|
$employee_data_group_by_family[$emp_id] = $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($clientPolicyId != null && $empCode != null)
|
||||||
|
{
|
||||||
|
return $employee_data_group_by_family;
|
||||||
|
}else{
|
||||||
|
// dd ($employee_data_group_by_family);
|
||||||
|
return $this->respond(['status' => 'success','code' => (count($employee_data_group_by_family) ? 200 : 404),'data' => [$employee_data_group_by_family] ], 200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCashDepositData()
|
public function getCashDepositData()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user