CHANGE_IRDA_REPORT_INS_CLT : RV

This commit is contained in:
VENKATESHWARAN 2025-01-24 08:33:39 +05:30
parent f99dd816d6
commit 09b3963653
10 changed files with 964 additions and 27 deletions

View File

@ -46,5 +46,287 @@ class BDSReportController extends BaseController
//
}
// -----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------
//Function for get BAP INSURE wise data for premium , policy count , revenue only
public function getBAPInsurerData($category = 0, $start_date = null, $end_date = null)
{
try {
$this->myLogger->logme('error', 'getBAPInsurerData function called');
$this->myLogger->logme('error', 'category : {data}', ['data' => $category]);
$this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]);
//set default last 3 months data date
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
$db = db_connect();
$builder = $db->query("
select ins.id, ins.name as insurer_name,
-- Health Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_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), 0) AS health_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), 0) AS health_revenue,
-- Misc Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium,
COALESCE(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 misc_revenue,
-- Motor Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium,
COALESCE(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), 0) AS motor_revenue,
-- Engineering Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium,
COALESCE(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), 0) AS engineering_revenue,
-- Fire Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium,
COALESCE(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), 0) AS fire_revenue,
-- Liability Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium,
COALESCE(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), 0) AS liability_revenue,
-- Life Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium,
COALESCE(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), 0) AS life_revenue,
-- Marine Cargo Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium,
COALESCE(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), 0) AS marine_cargoe_revenue,
-- 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
from insurers ins
left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1
left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1
left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate'
left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $category
where ins.is_active = 1
group by ins.id
ORDER BY
health_premium DESC,
misc_premium DESC,
motor_premium DESC,
engineering_premium DESC,
fire_premium DESC,
liability_premium DESC,
life_premium DESC,
marine_cargo_premium DESC,
marine_hull_premium DESC;
");
// Get the query
$result = $builder->getResultArray();
$this->myLogger->logme('error', 'Query executed successfully.');
// dd(db_connect()->getLastQuery(),$result);
return $result;
} catch (\Exception $e) {
// Log the exception details for debugging
$this->myLogger->logme('error', 'Error occurred in getBAPInsurerData: {message}', ['message' => $e->getMessage()]);
$this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]);
return [];
}
}
//Function for get BAP CLIENT wise data for premium , policy count , revenue only
public function getBAPClientData($category = 0, $start_date = null, $end_date = null)
{
try {
$this->myLogger->logme('error', 'getBAPClientData function called');
$this->myLogger->logme('error', 'category : {data}', ['data' => $category]);
$this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]);
//set default last 3 months data date
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
$db = db_connect();
$builder = $db->query("
SELECT
c.id AS client_id,
c.client_name,
-- Health Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_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), 0) AS health_premium,
-- Misc Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium,
-- Motor Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium,
-- Engineering Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium,
-- Fire Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium,
-- Liability Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium,
-- Life Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium,
-- Marine Cargo Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium,
-- 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
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'
LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id
LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1
LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1
WHERE c.is_active = 1
AND ptp.policy_category = $category
GROUP BY c.id
ORDER BY
health_premium DESC,
misc_premium DESC,
motor_premium DESC,
engineering_premium DESC,
fire_premium DESC,
liability_premium DESC,
life_premium DESC,
marine_cargo_premium DESC,
marine_hull_premium DESC
");
// Get the query
$result = $builder->getResultArray();
// dd(db_connect()->getLastQuery(),$result);
return $result;
} catch (\Exception $e) {
// Log the exception details for debugging
$this->myLogger->logme('error', 'Error occurred in getBAPClientData: {message}', ['message' => $e->getMessage()]);
$this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]);
return [];
}
}
//Function for get CLIENT wise data for premium and policy count only
public function getClientData($category = 0, $start_date = null, $end_date = null)
{
try {
$this->myLogger->logme('error', 'getClientData function called');
$this->myLogger->logme('error', 'category : {data}', ['data' => $category]);
$this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]);
//set default last 3 months data date
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
$db = db_connect();
$builder = $db->query("
select
c.id as client_id,
c.client_name,
(
select
count(policy_transaction.id)
from policy_transaction
left join policy_type on policy_transaction.policy_type_id = policy_type.id
where policy_transaction.client_id = c.id
and policy_transaction.action_type = 'inception'
and policy_transaction.is_active = 1
) as policy_count,
COALESCE((
select
sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium
from co_share_stmt_details stmt
left join pt_co_share_details ptco on stmt.co_share_id = ptco.id
left join policy_transaction pt on ptco.pt_id = pt.id
where pt.client_id = c.id
and stmt.is_active = 1
and ptco.is_active = 1
and pt.is_active = 1
), 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
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
");
// Get the query
$result = $builder->getResultArray();
// dd(db_connect()->getLastQuery(),$result);
return $result;
} catch (\Exception $e) {
// Log the exception details for debugging
$this->myLogger->logme('error', 'Error occurred in getClientData: {message}', ['message' => $e->getMessage()]);
$this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]);
return [];
}
}
}

