diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 64a7242e..6f47b036 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -430,7 +430,8 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("logined", "RestAuthenticationController::logined"); $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); -// $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); +$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); +$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index ec4f7478..409d6b5a 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1085,7 +1085,7 @@ class EmployeeRestController extends AdminController $keysToRemove = ["removable_keys"]; // Retrieve employee policy data by passing the employee primary key $empPolicy = $this->employeeModel->getEmployeePolicy($id); - +// dd($empPolicy); // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$emp_code) ->where('client_id',$client_id) @@ -1123,11 +1123,18 @@ class EmployeeRestController extends AdminController { $si_value = 0; + $si_premium_value = 0; + $si_gst_value = 0; // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $si_value = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + $si_premium_value = $si_premium_value + $employee_policy->rata_premimum; + $si_gst_value = $si_gst_value + $employee_policy->gst; + } $self['is_value_exist'] = true; $self['data']['family_floater_key'] = 'self'; @@ -1142,6 +1149,8 @@ class EmployeeRestController extends AdminController $array->mapped_family_floaters = $self; $array->type = 'GPA'; $array->si_value = $si_value; + $array->si_premium_value = $si_premium_value; + $array->si_gst_value = $si_gst_value; @@ -1201,8 +1210,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1404,8 +1416,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1504,16 +1519,25 @@ class EmployeeRestController extends AdminController $decodedArray = json_decode($array->Policy_Terms); $array->Policy_Terms = $decodedArray; $si_value = 0; + $si_premium_value = 0; + $si_gst_value = 0; // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $si_value = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + $si_premium_value = $si_premium_value + $employee_policy->rata_premimum; + $si_gst_value = $si_gst_value + $employee_policy->gst; + } $policyTypeData = $this->policyTypeModel->where('id',$policy_type)->get()->getRow(); $array->type = $policyTypeData->policy_type; $array->Policy_Name = $policyTypeData->long_name; $array->si_value = $si_value; + $array->si_premium_value = $si_premium_value; + $array->si_gst_value = $si_gst_value; if($employee_policy){ @@ -1808,8 +1832,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1929,8 +1956,11 @@ class EmployeeRestController extends AdminController $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; } - if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + } $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id']; $temp3['data']['relationship'] = $value['relationship']; @@ -1982,8 +2012,11 @@ class EmployeeRestController extends AdminController $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; } - if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + } $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id']; $temp3['data']['relationship'] = $value['relationship']; diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 40a44bd1..4892253e 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1480,7 +1480,7 @@ class PolicyTransactionController extends BaseController //Actual data for the list $data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); - // dd($data['report_list']); + //!dd($data['report_list']); $this->loadLayout('report_bds_filter', $data); } @@ -1529,6 +1529,7 @@ class PolicyTransactionController extends BaseController $data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); + // !dd($data['varience_list']); $this->loadLayout('variance_report_list', $data); } @@ -1811,6 +1812,12 @@ class PolicyTransactionController extends BaseController return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file not uploaded', 'error_data' => $validation_result['error_data'],'error_code' => $validation_result['error_code']], 200); } + if (isset($file_id) || $validation_result['status']) { + $this->insurerStatements->where('id', $file_id)->set(['invoice_status' => 'pending'])->update(); + } + + + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200); } diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 0364fd17..edd39439 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -363,7 +363,6 @@ class PolicyTransactionModel extends Model vehicle.vehicle_no, tpa.name as tpa_name, pt_co_share_details.remark as remarks, - pt_co_share_details.reward, pt_co_share_details.bp_amt, pt_co_share_details.exp_amt, pt_co_share_details.id as pt_id, @@ -383,7 +382,6 @@ class PolicyTransactionModel extends Model (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per, pt_co_share_details.agreed_bp_per, - ROUND( ( SELECT @@ -405,6 +403,24 @@ class PolicyTransactionModel extends Model ), 2 ) AS total_irda_amt, + ROUND( + ( + SELECT + ( + SUM(co_share_stmt_details.reward) + + ) AS reward + FROM + co_share_stmt_details + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + AND insurer_statements.is_active = 1 + $date_condition + ), + 2 + ) AS reward, ROUND( ( @@ -424,7 +440,7 @@ class PolicyTransactionModel extends Model AND co_share_stmt_details.is_active = 1 AND pt_table.is_active = 1 AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_no IS NOT NULL + AND insurer_statements.invoice_status IS NOT NULL $date_condition ), @@ -467,7 +483,7 @@ class PolicyTransactionModel extends Model AND co_share_stmt_details.is_active = 1 AND pt_table.is_active = 1 AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_no IS NULL + AND insurer_statements.invoice_status IS NULL $date_condition ) ), @@ -735,16 +751,55 @@ class PolicyTransactionModel extends Model pt_co_share_details.exp_amt, pt_co_share_details.variance, + ROUND ( (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt),2) as original_premium, + ROUND( + ( + SELECT + ( + SUM(co_share_stmt_details.actual_bp_amt) + SUM(co_share_stmt_details.actual_tp_amt) + SUM(co_share_stmt_details.actual_bp_per) + ) AS total_stmt_amt + FROM + co_share_stmt_details + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + ), + 2 + ) AS statement_premium, + + COALESCE( + (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 0 + ) - + COALESCE( + ( + SELECT + SUM(co_share_stmt_details.actual_bp_amt) + + SUM(co_share_stmt_details.actual_tp_amt) + + SUM(co_share_stmt_details.actual_bp_per) + FROM + co_share_stmt_details + JOIN + insurer_statements + ON + co_share_stmt_details.statement_id = insurer_statements.id + AND insurer_statements.is_active = 1 + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + ), 0 + ) AS premium_variance_amt, + ROUND( ( SELECT ( - SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.reward) ) AS total_irda_amt FROM co_share_stmt_details - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id AND co_share_stmt_details.is_active = 1 @@ -759,11 +814,11 @@ class PolicyTransactionModel extends Model ( SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + - SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.reward) ) FROM co_share_stmt_details JOIN insurer_statements - ON co_share_stmt_details.statement_id = insurer_statements.id + ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id AND co_share_stmt_details.is_active = 1 @@ -783,7 +838,18 @@ class PolicyTransactionModel extends Model ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') ->where('policy_transaction.is_active', 1) ->where('pt_co_share_details.is_active', 1) - ->having('variance_amt IS NOT NULL'); + // ->where('insurer_statements.is_active',1); + // ->having('variance_amt IS NOT NULL') + // ->having('variance_amt !=',0) + // ->having('premium_variance_amt IS NOT NULL') + // ->having('premium_variance_amt !=',0); + + // ->group_start() + ->having('variance_amt IS NOT NULL') + ->orHaving('variance_amt !=', 0) + ->having('premium_variance_amt IS NOT NULL') + ->orHaving('premium_variance_amt !=', 0); + // ->group_end(); // ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0'); // ->where('pt_co_share_details.variance IS NOT NULL') // ->where('pt_co_share_details.variance !=', 0); diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index b42fc37a..ff994fad 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -381,7 +381,7 @@ table.dataTable tbody td {