CHANGE_IRDA_REPORT : RV

This commit is contained in:
VENKATESHWARAN 2025-01-24 10:27:27 +05:30
parent a62901e433
commit 14d92a0441
6 changed files with 102 additions and 15 deletions

View File

@ -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
");

View File

@ -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();

View File

@ -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
];

View File

@ -93,7 +93,9 @@
</script>
<script>
$('#category').on('click', function(){
var choosed_option = $('#category').val();
$("#report_type").val('0');
if (choosed_option == 'life' ){
$("#report_type option[value='insurer']").show();
$("#report_type option[value='bap']").hide();

View File

@ -47,6 +47,7 @@ table.dataTable tbody td {
<th colspan="2" style="text-align: center;">Misc</th>
<th colspan="2" style="text-align: center;">Motor</th>
<th colspan="2" style="text-align: center;">Marine Hull</th>
<th colspan="2" style="text-align: center;">Grand Total</th>
</tr>
<tr>
@ -87,6 +88,9 @@ table.dataTable tbody td {
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
@ -128,6 +132,9 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['motor_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['motor_premium']; ?></td>
<td class="right-align-input"><?php echo $row['total_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
</tr>
<?php } ?>

View File

@ -46,6 +46,7 @@ table.dataTable tbody td {
<th colspan="3" style="text-align: center;">Misc</th>
<th colspan="3" style="text-align: center;">Motor</th>
<th colspan="3" style="text-align: center;">Marine Hull</th>
<th colspan="3" style="text-align: center;">Grand Total</th>
</tr>
<tr>
@ -87,8 +88,11 @@ table.dataTable tbody td {
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
@ -136,6 +140,10 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['motor_premium']; ?></td>
<td class="right-align-input"><?php echo $row['motor_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['total_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['total_revenue']; ?></td>
</tr>
<?php } ?>