From 14d92a0441990985b821a686a6056fe7164b0808 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 24 Jan 2025 10:27:27 +0530 Subject: [PATCH 1/2] CHANGE_IRDA_REPORT : RV --- app/Controllers/BDSReportController.php | 95 +++++++++++++++++++--- app/Controllers/ClientController.php | 2 +- app/Helpers/utility_helper.php | 1 + app/Views/irba_report.php | 2 + app/Views/irda_bap_client_report_list.php | 7 ++ app/Views/irda_bap_insurer_report_list.php | 10 ++- 6 files changed, 102 insertions(+), 15 deletions(-) diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 28cbd3d9..2fda3d14 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -132,6 +132,7 @@ class BDSReportController extends AdminController ]; return $this->loadLayout('irba_report', $data); } else { + $fromDate = $this->request->getPost('fromDate'); $toDate = $this->request->getPost('toDate'); $category = $this->request->getPost('category'); @@ -149,6 +150,7 @@ class BDSReportController extends AdminController $html = view('bds_report_Insurer_wise_Data', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); } else if ($report_type == 'bap') { + $life = $category == 'life' ? 1 : 0; $viewData = $this->Bap_wise_Data($life, $fromDate, $toDate); @@ -159,6 +161,32 @@ class BDSReportController extends AdminController $html = view('bds_report_bap_wise_data', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); + } else if($report_type == 'bapInsurer'){ + + //Condition for BAP Insurer wise date + $category = $category == 'life' ? 1 : 0; + $viewData['data'] = $this->getBAPInsurerData($category, $fromDate, $toDate); + + $html = view('irda_bap_insurer_report_list', $viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + + }else if($report_type == 'bapClient'){ + + //Condition for BAP Client wise date + $category = $category == 'life' ? 1 : 0; + $viewData['data'] = $this->getBAPClientData($category, $fromDate, $toDate); + + $html = view('irda_bap_client_report_list', $viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + + }else if($report_type == 'client'){ + + //Condition for Client wise date + $category = $category == 'life' ? 1 : 0; + $viewData['data'] = $this->getClientData($category, $fromDate, $toDate); + + $html = view('irda_client_report_list', $viewData); + return $this->respond(['status' => true, 'html' => $html], 200); } } } @@ -179,8 +207,8 @@ class BDSReportController extends AdminController $toDate = date('Y-m-d 23:59:59'); if (!empty($start_date) && !empty($end_date)) { - $fromDate = $start_date; - $toDate = $end_date; + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); } $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); @@ -237,7 +265,47 @@ class BDSReportController extends AdminController -- Marine Hull Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue, + + -- Grand Totals + COALESCE( + SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), + 0 + ) AS total_policy_count, + + COALESCE( + SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), + 0 + ) AS total_premium, + + COALESCE( + SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), + 0 + ) AS total_revenue from insurers ins left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 @@ -288,8 +356,8 @@ class BDSReportController extends AdminController $toDate = date('Y-m-d 23:59:59'); if (!empty($start_date) && !empty($end_date)) { - $fromDate = $start_date; - $toDate = $end_date; + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); } $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); @@ -335,7 +403,11 @@ class BDSReportController extends AdminController -- Marine Hull Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + + -- Grand Totals + COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count, + COALESCE(SUM(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt), 0) AS total_premium FROM clients c LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' @@ -386,8 +458,8 @@ class BDSReportController extends AdminController $toDate = date('Y-m-d 23:59:59'); if (!empty($start_date) && !empty($end_date)) { - $fromDate = $start_date; - $toDate = $end_date; + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); } $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); @@ -424,12 +496,9 @@ class BDSReportController extends AdminController ), 0) as premium from clients c - join policy_transaction on c.id = policy_transaction.client_id - join policy_type on policy_transaction.policy_type_id = policy_type.id + join policy_transaction on c.id = policy_transaction.client_id AND policy_transaction.policy_issue_date >= '$fromDate' AND policy_transaction.policy_issue_date <= '$toDate' + join policy_type on policy_transaction.policy_type_id = policy_type.id and policy_type.policy_category = $category where c.is_active = 1 - and policy_type.policy_category = $category - AND policy_transaction.policy_issue_date >= '$fromDate' - AND policy_transaction.policy_issue_date <= '$toDate' group by client_name order by premium desc "); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d6d1626a..33db229d 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4055,7 +4055,7 @@ class ClientController extends AdminController // $data['data'] = $BDSReportController->getBAPClientData(); // return $this->loadLayout('irda_bap_client_report_list', $data); - // $data['data'] = $BDSReportController->getClientData(); + // $data['data'] = $BDSReportController->getClientData(1); // return $this->loadLayout('irda_client_report_list', $data); // $BDSReportController->getBAPClientData(); diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index f5313bde..ca22481a 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -546,6 +546,7 @@ if (!function_exists('change_date_format')) { 'Y,m,d', // 2024,12,01 'd/m/Y', // 01/01/2025 + 'd-m-Y', // 01-01-2025 ]; diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index 88f51ebb..97702fa4 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -93,7 +93,9 @@