CHNAGE_GMC_PARENT_WITH_SELF_HANDLED&AMT_IN_FILELIST

This commit is contained in:
velz 2024-05-17 14:32:59 +05:30
parent d0f6db8884
commit bf0b4c3d2b
7 changed files with 83 additions and 19 deletions

View File

@ -216,13 +216,40 @@ class EmployeeController extends AdminController
$data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
// $data['fileList'] = $this->fileModel
// ->select(['files.*', 'up.emp_code', 'up.first_name', 'pm.name as policy_name', 'c.short_name', 'cp.id as client_policy_id'])
// ->join('user_profiles up', 'files.created_by = up.id')
// ->join('client_policy cp', 'files.policy_id = cp.id', 'left')
// ->join('policies pm', 'cp.policy_id = pm.id', 'left')
// ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
// ->where('files.created_by', get_session_userid())->orderBy('files.created_at', 'desc')->findAll();
// dd($this->fileModel->getLastQuery());
$data['fileList'] = $this->fileModel
->select(['files.*', 'up.emp_code', 'up.first_name', 'pm.name as policy_name', 'c.short_name', 'cp.id as client_policy_id'])
->join('user_profiles up', 'files.created_by = up.id')
->join('client_policy cp', 'files.policy_id = cp.id', 'left')
->join('policies pm', 'cp.policy_id = pm.id', 'left')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
->where('files.created_by', get_session_userid())->orderBy('files.created_at', 'desc')->findAll();
->select([
'files.*',
'up.emp_code',
'up.first_name',
'pm.name as policy_name',
'c.short_name',
'cp.id as client_policy_id',
'(SELECT COUNT(*)
FROM employees e
JOIN employee_polices ep ON e.id = ep.employee_id
WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as employee_count',
'(SELECT SUM(ep.rata_premimum) + SUM(ep.gst)
FROM employees e
JOIN employee_polices ep ON e.id = ep.employee_id
WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as total'
])
->join('user_profiles up', 'files.created_by = up.id')
->join('client_policy cp', 'files.policy_id = cp.id', 'left')
->join('policies pm', 'cp.policy_id = pm.id', 'left')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
->where('files.created_by', get_session_userid())
->orderBy('files.created_at', 'desc')
->findAll();
// dd($data['fileList']);
$data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name')
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')

View File

@ -143,7 +143,7 @@ class EmployeeServiceController extends AdminController
$policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
$policy_terms = json_decode($policy_details[0]->policy_terms);
$policy_terms = (array) $policy_terms;// convert obj to array
$default_age_ratio = isset($policy_details[0]->age_ratio) ? json_decode($policy_details[0]->age_ratio) : [];
$default_age_ratio = isset($policy_terms['age_ratio']) ? json_decode(json_encode($policy_terms['age_ratio']),true) : [];
//
// dd($default_age_ratio);
@ -376,26 +376,28 @@ class EmployeeServiceController extends AdminController
}
}
if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') && ($policy_details['policy_type_id'] != 3)) // 3 is GMC parents (base policy or dep addon)
//check self availbale in uploaded file
if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $policy_details['base_policy'] == null)) // 3 is GMC parents dep addon)
{
// dd('file check');
$res = check_self_available_in_family($family,$file['action']);
// dd($res);
if(!$res['is_self_found'])
{
array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found ";
$result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found in uploaded file";
}
}
//check self avaialbe where self data is not available either in excel or same policy (i.e.) gMC parents
if($policy_details['policy_type_id'] == 3) // 3 is GMC parents (base policy or dep addon)
//check self avaialbe where self data is not available either same policy (i.e.) gMC parents
if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && $policy_details['base_policy'] == null)) // 3 is GMC parents as base policy not as dep addon)
{
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active']);
// dd($self_details);
if(!count($self_details))
{
array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found ";
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System";
}
}

View File

@ -185,7 +185,7 @@ class JobWorker extends AdminController
//die();
$job_status = self::STATUS_FAILED;
$runtime = $runtime === null ? microtime(true) - $start : $runtime;
$response = $e->getMessage();
$response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString()];
}
$db->query("UPDATE jobs SET status=?, run_time=?, response=? WHERE id=? AND uuid=?", [

View File

@ -185,6 +185,36 @@ if (!function_exists('get_base64_image')) {
}
if (!function_exists('format_indian_number')) {
function format_indian_number($number) {
// Round the number to two decimal places
$number = round($number, 2);
// Split the number into integer and decimal parts
$numberParts = explode('.', number_format($number, 2, '.', ''));
$integerPart = $numberParts[0];
$decimalPart = isset($numberParts[1]) ? $numberParts[1] : '00';
// Format the integer part with commas
$length = strlen($integerPart);
$formattedStr = '';
$counter = 0;
for ($i = $length - 1; $i >= 0; $i--) {
$formattedStr = $integerPart[$i] . $formattedStr;
$counter++;
if ($counter == 3 && $i != 0) {
$formattedStr = ',' . $formattedStr;
$counter = 0;
} elseif ($counter == 2 && $i != 0 && $length - $i > 3) {
$formattedStr = ',' . $formattedStr;
$counter = 0;
}
}
// Combine the integer and decimal parts
return $formattedStr . '.' . $decimalPart;
}
}

View File

@ -41,8 +41,9 @@ class ClientModel extends Model
foreach ($clients as &$client) {
$clientPolicyModel = new ClientPolicyModel();
$clientPolicies = $clientPolicyModel->select(['client_policy.id','p.name'])
$clientPolicies = $clientPolicyModel->select(['client_policy.id','p.name','pt.policy_type'])
->join('policies p', 'p.id = client_policy.policy_id')
->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.client_id',$client['id'])
->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1)

View File

@ -476,11 +476,10 @@ function appendPolicies(data) {
value: '',
text: 'Select'
}));
$.each(data, function(index, item) {
$('#policy_id').append($('<option>', {
value: item.id,
text: item.name
text: item.name + ' ('+ item.policy_type+')'
}));
});
}

View File

@ -59,10 +59,15 @@
}else if( $file['status'] == 'inprogress'){
echo '<a data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" class="reload" title="Click to reload" href="#">' . $file['status'] . '</a>';
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'],2,',') ." | Click to reload";
echo '<a data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" class="reload" title="'.$tool_tip_text.'" href="#">' . $file['status'] . '</a>';
}else{
echo $file['status'];
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'],2,',') ;
// $tool_tip_text = "dssd";
// Total Amount : $file['total']";
echo '<span data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" title=" '. $tool_tip_text.' ">' . $file['status'] . '</span>';
}
?>
</td>