Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
bfcfc4dd98
@ -87,6 +87,7 @@ class ClientController extends AdminController
|
||||
protected $vehicleModel;
|
||||
protected $leadsModel;
|
||||
protected $clientApi;
|
||||
protected $PTCOShareDetailsModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -123,6 +124,7 @@ class ClientController extends AdminController
|
||||
$this->vehicleModel = new VehicleModel();
|
||||
$this->leadsModel = new LeadsModel();
|
||||
$this->clientApi = new ClientApiModel();
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@ -270,7 +272,7 @@ class ClientController extends AdminController
|
||||
|
||||
if($mail_active == 1){
|
||||
$mail_send_return = MailHelper::send_email($wholeData[0]);
|
||||
$this->myLogger->logme("info", $mail_send_return);
|
||||
$this->myLogger->logme("error", $mail_send_return);
|
||||
}
|
||||
|
||||
// if (isset($wholeData)) {
|
||||
@ -1255,15 +1257,12 @@ class ClientController extends AdminController
|
||||
|
||||
public function editClientPolicy()
|
||||
{
|
||||
|
||||
// print_r('test'); die;
|
||||
$this->myLogger->logme('error', 'Client policy function called');
|
||||
|
||||
|
||||
$id = $this->request->getPost('PrimaryKey');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$id = $this->request->getPost('PrimaryKey');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$policy_type_id = $this->request->getPost('policy_type_id');
|
||||
$base_policy = $this->request->getPost('base_policy');
|
||||
$base_policy = $this->request->getPost('base_policy');
|
||||
|
||||
|
||||
$insurerValue = (string) $this->request->getPost('insurer');
|
||||
@ -1279,9 +1278,7 @@ class ClientController extends AdminController
|
||||
$data['client_id'] = $client_id;
|
||||
$data['tpa_id'] = $tpaId;
|
||||
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
|
||||
$data['policy_no'] = $this->request->getPost('policy_no');
|
||||
// $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
|
||||
// $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
|
||||
$data['policy_no'] = $this->request->getPost('policy_no');
|
||||
|
||||
$data['insured'] = $this->request->getPost('insured');
|
||||
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
|
||||
@ -1318,19 +1315,6 @@ class ClientController extends AdminController
|
||||
$data['reminder_date'] = null;
|
||||
}
|
||||
|
||||
// if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
|
||||
|
||||
// $data['is_addon'] = 1;
|
||||
|
||||
// }else if($policy_type_id == 4){
|
||||
|
||||
// $data['is_addon'] = 2;
|
||||
|
||||
// }else if($policy_type_id == 5){
|
||||
|
||||
// $data['is_addon'] = 3;
|
||||
// }
|
||||
|
||||
if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) {
|
||||
|
||||
$data['is_addon'] = 1; // Base Policy
|
||||
@ -1348,47 +1332,26 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
|
||||
|
||||
// if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
|
||||
// if ($this->request->getPost('is_addon') == 3) {
|
||||
// $policyTerm = $policy_terms['policy_terms'];
|
||||
// $decoded_policyTerm = json_decode($policyTerm, true);
|
||||
// $decoded_policyTerm['family_floater'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['self'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['spouse'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['childrens'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['parents'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['parents-in-law'] =0;
|
||||
// $decoded_policyTerm['family_floaters']['either-parents-pil'] =0;
|
||||
|
||||
// $data['policy_terms'] = json_encode($decoded_policyTerm);
|
||||
// } else {
|
||||
// $data['policy_terms'] = $policy_terms['policy_terms'];
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// dd($data);
|
||||
$old_client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $id)->first();
|
||||
$data['updated_by'] = get_session_userid();
|
||||
// print_r(json_encode($data));die;
|
||||
$insert = $this->clientPolicyModel->update($id, $data);
|
||||
$lastQuery = $this->clientPolicyModel->getLastQuery();
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($data); die;
|
||||
|
||||
if ($insert) {
|
||||
|
||||
$new_client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $id)->first();
|
||||
$policy_transaction_data = $this->policyTransactionModel->where('is_active', 1)->where('client_policy_id', $id)->countAllResult();
|
||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
|
||||
$clientPoliceData['role'] = get_role_id();
|
||||
// foreach ($clientPoliceData as $key => $value) {
|
||||
|
||||
// $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
|
||||
// $clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
|
||||
// }
|
||||
if($policy_transaction_data > 0){
|
||||
$r = Jobs::addJob(['job_name' => 'updatePolicyTransactionDataWhileClinetPolicyUpdate', 'payload' => [
|
||||
'old_client_policy_data' => $old_client_policy_data ?? null,
|
||||
'new_client_policy_data' => $new_client_policy_data ?? null,
|
||||
]]);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $clientPoliceData, 'method' => 'EDIT'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -1857,6 +1820,146 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePolicyTransactionWhileClinetPolicyUpdate($params)
|
||||
{
|
||||
try {
|
||||
// Basic validation
|
||||
if (empty($params) || !isset($params['old_client_policy_data']) || empty($params['old_client_policy_data'])) {
|
||||
$this->myLogger->logme("error", "Old client policy data is missing or empty: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Old client policy data is missing or empty", 'data' => $params];
|
||||
}
|
||||
|
||||
if (!isset($params['new_client_policy_data']) || empty($params['new_client_policy_data'])) {
|
||||
$this->myLogger->logme("error", "New client policy data is missing or empty: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "New client policy data is missing or empty", 'data' => $params];
|
||||
}
|
||||
|
||||
$old = $params['old_client_policy_data'];
|
||||
$new = $params['new_client_policy_data'];
|
||||
|
||||
$data = [];
|
||||
|
||||
// Check differences and prepare update data
|
||||
$fields_to_check = [
|
||||
'client_branch_id', 'policy_type', 'insurer_id', 'insurer_branch_id',
|
||||
'cd_ac_pk', 'policy_end_date', 'policy_start_date', 'tpa_id', 'tpa_branch_id'
|
||||
];
|
||||
|
||||
foreach ($fields_to_check as $field) {
|
||||
if (isset($new[$field]) && isset($old[$field]) && $new[$field] != $old[$field]) {
|
||||
$data[$field] = $new[$field];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
$this->myLogger->logme("error", "No changes detected in client policy update.");
|
||||
return ['status' => "Failed", 'message' => "No changes detected in policy data."];
|
||||
}
|
||||
|
||||
// Fetch related policy transactions
|
||||
$policy_transactions = $this->policyTransactionModel
|
||||
->where('is_active', 1)
|
||||
->where('client_policy_id', $new['client_policy_id'])
|
||||
->findAll();
|
||||
|
||||
$updated_pt_ids = [];
|
||||
|
||||
if (!empty($policy_transactions)) {
|
||||
|
||||
// Update each policy transaction and track affected IDs
|
||||
foreach ($policy_transactions as $pt) {
|
||||
$result = $this->policyTransactionModel
|
||||
->where('id', $pt['id'])
|
||||
->set($data)
|
||||
->update();
|
||||
|
||||
if ($this->policyTransactionModel->affectedRows() > 0) {
|
||||
$updated_pt_ids[] = $pt['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($updated_pt_ids)) {
|
||||
$this->myLogger->logme("error", "No policy_transaction records were updated.");
|
||||
return ['status' => "Failed", 'message' => "No records updated."];
|
||||
}
|
||||
|
||||
// If insurer-related fields are updated, update co-share table as well
|
||||
if (isset($data['insurer_id']) && !empty($data['insurer_id'])) {
|
||||
$co_share_result = $this->updatePTCoShareTableEntry($policy_transactions, $old, $data);
|
||||
$this->myLogger->logme("error", "PT co-share update result: " . json_encode($co_share_result));
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Policy transaction(s) updated successfully. Updated IDs: " . json_encode($updated_pt_ids));
|
||||
|
||||
return [
|
||||
'status' => "Success",
|
||||
'message' => "Policy transaction(s) updated.",
|
||||
'updated_ids' => $updated_pt_ids
|
||||
];
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme("error", "No active policy_transaction records found for update.");
|
||||
return ['status' => "Failed", 'message' => "No active policy_transaction records found."];
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme("error", "Exception during policy_transaction update: " . $e->getMessage());
|
||||
return [
|
||||
'status' => "Failed",
|
||||
'message' => "An error occurred during update.",
|
||||
'error' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function updatePTCoShareTableEntry($policy_transaction_data, $old_client_policy_data, $data)
|
||||
{
|
||||
$updated_ids = [];
|
||||
$errors = [];
|
||||
|
||||
foreach ($policy_transaction_data as $value) {
|
||||
$pt_id = $value['id'];
|
||||
|
||||
try {
|
||||
// Find matching rows
|
||||
$rows = $this->PTCOShareDetailsModel
|
||||
->where('pt_id', $pt_id)
|
||||
->where('insurer_id', $old_client_policy_data['insurer_id'])
|
||||
->where('insurer_branch_id', $old_client_policy_data['insurer_branch_id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
// Update each row individually
|
||||
$result = $this->PTCOShareDetailsModel
|
||||
->where('id', $row['id'])
|
||||
->set([
|
||||
'insurer_id' => $data['insurer_id'],
|
||||
'insurer_branch_id' => $data['insurer_branch_id'],
|
||||
])
|
||||
->update();
|
||||
|
||||
// Check if the update was successful
|
||||
if ($this->PTCOShareDetailsModel->affectedRows() > 0) {
|
||||
$updated_ids[] = $row['id'];
|
||||
} else {
|
||||
$errors[] = "No change or failed update for ID {$row['id']}";
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = "Error updating pt_id {$pt_id}: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'updated_ids' => $updated_ids,
|
||||
'errors' => $errors,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function uploadVehicleFile()
|
||||
@ -4612,6 +4715,7 @@ class ClientController extends AdminController
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live
|
||||
$EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live
|
||||
|
||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
// print_rr($result); die;
|
||||
@ -4636,12 +4740,12 @@ class ClientController extends AdminController
|
||||
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
|
||||
// $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]);
|
||||
|
||||
$params = [
|
||||
'client_policy_id' => 6090,
|
||||
'action_type' => "inception",
|
||||
];
|
||||
$res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction($params);
|
||||
dd($res);
|
||||
// $params = [
|
||||
// 'client_policy_id' => 6090,
|
||||
// 'action_type' => "inception",
|
||||
// ];
|
||||
// $res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction($params);
|
||||
// dd($res);
|
||||
|
||||
// $array = [
|
||||
// "employeeIds" => ["12800", "12798", "12797", "12799"],
|
||||
@ -4677,7 +4781,7 @@ class ClientController extends AdminController
|
||||
// $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
|
||||
// dd($returndata);
|
||||
|
||||
$LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]);
|
||||
// $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]);
|
||||
|
||||
// -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1929,7 +1929,9 @@ class EmpDataServiceController extends BaseController
|
||||
->first();
|
||||
|
||||
if (!empty($result_for_endorsement) && count($result_for_endorsement)) {
|
||||
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
|
||||
}
|
||||
$emp_endorsement_table_data[] = array('id' => $result_for_endorsement['id'], 'group_key' => $result_for_endorsement['group_key'], 'endorsement_id' => $value[18], 'status' => 'complete');
|
||||
}
|
||||
}
|
||||
@ -2388,7 +2390,9 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
// return $result;
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
}
|
||||
|
||||
if($result['field_name'] == 'dob'){
|
||||
$value[8] = change_date_format($value[8]);
|
||||
@ -2967,7 +2971,10 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
}
|
||||
|
||||
$emp_policy_ids[] = array('id' => $result['emp_policy_id'], 'is_active' => 0);
|
||||
$employeeIds[] = $result['emp_policy_id'];
|
||||
$endorsement_details[] = array('id' => $result['id'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[19], 'status' => 'complete');
|
||||
@ -3472,7 +3479,9 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id']; //files table primary key
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id']; //files table primary key
|
||||
}
|
||||
$employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
|
||||
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => change_date_format($result['date_of_exit']), 'reason_for_exit' => $result['reason_for_exit'], 'claim_status' => $result['claim_status'], 'status' => $result['status']);
|
||||
// $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
|
||||
@ -4735,6 +4744,14 @@ class EmpDataServiceController extends BaseController
|
||||
return ['status' => "Failed", 'message' => "Action type is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
//Function call for if the old policy transaction entries exisit than active the Policy transaction entries
|
||||
$existing_policy_transaction_entry = $this->retrivePolicyTransactionEntries($params);
|
||||
|
||||
if($existing_policy_transaction_entry != false){
|
||||
return $existing_policy_transaction_entry;
|
||||
}
|
||||
|
||||
//get the policy data
|
||||
$policy_data = $this->clientPolicyModel
|
||||
->where('id', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
@ -4745,6 +4762,7 @@ class EmpDataServiceController extends BaseController
|
||||
return ['status' => "Failed", 'message' => "No policy data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
//get the leads data
|
||||
$lead_data = $this->leadsModel
|
||||
->where('is_policy_created', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
@ -4752,13 +4770,15 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (empty($lead_data)) {
|
||||
$this->myLogger->logme("error", "No lead data found: " . json_encode(['client_policy_id' => $params['client_policy_id']]));
|
||||
return ['status' => "Failed", 'message' => "No lead data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
// return ['status' => "Failed", 'message' => "No lead data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Constructing policy transaction data: " . json_encode(['policy_data' => $policy_data, 'lead_data' => $lead_data]));
|
||||
|
||||
//Function to construct the policy transaction data to insert
|
||||
$policyTransactionData = $this->constructBDSData($policy_data, $lead_data, $params);
|
||||
|
||||
//insert the policy transaction data to othe table
|
||||
$insert_id = $this->policyTransactionModel->insert($policyTransactionData);
|
||||
|
||||
if (!$insert_id) {
|
||||
@ -4774,20 +4794,23 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// $this->myLogger->logme("error", "PT Co share data inserted successfully: " . json_encode(['pt_co_share_id' => $pt_co_share_id]));
|
||||
|
||||
$lead_installment_data = $this->leadInstallmentPaymentDetailesModel
|
||||
->select('lead_id, installment_amount, payment_date, utr_no')
|
||||
->where('lead_id', $lead_data['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
// get the lead installment data
|
||||
|
||||
if (!empty($lead_installment_data) && (isset($params['action_type']) && $params['action_type'] == "inception")) {
|
||||
$this->myLogger->logme("error", "Found lead installment data: " . json_encode($lead_installment_data));
|
||||
if(!empty($lead_data)){
|
||||
$lead_installment_data = $this->leadInstallmentPaymentDetailesModel
|
||||
->select('lead_id, installment_amount, payment_date, utr_no')
|
||||
->where('lead_id', $lead_data['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$installment_ids = $this->constructInstallmentData($lead_installment_data, $insert_id);
|
||||
if (!empty($lead_installment_data) && (isset($params['action_type']) && $params['action_type'] == "inception")) {
|
||||
|
||||
$this->myLogger->logme("error", "Installment data inserted: " . json_encode(['installment_ids' => $installment_ids]));
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to insert Installment data : " . json_encode($params));
|
||||
$this->myLogger->logme("error", "Found lead installment data: " . json_encode($lead_installment_data));
|
||||
$installment_ids = $this->constructInstallmentData($lead_installment_data, $insert_id);
|
||||
$this->myLogger->logme("error", "BDS Installment data inserted ids: " . json_encode(['installment_ids' => $installment_ids]));
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to insert Installment data : " . json_encode($params));
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => "Success", 'message' => "Policy transaction entry created successfully", 'data' => ['params' => $params, 'insert_id' => $insert_id]];
|
||||
@ -4834,12 +4857,13 @@ class EmpDataServiceController extends BaseController
|
||||
'is_cd_reduce_from_bds' => 0,
|
||||
'client_type_id' => 0,
|
||||
|
||||
'status' => "completed",
|
||||
'status' => "co_insurer_pending",
|
||||
'action_type' => $params['action_type'] ?? null,
|
||||
'endorsement_no' => $params['endorsement_no'] ?? null,
|
||||
'issue_type' => $lead_data['lead_type'] ?? null,
|
||||
|
||||
'issue_type' => $lead_data['lead_type'] ?? 1,
|
||||
'source_client_policy_id' => $lead_data['source_policy_id'] ?? null,
|
||||
'tsi' => generate_tsi_code($lead_data['lead_type']) ?? null,
|
||||
'tsi' => generate_tsi_code($lead_data['lead_type'] ?? 1) ?? null,
|
||||
'installment' => $lead_data['no_of_installment'] ?? null,
|
||||
];
|
||||
|
||||
@ -4877,12 +4901,129 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function retriveBDSPolicyTransactionEntry()
|
||||
private function retrivePolicyTransactionEntries($params)
|
||||
{
|
||||
$policy_transaction_data = $this->policyTransactionModel
|
||||
->where('is_active', 0)
|
||||
->where('client_policy_id', $params['client_policy_id']);
|
||||
|
||||
if ($params['action_type'] != "inception") {
|
||||
$policy_transaction_data = $policy_transaction_data->where('endorsement_no', $params['endorsement_no']);
|
||||
}
|
||||
|
||||
$policy_transaction_data = $policy_transaction_data
|
||||
->where('action_type', $params['action_type'])
|
||||
->first();
|
||||
|
||||
if(empty($policy_transaction_data)){
|
||||
$this->myLogger->logme("error", "retrive Policy Transaction Entries data not found : " . json_encode(['params' => $params]));
|
||||
return false;
|
||||
}
|
||||
|
||||
$pt_co_share_data = $this->PTCOShareDetailsModel->where('is_active', 0)->where('pt_id', $policy_transaction_data['id'])->findAll();
|
||||
|
||||
if(empty($pt_co_share_data)){
|
||||
$this->myLogger->logme("error", "PT Co Share Table data not found");
|
||||
}
|
||||
|
||||
$activated_pt_co_share_ids = [];
|
||||
foreach ($pt_co_share_data as $key => $value) {
|
||||
$this->PTCOShareDetailsModel->where('id', $value['id'])->set(['is_active' => 1])->update();
|
||||
$activated_pt_co_share_ids[] = $value['id'];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Activated pt_co_share_ids : ". json_encode($activated_pt_co_share_ids));
|
||||
|
||||
|
||||
$update_return = $this->policyTransactionModel->where('id', $policy_transaction_data['id'])->set(['is_active' => 1])->update();
|
||||
|
||||
if($update_return){
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Success", 'message' => "Policy transaction entry Retrived successfully", 'data' => ['params' => $params, 'updated_id' => $policy_transaction_data['id']]];
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Success", 'message' => "Failed to retrive the policy transaction entry", 'data' => ['params' => $params, 'updated_id' => $policy_transaction_data['id']]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function removeBDSPolicyTransactionEntryFromTruncate($params)
|
||||
{
|
||||
if (empty($params) || !isset($params['client_policy_id']) || empty($params['client_policy_id'])) {
|
||||
$this->myLogger->logme("error", "Invalid parameters provided: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Client Policy ID is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['file_id']) || empty($params['file_id'])) {
|
||||
$this->myLogger->logme("error", "File ID is missing or empty : " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "File ID is missing or empty : ", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['action_type']) || empty($params['action_type'])) {
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Action type is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$endorsement_data = $this->endorsementModel
|
||||
->where('is_active', 1)
|
||||
->where('client_policy_id', $params['client_policy_id'])
|
||||
->where('endorsement_type', $params['action_type'])
|
||||
->where('file_id', $params['file_id'])
|
||||
->first();
|
||||
|
||||
if(empty($endorsement_data)){
|
||||
$this->myLogger->logme("error", "Endorsement data not found");
|
||||
return ['status' => "Failed", 'message' => "Endorsement data not found", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
|
||||
$policy_transaction_data = $this->policyTransactionModel
|
||||
->where('is_active', 1)
|
||||
->where('client_policy_id', $params['client_policy_id']);
|
||||
|
||||
if ($params['action_type'] != "inception") {
|
||||
$policy_transaction_data = $policy_transaction_data->where('endorsement_no', $endorsement_data['endorsement_no']);
|
||||
}
|
||||
|
||||
$policy_transaction_data = $policy_transaction_data
|
||||
->where('action_type', $params['action_type'])
|
||||
->first();
|
||||
|
||||
|
||||
if(empty($policy_transaction_data)){
|
||||
$this->myLogger->logme("error", "Policy transaction data not found");
|
||||
return ['status' => "Failed", 'message' => "Policy transaction data not found", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
|
||||
$pt_co_share_data = $this->PTCOShareDetailsModel->where('is_active', 1)->where('pt_id', $policy_transaction_data['id'])->findAll();
|
||||
|
||||
if(empty($pt_co_share_data)){
|
||||
$this->myLogger->logme("error", "PT Co Share Table data not found");
|
||||
}
|
||||
|
||||
$de_activated_pt_co_share_ids = [];
|
||||
foreach ($pt_co_share_data as $key => $value) {
|
||||
$this->PTCOShareDetailsModel->where('id', $value['id'])->set(['is_active' => 0])->update();
|
||||
$de_activated_pt_co_share_ids[] = $value['id'];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "De-activated pt_co_share_ids : ". json_encode($de_activated_pt_co_share_ids));
|
||||
|
||||
$update_return = $this->policyTransactionModel->where('id', $policy_transaction_data['id'])->set(['is_active' => 0])->update();
|
||||
|
||||
if($update_return){
|
||||
$this->myLogger->logme("error", "Policy transaction data de-active successfully");
|
||||
return ['status' => "Success", 'message' => "Policy transaction data Truncated successfully", 'data' => ['params' => $params]];
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to de-active policy transaction data");
|
||||
return ['status' => "Success", 'message' => "Failed to truncated the policy transaction data", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1384,6 +1384,13 @@ class EmployeeController extends AdminController
|
||||
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
|
||||
}
|
||||
|
||||
//this job for deactive policy transaction and pt co share table entry for BDS Sync
|
||||
$r = Jobs::addJob(['job_name' => 'removeBDSPolicyTransactionEntryFromTruncate', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'file_id' => $file_id ?? null,
|
||||
'action_type' => $file['action'] ?? null,
|
||||
]]);
|
||||
|
||||
}else{
|
||||
|
||||
$this->myLogger->logme('error', '---- There is no data to truncate ----');
|
||||
@ -1534,6 +1541,13 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
//this job for deactive policy transaction and pt co share table entry for BDS Sync
|
||||
$r = Jobs::addJob(['job_name' => 'removeBDSPolicyTransactionEntryFromTruncate', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'file_id' => $file_id ?? null,
|
||||
'action_type' => $file['action'] ?? null,
|
||||
]]);
|
||||
|
||||
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'success'], 200);
|
||||
|
||||
@ -124,8 +124,12 @@ class JobWorker extends AdminController
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'makeEntryForBDSPolicyTransaction' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'removeBDSPolicyTransactionEntryFromTruncate' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'employeesEnrollmentInsert' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
@ -134,7 +138,11 @@ class JobWorker extends AdminController
|
||||
'calculateMembersDemography' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\LeadsController',
|
||||
]
|
||||
],
|
||||
'updatePolicyTransactionWhileClinetPolicyUpdate' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\ClientController',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ class EndorsementModel extends Model
|
||||
'created_at',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
'file_id',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user