CHANGE_BDS_ALL_FILTER_POLICY_ISSUE_DATE_TO_PT_CO_SHARE

This commit is contained in:
VENKATESHWARAN 2025-11-26 18:19:23 +05:30
parent f90b464feb
commit d48f5ddcf4
5 changed files with 185 additions and 124 deletions

View File

@ -1394,9 +1394,9 @@ class EmployeeServiceController extends AdminController
// Kint::dump($family); // Kint::dump($family);
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units); $data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
if($file['action'] == 'dependent_addition') { // if($file['action'] == 'dependent_addition') {
$data = validatet_family_floter_rata_premium($data); // $data = validatet_family_floter_rata_premium($data);
} // }
// dd($data); // dd($data);
$employee_data_group_by_family[$emp_id] = $data; $employee_data_group_by_family[$emp_id] = $data;
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]); $this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);

View File

@ -3208,116 +3208,116 @@
} }
public function reportBDSNew() public function reportBDSNew()
{ {
// 🧭 Basic Page Info // 🧭 Basic Page Info
$data['tab_name'] = 'BDS Report'; $data['tab_name'] = 'BDS Report';
$data['page_name'] = 'BDS Report'; $data['page_name'] = 'BDS Report';
// 📋 Dropdown Data // 📋 Dropdown Data
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$data['policy_status'] = [ $data['policy_status'] = [
'pending' => 'Pending', 'pending' => 'Pending',
'exported_to_insurer' => 'Exported to Insurer', 'exported_to_insurer' => 'Exported to Insurer',
'imported_from_insurer'=> 'Imported from Insurer', 'imported_from_insurer'=> 'Imported from Insurer',
'exported_to_tpa' => 'Exported to TPA', 'exported_to_tpa' => 'Exported to TPA',
'imported_from_tpa' => 'Imported from TPA', 'imported_from_tpa' => 'Imported from TPA',
'completed' => 'Completed' 'completed' => 'Completed'
]; ];
$data['invoice_status_array'] = [ $data['invoice_status_array'] = [
'yet_to_generate' => 'Yet to Generate', 'yet_to_generate' => 'Yet to Generate',
'generated' => 'Generated', 'generated' => 'Generated',
'send' => 'Send', 'send' => 'Send',
'recived' => 'Recived', 'recived' => 'Recived',
]; ];
$data['date_type'] = [ $data['date_type'] = [
'policy_issue_date' => 'Policy Issue Date', 'policy_issue_date' => 'Policy Issue Date',
'policy_start_date' => 'Policy Start Date', 'policy_start_date' => 'Policy Start Date',
'policy_end_date' => 'Policy End Date', 'policy_end_date' => 'Policy End Date',
'data_received_date' => 'Data Received Date', 'data_received_date' => 'Data Received Date',
'closure_date' => 'Closure Date', 'closure_date' => 'Closure Date',
'statement_month' => 'Statement Month', 'statement_month' => 'Statement Month',
]; ];
// 🏢 Fetch Active Data // 🏢 Fetch Active Data
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll(); $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll(); $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll(); $data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
$data['users'] = $this->userModel->where('is_active', 1)->findAll(); $data['users'] = $this->userModel->where('is_active', 1)->findAll();
$data['policy_count'] = $this->policyTransactionModel->where('is_active', 1)->countAllResults(); $data['policy_count'] = $this->policyTransactionModel->where('is_active', 1)->countAllResults();
// 🕐 Filters // 🕐 Filters
$start_date = $this->request->getGet('start_date'); $start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date'); $end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id'); $client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id'); $insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id'); $policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type'); $date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer'); $issuer = $this->request->getGet('issuer');
$client_branch_id = $this->request->getGet('client_branch_id'); $client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id'); $insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id'); $client_policy_id = $this->request->getGet('client_policy_id');
$user_id = $this->request->getGet('user_id'); $user_id = $this->request->getGet('user_id');
// Handle statement month range // Handle statement month range
if ($date_type == 'statement_month') { if ($date_type == 'statement_month') {
$start_date = (string) date('Y-m-01', strtotime($start_date)); $start_date = (string) date('Y-m-01', strtotime($start_date));
$end_date = (string) date('Y-m-31', strtotime($end_date)); $end_date = (string) date('Y-m-31', strtotime($end_date));
} }
// Ensure default values // Ensure default values
$start_date = $start_date ?: 0; $start_date = $start_date ?: 0;
$end_date = $end_date ?: 0; $end_date = $end_date ?: 0;
$client_id = $client_id ?: 0; $client_id = $client_id ?: 0;
$insurer_id = $insurer_id ?: 0; $insurer_id = $insurer_id ?: 0;
$policy_type_id = $policy_type_id ?: 0; $policy_type_id = $policy_type_id ?: 0;
$date_type = $date_type ?: 0; $date_type = $date_type ?: 0;
$issuer = $issuer ?: 0; $issuer = $issuer ?: 0;
$client_branch_id = $client_branch_id ?: 0; $client_branch_id = $client_branch_id ?: 0;
$insurer_branch_id = $insurer_branch_id ?: 0; $insurer_branch_id = $insurer_branch_id ?: 0;
$client_policy_id = $client_policy_id ?: 0; $client_policy_id = $client_policy_id ?: 0;
$user_id = $user_id ?: 0; $user_id = $user_id ?: 0;
// 🧾 Handle POST requests (Dashboard filters) // 🧾 Handle POST requests (Dashboard filters)
if ($this->request->is('post')) { if ($this->request->is('post')) {
$isFromDashboard = $this->request->getPost('is_dashboard'); $isFromDashboard = $this->request->getPost('is_dashboard');
if (!empty($isFromDashboard) && $isFromDashboard == 1) { if (!empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = array_filter(explode(',', $this->request->getPost('ids'))); $ids = array_filter(explode(',', $this->request->getPost('ids')));
if (!empty($ids)) { if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs $idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs
$where = "policy_transaction.id IN ($idsStr)"; $where = "policy_transaction.id IN ($idsStr)";
} else { } else {
$where = []; // No valid IDs $where = []; // No valid IDs
}
} }
} }
// 📊 Fetch report data
$data['report_list'] = $this->policyTransactionModel->reportBDSNew(
$start_date,
$end_date,
$client_id,
$insurer_id,
$policy_type_id,
$date_type,
$issuer,
$client_branch_id,
$insurer_branch_id,
$client_policy_id,
$user_id,
$where ?? ''
);
$data['list_new'] = true;
// 🧩 Load View
$this->loadLayout('report_bds_filter', $data);
} }
// 📊 Fetch report data
$data['report_list'] = $this->policyTransactionModel->reportBDSNew(
$start_date,
$end_date,
$client_id,
$insurer_id,
$policy_type_id,
$date_type,
$issuer,
$client_branch_id,
$insurer_branch_id,
$client_policy_id,
$user_id,
$where ?? ''
);
$data['list_new'] = true;
// 🧩 Load View
$this->loadLayout('report_bds_filter', $data);
}
} }

