From f76c356729d835157a35984130eebd91e165064a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 8 Jan 2025 15:28:58 +0530 Subject: [PATCH] FEAT_AUTO_SI : RV --- app/Config/Routes.php | 2 + app/Controllers/ClientController.php | 127 +- app/Helpers/excel_util_helper.php | 47 +- app/Models/AutoSIModel.php | 53 + app/Models/ClientPolicyModel.php | 3 +- app/Views/client_policy.php | 3345 +++++++++++++------------- app/Views/rack_rate_auto_si.php | 352 +++ 7 files changed, 2262 insertions(+), 1667 deletions(-) create mode 100644 app/Models/AutoSIModel.php create mode 100644 app/Views/rack_rate_auto_si.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8399284..5fa8c80 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -335,6 +335,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping'); $routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1'); $routes->get('transformMailContent', 'LeadsController::transformMailContent'); + $routes->get('getRackRateSIAmountAndAutoSiDataForAutoSI', 'ClientController::getRackRateSIAmountAndAutoSiDataForAutoSI'); + $routes->post('createAutoSI', 'ClientController::createAutoSI'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 0b15d13..f87019a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -39,6 +39,7 @@ use App\Models\PolicyTransactionModel; use App\Models\PolicyTransactionStatusModel; use App\Models\VehicleModel; use App\Models\LeadsModel; +use App\Models\AutoSIModel; use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; @@ -80,6 +81,7 @@ class ClientController extends AdminController protected $policyTransactionStatusModel; protected $vehicleModel; protected $leadsModel; + protected $AutoSIModel; @@ -116,6 +118,7 @@ class ClientController extends AdminController $this->policyTransactionStatusModel = new PolicyTransactionStatusModel(); $this->vehicleModel = new VehicleModel(); $this->leadsModel = new LeadsModel(); + $this->AutoSIModel = new AutoSIModel(); } //-------------------------------------------------------------------------------------------------------- @@ -3876,28 +3879,29 @@ class ClientController extends AdminController // $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]); - $EmpDataServiceController = new EmpDataServiceController(); + // $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]); // $EmpDataServiceController->importDeletionValidation(['file_id' => 171]); // $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]); - $array = [ - "employeeIds" => ["12800", "12798", "12797", "12799"], - "client_id" => "159", - "client_policy_id" => "336", - "client_branch_id" => "126", - "cd_ac_no" => "Apple_123", - "endorsement_no" => "ENDORSEMENT_ID", - "count" => 4, - "event_name" => "deletion", - "policy_name" => "GMC", - "user_id" => "1" - ]; - $EmpDataServiceController->cashDepositCalculationForDeletion($array); + // $array = [ + // "employeeIds" => ["12800", "12798", "12797", "12799"], + // "client_id" => "159", + // "client_policy_id" => "336", + // "client_branch_id" => "126", + // "cd_ac_no" => "Apple_123", + // "endorsement_no" => "ENDORSEMENT_ID", + // "count" => 4, + // "event_name" => "deletion", + // "policy_name" => "GMC", + // "user_id" => "1" + // ]; + + // $EmpDataServiceController->cashDepositCalculationForDeletion($array); - // $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]); + $employeeRestController = new EmployeeServiceController(); + $employeeRestController->employeesOnboardPreprocess(['file_id' => 756]); } @@ -3943,4 +3947,95 @@ class ClientController extends AdminController } } + + // ---------AUTO SI ---------------------------------------------------------------------------------------------- + + // Function to insert and update the auto si data and update the client policy table for auto si enableor disable + public function createAutoSI() + { + try { + + $postData = $this->request->getPost(); + if (empty($postData)) { + return $this->respond([ + 'status' => false, + 'code' => 400, + 'message' => 'No data provided.', + ], 400); + } + + $id = $postData['id'] ?? null; + $auto_si_enable = isset($postData['is_auto_si']) ? 1 : 0; + $affectedRows = 0; + $message = ''; + + $this->clientPolicyModel->where('id', $postData['client_policy_id'])->set('is_auto_si', $auto_si_enable)->update(); + + if ($id) { + $affectedRows = $this->AutoSIModel->where('id', $id)->set($postData)->update(); + $message = "Auto SI data updated successfully."; + } else { + $affectedRows = $this->AutoSIModel->insert($postData); + $message = "Auto SI data submitted successfully."; + } + + if ($affectedRows) { + return $this->respond([ + 'status' => true, + 'code' => 200, + 'message' => $message, + 'data' => $affectedRows, + ], 200); + } else { + return $this->respond([ + 'status' => false, + 'code' => 500, + 'message' => 'Failed to save data.', + ], 500); + } + } catch (\Exception $e) { + return $this->respond([ + 'status' => false, + 'code' => 500, + 'message' => 'An error occurred.', + 'error' => $e->getMessage(), + ], 500); + } + } + + //Function to get the data from Policy Premium 2 table data for the SI Dropdown, and Auto SI table data for edit auto_si + public function getRackRateSIAmountAndAutoSiDataForAutoSI() + { + $client_policy_id = $this->request->getGet('client_policy_id'); + + if(!empty($client_policy_id)){ + + $rack_rate_count = $this->policyPremium2Model + ->where('client_policy_id', $client_policy_id) + ->where('is_active', 1) + ->groupBy('rack_rate_name') + ->countAllResults(); + + $si_amounts = $this->policyPremium2Model + ->where('client_policy_id', $client_policy_id) + ->where('is_active', 1) + ->findAll(); + + $auto_si = $this->AutoSIModel + ->select('auto_si.*, client_policy.is_auto_si') + ->join('client_policy', 'auto_si.client_policy_id = client_policy.id') + ->where('client_policy_id', $client_policy_id) + ->where('auto_si.is_active', 1) + ->first(); + + if($rack_rate_count <= 1){ + return $this->respond(['status' => true, 'code' => 200, 'si_amount' => $si_amounts, "auto_si_amount" => $auto_si], 200); + }else{ + return $this->respond(['status' => false, 'code' => 200, 'message' => 'The policy has more than one rack rates. Auto SI create only one rack rate.', 'si_amount' => $si_amounts, "auto_si_amount" => $auto_si], 200); + } + + }else{ + return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to found. Client Policy Not found'], 200); + } + } } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 3c25437..2ab0273 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2,6 +2,8 @@ use App\Models\EmployeeModel; use App\Models\InsurerModel; +use App\Models\ClientPolicyModel; +use App\Models\AutoSIModel; use Kint\Kint; @@ -890,7 +892,7 @@ if (!function_exists('calculate_premium_new')) // dd($temp_slab_rates); /* 1. construct available/incoming family members composition & count */ $incoming_familiy_composition = get_familiy_composition($family_data); - // dd($incoming_familiy_composition); + // dd($incoming_familiy_composition); //2 .get applicable familiy members composition & count from slab details & constrcut an array //3 in for another loop compare slab level applicable familiy composition with available family composition @@ -900,7 +902,7 @@ if (!function_exists('calculate_premium_new')) // dd($slab); $res = compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition); // kint::dump($key); - // kint::dump($res); + kint::dump($res); if($res['is_applicable']) { @@ -940,7 +942,7 @@ if (!function_exists('calculate_premium_new')) $temp_slab_rates[$key]['is_applicable'] = false; } } - // dd(); + dd($family_data); //4. if macthed then the current rack rate is applicable and find common variables link max age,max count,grade, basic pay,SI, self/acting self for current rack rate @@ -983,7 +985,7 @@ if (!function_exists('calculate_premium_new')) // // Final combined condition if ($conditions['isEmployeeSourceEnrollment'] || $conditions['isEmployeeSourceExcelFile'] || $primaryGridTypeCondition ) { - // dd($transformed_familiy_member_data); + dd($transformed_familiy_member_data); $transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$temp_slab_rates,$default_si); // dd($transformed_familiy_member_data); $result[] = $transformed_familiy_member_data; @@ -2173,4 +2175,41 @@ if(!function_exists('generate_family_floater_key')) $relation = 'self'; } } +} + + +if(!function_exists('update_si_with_auto_si')) +{ + function update_si_with_auto_si($client_id, $client_policy_id, $client_branch_id, $emp_code) + { + + $clientPolicy = new ClientPolicyModel(); + $policy_data = $clientPolicy->getPolicyDetails($client_id, $client_policy_id); + + if(empty($policy_data) || $policy_data['is_auto_si']){ + return null; + }else{ + + $autoSiModel = new AutoSIModel(); + $auto_si_amounts = $autoSiModel + ->where('client_policy_id', $client_policy_id) + ->where('is_active', 1) + ->first(); + + $params = [ + 'auto_si' => $auto_si_amounts, + ]; + + $modified_si = modify_si_for_the_family($params); + return $modified_si; + } + } +} + +if(!function_exists('modify_si_for_the_family')) +{ + function modify_si_for_the_family($params) + { + + } } \ No newline at end of file diff --git a/app/Models/AutoSIModel.php b/app/Models/AutoSIModel.php new file mode 100644 index 0000000..2208ec6 --- /dev/null +++ b/app/Models/AutoSIModel.php @@ -0,0 +1,53 @@ + -
- - + +
- - +
+ @@ -31,20 +34,23 @@
- +

- + - - + +
@@ -52,7 +58,7 @@
@@ -62,13 +68,14 @@
- +
- +
Insurer Policy