View File

@ -4045,6 +4045,20 @@ class ClientController extends AdminController
// $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
// dd($returndata);
// -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
$BDSReportController = new BDSReportController();
$data['data'] = $BDSReportController->getBAPInsurerData();
return $this->loadLayout('irda_bap_insurer_report_list', $data);
// $data['data'] = $BDSReportController->getBAPClientData();
// return $this->loadLayout('irda_bap_client_report_list', $data);
// $data['data'] = $BDSReportController->getClientData();
// return $this->loadLayout('irda_client_report_list', $data);
// $BDSReportController->getBAPClientData();
}
// -------------------------------------------------------------------------------------------------------

View File

@ -1103,20 +1103,30 @@ class PolicyTransactionController extends BaseController
}
if(!empty($data['data_received_date'])){
if(empty($data['data_received_date'])){
$data['data_received_date'] = null;
}else{
$data['data_received_date'] = change_date_format($data['data_received_date'], 'd/m/Y', 'Y-m-d');
}
if(!empty($data['policy_issue_date'])){
if(empty($data['policy_issue_date'])){
$data['policy_issue_date'] = null;
}else{
$data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'd/m/Y', 'Y-m-d');
}
if(!empty($data['endorse_eff_date'])){
if(empty($data['endorse_eff_date'])){
$data['endorse_eff_date'] = null;
}else{
$data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d');
}
if(!empty($data['install_due_date'])){
if(empty($data['install_due_date'])){
$data['install_due_date'] = null;
}else{
$data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d');
}
if(!empty($data['month'])){
@ -1162,7 +1172,8 @@ class PolicyTransactionController extends BaseController
'policy_type_id' => $issue_type['policy_type_id'] ?? null,
'issue_type' => $issue_type['issue_type'] ?? null,
'source_client_policy_id' => $issue_type['source_client_policy_id'] ?? null,
'cd_ac_no' => $issue_type['issue_type'] ?? null,
'cd_ac_no' => $issue_type['cd_ac_no'] ?? null,
'cd_ac_pk' => $issue_type['cd_ac_pk'] ?? null,
// 'policy_issue_date' => $issue_type['policy_issue_date'] ?? null,
'policy_start_date' => $issue_type['policy_start_date'] ?? null,
'policy_end_date' => $issue_type['policy_end_date'] ?? null,

View File

@ -22,6 +22,6 @@ class PolicyTypeModel extends Model
"etp",
"iep",
"itp",
"question_json",'itep','etep'
"question_json",'itep','etep', 'policy_category',
];
}

View File

@ -0,0 +1,226 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BAP Client Report </h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th></th>
<th></th>
<th colspan="2" style="text-align: center;">Engineering</th>
<th colspan="2" style="text-align: center;">Fire</th>
<th colspan="2" style="text-align: center;">Health</th>
<th colspan="2" style="text-align: center;">Liability</th>
<th colspan="2" style="text-align: center;">Life</th>
<th colspan="2" style="text-align: center;">Marine Cargo</th>
<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>
</tr>
<tr>
<th>S. No</th>
<th>Insured</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
<?php foreach($data as $index => $row){ ?>
<tr>
<td class="right-align-input"><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td class="right-align-input"><?php echo $row['engineering_policy_count']; ?> </td>
<td class="right-align-input"><?php echo $row['engineering_premium']; ?></td>
<td class="right-align-input"><?php echo $row['fire_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['fire_premium']; ?></td>
<td class="right-align-input"><?php echo $row['health_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['health_premium']; ?></td>
<td class="right-align-input"><?php echo $row['liability_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['liability_premium']; ?></td>
<td class="right-align-input"><?php echo $row['life_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['life_premium']; ?></td>
<td class="right-align-input"><?php echo $row['marine_cargo_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['marine_cargo_premium']; ?></td>
<td class="right-align-input"><?php echo $row['marine_hull_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['marine_hull_premium']; ?></td>
<td class="right-align-input"><?php echo $row['misc_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['misc_premium']; ?></td>
<td class="right-align-input"><?php echo $row['motor_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['motor_premium']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'IRDA-BAP-CLIENT-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'IRDA-BAP-CLIENT-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this)
.text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) +
2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex +
'"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) +
'</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
orthogonal: 'sort'
},
customizeData: function(data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// Check if the column is the 9th index (10th column)
if (j === 9) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
}
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
</script>

View File

@ -0,0 +1,234 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BAP Insurer Report </h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th></th>
<th></th>
<th colspan="3" style="text-align: center;">Engineering</th>
<th colspan="3" style="text-align: center;">Fire</th>
<th colspan="3" style="text-align: center;">Health</th>
<th colspan="3" style="text-align: center;">Liability</th>
<th colspan="3" style="text-align: center;">Life</th>
<th colspan="3" style="text-align: center;">Marine Cargo</th>
<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>
</tr>
<tr>
<th>S. No</th>
<th>Insurer</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
<?php foreach($data as $index => $row){ ?>
<tr>
<td class="right-align-input"><?= $index + 1 ?></td>
<td><?php echo $row['insurer_name']; ?></td>
<td class="right-align-input"><?php echo $row['engineering_policy_count']; ?> </td>
<td class="right-align-input"><?php echo $row['engineering_premium']; ?></td>
<td class="right-align-input"><?php echo $row['engineering_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['fire_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['fire_premium']; ?></td>
<td class="right-align-input"><?php echo $row['fire_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['health_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['health_premium']; ?></td>
<td class="right-align-input"><?php echo $row['health_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['liability_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['liability_premium']; ?></td>
<td class="right-align-input"><?php echo $row['liability_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['life_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['life_premium']; ?></td>
<td class="right-align-input"><?php echo $row['life_revenue'];?></td>
<td class="right-align-input"><?php echo $row['marine_cargo_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['marine_cargo_premium']; ?></td>
<td class="right-align-input"><?php echo $row['marine_cargoe_revenue'];?></td>
<td class="right-align-input"><?php echo $row['marine_hull_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['marine_hull_premium']; ?></td>
<td class="right-align-input"><?php echo $row['marine_hull_revenue'];?></td>
<td class="right-align-input"><?php echo $row['misc_policy_count']; ?></td>
<td class="right-align-input"><?php echo $row['misc_premium']; ?></td>
<td class="right-align-input"><?php echo $row['misc_revenue']; ?></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['motor_revenue']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'IRDA-BAP-INSURER-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'IRDA-BAP-INSURER-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this)
.text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) +
2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex +
'"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) +
'</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
orthogonal: 'sort'
},
customizeData: function(data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// Check if the column is the 9th index (10th column)
if (j === 9) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
}
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
</script>

View File

@ -0,0 +1,148 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Client Report </h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Insured</th>
<th>Policies</th>
<th>Premium</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
<?php foreach($data as $index => $row){ ?>
<tr>
<td ><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td ><?php echo $row['policy_count']; ?> </td>
<td ><?php echo $row['premium']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'IRDA-BAP-CLIENT-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'IRDA-BAP-CLIENT-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this)
.text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) +
2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex +
'"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) +
'</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
orthogonal: 'sort'
},
customizeData: function(data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// Check if the column is the 9th index (10th column)
if (j === 9) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
}
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
</script>

View File

@ -1159,17 +1159,20 @@ function amountCalculation(input) {
console.log('gst_per_amt', gst_per_amt);
// $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
if(gst_amount != 0){
if (event.target.id.startsWith('non_comm_per_amt')) {
if (event.target.id.startsWith('non_comm_per_amt')) {
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}else if (event.target.id.startsWith('gst_amount')) {
$('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00');
}else{
if(ncpa != 0 && ncpa != ""){
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}else{
$('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00');
$('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
}
}else{
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
console.log('Summed Amount:', finalTotal);
@ -1186,11 +1189,15 @@ function amountCalculation(input) {
expectedAmount = agreed_amount;
// console.log('Formula 1 AGREED AMOUNT');
}else if(sum_of_agreed_premium > 0){
expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
//expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per;
expectedAmount = (tpTotal * sumOfTheAggreedPer);
expectedAmount = expectedAmount / 100;
// console.log('Formula 2 AGREED BP TP/TEP %');
}else{
expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
// expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per;
expectedAmount = (tpTotal * sumOfTheStandardPer);
console.log(expectedAmount)
expectedAmount = expectedAmount / 100;
// console.log('Formula 3 STANDARD BP TP/TEP %');

View File

@ -548,10 +548,10 @@ document.addEventListener("DOMContentLoaded", function () {
});
// var closure_date = flatpickr("#policy_issue_date", {
// dateFormat: "d/m/Y",
// allowInput: false
// });
var closure_date = flatpickr("#policy_issue_date", {
dateFormat: "d/m/Y",
allowInput: false
});
var install_due_date = flatpickr("#install_due_date", {
dateFormat: "d/m/Y",

View File

@ -1842,17 +1842,20 @@ function amountCalculation(input) {
console.log('gst_per_amt', gst_per_amt);
// $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
if(gst_amount != 0){
if (event.target.id.startsWith('non_comm_per_amt')) {
if (event.target.id.startsWith('non_comm_per_amt')) {
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}else if (event.target.id.startsWith('gst_amount')) {
$('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00');
}else{
if(ncpa != 0 && ncpa != ""){
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}else{
$('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00');
$('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
}
}else{
$('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
}
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
console.log('Summed Amount:', finalTotal);
@ -1869,11 +1872,15 @@ function amountCalculation(input) {
expectedAmount = agreed_amount;
// console.log('Formula 1 AGREED AMOUNT');
}else if(sum_of_agreed_premium > 0){
expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
//expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per;
expectedAmount = (tpTotal * sumOfTheAggreedPer);
expectedAmount = expectedAmount / 100;
// console.log('Formula 2 AGREED BP TP/TEP %');
}else{
expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
// expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per;
expectedAmount = (tpTotal * sumOfTheStandardPer);
console.log(expectedAmount)
expectedAmount = expectedAmount / 100;
// console.log('Formula 3 STANDARD BP TP/TEP %');
@ -3890,9 +3897,11 @@ function populateTable(dataArray, cd_ac_pk) {
case 2: // CD Account Number
cell.find('select').val(cd_ac_pk);
var selectElement = cell.find('select');
console.log('selectElement', selectElement);
selectElement.val(cd_ac_pk).prop('selected', true);
selectElement.toggleClass('readonly-select', !!disable_td)
setTimeout(function(){
console.log('selectElement', selectElement);
selectElement.find('option[value="' + cd_ac_pk + '"]').prop('selected', true);
selectElement.toggleClass('readonly-select', !!disable_td)
}, 2000)
@ -4240,8 +4249,14 @@ function getCdAmount(cd_ac_pk, increment){
console.log('Data fetched successfully:', response);
if (response.status == true) {
$('#cd_current_balance_'+increment).val(response.data.balance);
}
if(!response.data.balance){
$('#cd_current_balance_'+increment).val(0.00);
}else{
$('#cd_current_balance_'+increment).val(response.data.balance);
}
} else{
$('#cd_current_balance_'+increment).val(0.00);
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);