View File

@ -1022,8 +1022,8 @@ if (!function_exists('transform_excel_data_to_db')) {
} }
} }
if (!function_exists('premium_calculation_manager_old')) { if (!function_exists('premium_calculation_manager')) {
function premium_calculation_manager_old($emp_data, $policy_terms, $slab_details, $default_si = null) function premium_calculation_manager($emp_data, $policy_terms, $slab_details, $default_si = null)
{ {
// dd($emp_data,$policy_terms,$slab_details,$default_si); // dd($emp_data,$policy_terms,$slab_details,$default_si);
@ -1429,8 +1429,8 @@ if (!function_exists('premium_calculation_manager_old')) {
} }
} }
if (!function_exists('premium_calculation_manager')) { if (!function_exists('premium_calculation_manager_new')) {
function premium_calculation_manager($emp_data, $policy_terms, $slab_details, $default_si = null) function premium_calculation_manager_new($emp_data, $policy_terms, $slab_details, $default_si = null)
{ {
// dd($emp_data,$policy_terms,$slab_details,$default_si); // dd($emp_data,$policy_terms,$slab_details,$default_si);

View File

@ -826,8 +826,16 @@
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) // $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); // ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} }
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){ // if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
@ -1043,8 +1051,18 @@
// Optimize Date Filtering // Optimize Date Filtering
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) { if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
$builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date))); $startDate = change_date_format($start_date, 'd/m/Y', 'Y-m-d 00:00:00');
$endDate = change_date_format($end_date, 'd/m/Y', 'Y-m-d 23:59:59');
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where("policy_transaction.$date_type >=", $startDate)
->where("policy_transaction.$date_type <=", $startDate);
}
} }
// Apply Filters Only When Necessary // Apply Filters Only When Necessary
@ -1080,6 +1098,7 @@
// Optimize Query Execution // Optimize Query Execution
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
$data = $builder->get()->getResultArray(); $data = $builder->get()->getResultArray();
// dd($this->db->getLastQuery());
return $data; return $data;
} }
@ -1134,11 +1153,17 @@
if ($start_date != 0 && $end_date != 0 && $date_type != 0) { if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = change_date_format($start_date, 'd/m/Y', 'Y-m-d 00:00:00');
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = change_date_format($end_date, 'd/m/Y', 'Y-m-d 23:59:59');
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
} else { } else {
// $fromDate = date('Y-m-d', strtotime('-30 days')); // $fromDate = date('Y-m-d', strtotime('-30 days'));
@ -1177,7 +1202,7 @@
} }
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
// dd($this->db->getLastQuery());
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
@ -1315,8 +1340,17 @@
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) // $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); // ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else { } else {
$fromDate = date('Y-m-d', strtotime('-90 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1356,8 +1390,10 @@
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
$return_data = $builder->get()->getResultArray();
// dd(db_connect()->getLastQuery());
return $builder->get()->getResultArray(); return $return_data;
} }
public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
@ -1418,8 +1454,16 @@
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) // $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); // ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else { } else {
$fromDate = date('Y-m-d', strtotime('-90 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1521,8 +1565,17 @@
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) // $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); // ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else { } else {
$fromDate = date('Y-m-d', strtotime('-90 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
@ -1627,8 +1680,16 @@
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) // $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); // ->where('policy_transaction.' . $date_type . '<=', $endDate);
if($date_type == "policy_issue_date"){
$builder->where("pt_co_share_details.pt_policy_issue_date >=", $startDate)
->where("pt_co_share_details.pt_policy_issue_date <=", $endDate);
}else{
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate);
}
} else { } else {
$fromDate = date('Y-m-d', strtotime('-90 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');

View File

@ -440,7 +440,7 @@
</tr> </tr>
<tr id="table_tr_40" > <tr id="table_tr_40" >
<td>Policy Issue Date</td> <td>Endorsement Issue Date</td>
</tr> </tr>
<tr id="table_tr_3" style="display: none;"> <tr id="table_tr_3" style="display: none;">