Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
vadivelJ96 2025-10-29 17:31:50 +05:30
commit f2e79abfe7
5 changed files with 277 additions and 104 deletions

View File

@ -5673,7 +5673,7 @@ class ClientController extends AdminController
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]);
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
// $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]);
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '1131']);
// $res = $empServiceController->employeeDisembark(['file_id' => '1681']);
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']);
// $res = $empServiceController->compareMemberDataAndInceptionData(['file_id' => '1126']);
@ -5737,8 +5737,8 @@ class ClientController extends AdminController
// $res = $EmpDataServiceController->generateExcelForCorrection($batch_data);
// $res = $EmpDataServiceController->importInceptionFileValidation(['file_id' => 1932]); die;
// $res = $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
// $res = $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live
// $res = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live
// $res = $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 387]); //for live
// $res = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 387]); //for live
// $res = $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live
// $res = $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 310]); dd($res);//for live
// $res = $EmpDataServiceController->getInceptionBasePremium(["13332","13333","13334","13335","13336"]); dd($res);//for live

View File

@ -3202,6 +3202,7 @@ class EmpDataServiceController extends BaseController
$empData['rata_premimum'] = $value[16];
$empData['gst'] = $value[17];
$empData['created_by'] = $user_id;
$empData['old_basic_cover_si'] = $value[9];
$emp_details[] = $empData;
}
@ -3222,11 +3223,41 @@ class EmpDataServiceController extends BaseController
// $insertedIds[] = $startId + $i;
// }
// $insertedIds = [];
// foreach ($emp_details as $emp) {
// $old_si_value = $emp['old_basic_cover_si'];
// $new_si_value = $emp['basic_cover_si'];
// if($old_si_value < $new_si_value){
// $insertedIds['si_adjustment'] = 2;
// }else{
// $insertedIds['si_adjustment'] = 1;
// }
// unset($emp['old_basic_cover_si']);
// $insertedIds['pk'] = $this->employeePolicyModel->insert($emp);
// }
$insertedIds = [];
foreach ($emp_details as $emp) {
$insertedIds[] = $this->employeePolicyModel->insert($emp);
}
$old_si_value = $emp['old_basic_cover_si'];
$new_si_value = $emp['basic_cover_si'];
// Determine SI adjustment type
$si_adjustment = ($old_si_value < $new_si_value) ? 1 : 2;
unset($emp['old_basic_cover_si']);
// Insert and store PK with adjustment info
$pk = $this->employeePolicyModel->insert($emp);
$insertedIds[] = [
'pk' => $pk,
'si_adjustment' => $si_adjustment
];
}
// dd($insertedIds);
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
@ -3241,7 +3272,6 @@ class EmpDataServiceController extends BaseController
'amount' => $rounded_totals,
]);
$this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]);
$this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]);
@ -4278,60 +4308,164 @@ class EmpDataServiceController extends BaseController
}
public function cashDepositCalculationForSIEnhancement($arrayData)
{
// return $arrayData;
// public function cashDepositCalculationForSIEnhancement($arrayData)
// {
// // return $arrayData;
// if (!empty($arrayData)) {
// $client_branch_data = $this->clientBranchModel->where('id', $arrayData['client_branch_id'])->first();
// $units = json_decode($client_branch_data['units']);
// foreach($units as $unit)
// {
// $amount = $this->employeePolicyModel->query("
// SELECT SUM(rata_premimum + gst) AS total_sum
// FROM employee_polices
// JOIN employees ON employees.id = employee_polices.employee_id
// WHERE employees.unit = '$unit'
// AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
// ")->getRow();
// if($amount){
// $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
// $description = 'The following amount of ' . round($amount->total_sum, 2) . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event_name']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
// $data = [
// 'amount' => $amount->total_sum,
// 'sub_type_id' => 4,
// 'client_id' => $arrayData['client_id'],
// 'client_policy_id' => $arrayData['client_policy_id'],
// 'endorsement_no' => $arrayData['endorsement_no'] ?? null,
// 'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
// 'insurer_id' => $insurer_id['insurer_id'],
// 'unit' => $unit,
// 'description' => $description,
// 'transaction_type' => 'Debit',
// 'updated_by' => $arrayData['user_id'],
// 'event_name' => $arrayData['event_name'],
// 'is_active' => 1,
// 'cd_ac_pk' => $insurer_id['cd_ac_pk']
// ];
// $response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
// }
// }
// $msg = "SI Enhancement Cash Deposite Updated Successfully ";
// return [$msg];
// // print_r($response);
// // $query = $this->employeePolicyModel->getLastQuery();
// // echo $query . "<br>";
// } else {
// return 0;
// }
// }
public function cashDepositCalculationForSIEnhancement($arrayData)
{
if (!empty($arrayData)) {
$client_branch_data = $this->clientBranchModel->where('id', $arrayData['client_branch_id'])->first();
$units = json_decode($client_branch_data['units']);
foreach($units as $unit)
{
foreach ($units as $unit) {
$amount = $this->employeePolicyModel->query("
SELECT SUM(rata_premimum + gst) AS total_sum
FROM employee_polices
JOIN employees ON employees.id = employee_polices.employee_id
WHERE employees.unit = '$unit'
AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
$si_enhance_amt = 0;
$si_decrease_amt = 0;
if($amount){
foreach ($arrayData['employeeIds'] as $value) {
$insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
$description = 'The following amount of ' . round($amount->total_sum, 2) . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event_name']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
// If $value is an array, get its elements; otherwise, assign defaults
$pk = is_array($value) ? ($value['pk'] ?? null) : $value;
$si_adjustment = is_array($value) ? ($value['si_adjustment'] ?? null) : $value;
$query = "
SELECT SUM(rata_premimum + gst) AS total_sum
FROM employee_polices
JOIN employees ON employees.id = employee_polices.employee_id
WHERE employees.unit = '{$unit}'
AND employee_polices.id = '{$pk}'
";
$amount = $this->employeePolicyModel->query($query)->getRow();
if ($amount && $amount->total_sum > 0) {
if ($si_adjustment == 2) {
$si_decrease_amt += $amount->total_sum;
} else {
$si_enhance_amt += $amount->total_sum;
}
}
}
// Save Enhancement amount
if ($si_enhance_amt > 0) {
$policy_data = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
$description = 'An amount of ' . round($si_enhance_amt, 2) .
' has been debited for ' . $arrayData['count'] . ' employees under ' .
remove_underscore_capitalize_first_letter($arrayData['event_name']) .
' in ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
$data = [
'amount' => $amount->total_sum,
'amount' => round($si_enhance_amt, 2),
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'insurer_id' => $policy_data['insurer_id'],
'unit' => $unit,
'description' => $description,
'transaction_type' => 'Debit',
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
'cd_ac_pk' => $insurer_id['cd_ac_pk']
'cd_ac_pk' => $policy_data['cd_ac_pk']
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
DepositHelper::saveDeposit($data, $arrayData['user_id']);
}
// Save Decrease amount
if ($si_decrease_amt > 0) {
$policy_data = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
$description = 'An amount of ' . round($si_decrease_amt, 2) .
' has been credited for ' . $arrayData['count'] . ' employees due to a decrease in Sum Insured (SI) under ' .
remove_underscore_capitalize_first_letter($arrayData['event_name']) .
' in ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
$data = [
'amount' => round($si_decrease_amt, 2),
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $policy_data['insurer_id'],
'unit' => $unit,
'description' => $description,
'transaction_type' => 'Credit',
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
'cd_ac_pk' => $policy_data['cd_ac_pk']
];
DepositHelper::saveDeposit($data, $arrayData['user_id']);
}
}
$msg = "SI Enhancement Cash Deposite Updated Successfully ";
$msg = "SI Adjustment Cash Deposit Updated Successfully.";
return [$msg];
// print_r($response);
// $query = $this->employeePolicyModel->getLastQuery();
// echo $query . "<br>";
} else {
return 0;
}

View File

@ -2172,6 +2172,7 @@ class EmployeeMultiEventServiceController extends BaseController
->where('emp_status', 'active')
->where('is_active', 1)
->first();
$employee_policy = $this->employeePolicyModel
->where('employee_id', $employee['id'])
->where('client_policy_id', $file['policy_id'])
@ -2186,8 +2187,11 @@ class EmployeeMultiEventServiceController extends BaseController
->where('emp_code', $employee['emp_code'])
->where('name', $employee['name'])
->where('field_name', 'basic_cover_si')
->where('is_active', 1)
->where('status !=', 'truncated')
->findAll();
// dd($existing_endorsements);
//make entry in endorsement table
if (!count($existing_endorsements)) {
//transform data to send
@ -2235,6 +2239,8 @@ class EmployeeMultiEventServiceController extends BaseController
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'basic_cover_si', 'old_value' => $employee_policy['basic_cover_si'], 'new_value' => $row[3], 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'premium', 'old_value' => $employee_policy['premium'], 'new_value' => $calculated_data['policy_details']['premium'], 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'si_enhancement_date', 'old_value' => null, 'new_value' => change_date_format($row[4], 'd-M-Y', 'Y-m-d'), 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
}else {
$this->myLogger->logme("error", 'Endorsement already exists for this employee ' . json_encode(['file_id' => $file_id, 'emp_code' => $employee['emp_code'], 'emp_name' => $employee['name']]));
}
}

View File

@ -1680,75 +1680,75 @@ class EmployeeServiceController extends AdminController
//enhance of emp
public function employeesSIEnhanceProcess($params)
{
helper('excel_util_helper');
helper('excel_util_helper');
//get file name
$file_id = $params['file_id'];
$file = $this->fileModel->find($file_id);
// dd($file);
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
$file_name_with_path = WRITEPATH . "/uploads/excel/" . $file['file_name'];
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$allowedHighestColumn = end($this->si_enhance_excel_columns);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
// dd($excel_data);
//get policy slab rates
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'], $file['client_id']);
//iterate each row
// dd($slab_details);
foreach ($excel_data as $col_key => $row)
{
if(check_row_is_empty_or_null($row))
{
break;
foreach ($excel_data as $col_key => $row) {
if (check_row_is_empty_or_null($row)) {
break;
}
$row[3] = removeNumberFormatting($row[3]);
// echo '<br>START- ' . $row[2];
$employee = $this->employeeModel
->where('emp_code', $row[1])
->where('name',$row[2])
->where('client_id',$file['client_id'])
->where('client_branch_id',$file['client_branch_id'])
->where('emp_status', 'active')
->where('is_active', 1)
->first();
->where('emp_code', $row[1])
->where('name', $row[2])
->where('client_id', $file['client_id'])
->where('client_branch_id', $file['client_branch_id'])
->where('emp_status', 'active')
->where('is_active', 1)
->first();
$employee_policy = $this->employeePolicyModel
->where('employee_id',$employee['id'])
->where('client_policy_id',$file['policy_id'])
->where('employee_id', $employee['id'])
->where('client_policy_id', $file['policy_id'])
->where('status', 'active')
->where('is_active', 1)
->first();
// dd($employee, $employee_policy);
$existing_endorsements = $this->empEndorsementModel->where('actions','si')
->where('table_name','employee_polices')
->where('endorsement_id is null')
->where('emp_code',$employee['emp_code'])
->where('name',$employee['name'])
->where('field_name','basic_cover_si')
->findAll();
// dd($existing_endorsements);
//make entry in endorsement table
if(!count($existing_endorsements))
{
$existing_endorsements = $this->empEndorsementModel->where('actions', 'si')
->where('table_name', 'employee_polices')
->where('endorsement_id is null')
->where('emp_code', $employee['emp_code'])
->where('name', $employee['name'])
->where('field_name', 'basic_cover_si')
->where('is_active', 1)
->where('status !=', 'truncated')
->findAll();
// dd($existing_endorsements);
//make entry in endorsement table
if (!count($existing_endorsements)) {
//transform data to send
//get applicable slab rate for current member relation
$pre_rack_rate_name = '';
$applicable_rack_rate_name = '';
$applicable_rack_rate_master = [];
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
{
if($pre_rack_rate_name != $slab_value['rack_rate_name'])
{
foreach ($slab_details['slab_rates'] as $skey => $slab_value) {
if ($pre_rack_rate_name != $slab_value['rack_rate_name']) {
$pre_rack_rate_name = $slab_value['rack_rate_name'];
$rack_rate_json = json_decode($slab_value['additional_relationship'], true);
$relationship_array_key = strtolower(trim($employee['relationship']));
@ -1761,46 +1761,42 @@ class EmployeeServiceController extends AdminController
$relationship_array_key = 'parents-in-law';
}
if(array_key_exists($relationship_array_key, $rack_rate_json) && $rack_rate_json[$relationship_array_key] != 0 && $rack_rate_json[$relationship_array_key] != 'NA')
{
if (array_key_exists($relationship_array_key, $rack_rate_json) && $rack_rate_json[$relationship_array_key] != 0 && $rack_rate_json[$relationship_array_key] != 'NA') {
$applicable_rack_rate_name = $slab_value['rack_rate_name'];
$applicable_rack_rate_master = $slab_value['grid_master'];
break;
}
}
}
//get max age,max count of the familiy
$max_age_and_max_count_of_current_member = $this->employeeModel->getFamiliyCountAndMaxage($employee['emp_code']);
//transform SI excel row data as inception excel OR premium calculateable fomart
$data = transform_si_excel_row_to_calculatable_format(employee: $employee,employee_policy: $employee_policy,maxage_and_maxcount: $max_age_and_max_count_of_current_member,slab_details: $slab_details,applicable_slab_name: $applicable_rack_rate_name,augmented_si: $row[3],grid_master: $applicable_rack_rate_master);
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
$data = transform_si_excel_row_to_calculatable_format(employee: $employee, employee_policy: $employee_policy, maxage_and_maxcount: $max_age_and_max_count_of_current_member, slab_details: $slab_details, applicable_slab_name: $applicable_rack_rate_name, augmented_si: $row[3], grid_master: $applicable_rack_rate_master);
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'], $file['policy_id']);
$policy_terms = (array) $policy_terms[0];
// dd($policy_terms);
//grouping slab details by rack rate name
$temp_slab_rates = group_slab_rates_basedon_name($slab_details);
$calculated_data = premium_calculation_manager($data,$policy_terms,$temp_slab_rates,$row[3]);
$calculated_data = premium_calculation_manager($data, $policy_terms, $temp_slab_rates, $row[3]);
$group_key = rand(100000, 999999);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $calculated_data['policy_details']['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$group_key = rand(100000, 999999);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'basic_cover_si', 'old_value' => $employee_policy['basic_cover_si'], 'new_value' => $row[3], 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'premium', 'old_value' => $employee_policy['premium'], 'new_value' => $calculated_data['policy_details']['premium'], 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'], 'emp_code' => $employee['emp_code'], 'table_name' => 'employee_polices', 'actions' => 'si', 'name' => $employee['name'], 'field_name' => 'si_enhancement_date', 'old_value' => null, 'new_value' => change_date_format($row[4], 'd-M-Y', 'Y-m-d'), 'created_by' => $file['created_by'], 'remarks' => 'general si enhancement', 'group_key' => $group_key, 'file_id' => $file['id'], 'status' => 'pending']);
} else {
$this->myLogger->logme("error", 'Endorsement already exists for this employee ' . json_encode(['file_id' => $file_id, 'emp_code' => $employee['emp_code'], 'emp_name' => $employee['name']]));
}
}
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
//set success msg to pull notifications
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
return true;
$this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
return true;
}
// insert or update in db for inception addition depent addition

View File

@ -611,6 +611,36 @@ class EmployeePolicyModel extends Model
$subquery_endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "WHERE (endorsement_id IS NOT NULL OR endorsement_id != '')" : "WHERE (endorsement_id IS NULL OR endorsement_id = '')";
/*
ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
ROUND(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365,
2
) AS pro_rata_premium,
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18,
2
) AS gst,
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) +
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18,
2
),
2
) AS total
*/
$query = $this->db->query("
SELECT
a.id AS endorsement_primarykey,
@ -643,33 +673,40 @@ class EmployeePolicyModel extends Model
sidata.old_si_premium,
sidata.date_of_coverage,
DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
ROUND(ABS(sidata.new_si_premium - sidata.old_si_premium), 2) AS difference_premium,
ROUND(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365,
ABS(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
),
2
) AS pro_rata_premium,
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18,
ABS(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18
),
2
) AS gst,
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) +
ROUND(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18,
2
ABS(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) +
(
(
(sidata.new_si_premium - sidata.old_si_premium) *
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
) * 0.18
)
),
2
) AS total
FROM
emp_endorsement a
LEFT JOIN employees ON employees.emp_code = a.emp_code