Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
16e19b4e30
@ -1233,6 +1233,8 @@ class LeadsController extends BaseController
|
||||
'Total Lives' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
];
|
||||
} else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
@ -1241,6 +1243,8 @@ class LeadsController extends BaseController
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
];
|
||||
}
|
||||
@ -1264,6 +1268,8 @@ class LeadsController extends BaseController
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||
@ -1279,6 +1285,8 @@ class LeadsController extends BaseController
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'TPA ' => $rfq_data['tpa_name'],
|
||||
@ -1376,7 +1384,7 @@ class LeadsController extends BaseController
|
||||
|
||||
// // Set column width based on max content length (adjusted for padding)
|
||||
$sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2);
|
||||
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 5);
|
||||
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.5);
|
||||
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.6);
|
||||
|
||||
// $rowNumber += 2;
|
||||
@ -1445,7 +1453,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
if ($header['parentHeader'] === 'Particulars') {
|
||||
$sheet->getColumnDimension('B')->setWidth(80);
|
||||
$sheet->getColumnDimension('B')->setWidth(50);
|
||||
}
|
||||
|
||||
$startColumn = $columnLetter; // Start of the current header range
|
||||
@ -1454,7 +1462,11 @@ class LeadsController extends BaseController
|
||||
if ($is_placement == true && !in_array($header['parentHeader'], ['Particulars', 'S.No.'])) {
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Terms");
|
||||
} else {
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", $header['parentHeader']);
|
||||
if(in_array($header['parentHeader'], ["Existing Renewal", "Existing Rollover"])){
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Terms");
|
||||
}else{
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", $header['parentHeader']);
|
||||
}
|
||||
}
|
||||
$sheet->getStyle("{$startColumn}{$rowNumber}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
@ -1576,10 +1588,17 @@ class LeadsController extends BaseController
|
||||
foreach ($premiumData as $proposal => $insurers) {
|
||||
if ($proposal != 'Particulars') {
|
||||
foreach ($insurers as $insurer => $values) {
|
||||
$premium[] = $values[$labelArray[0]];
|
||||
$gst[] = $values[$labelArray[1]];
|
||||
$gstAmt[] = $values[$labelArray[2]];
|
||||
$total[] = $values[$labelArray[3]];
|
||||
if($insurer == 'Quote Asked'){
|
||||
$premium[] = "";
|
||||
$gst[] = "";
|
||||
$gstAmt[] = "";
|
||||
$total[] = "";
|
||||
}else{
|
||||
$premium[] = formatIndianCurrency($values[$labelArray[0]]);
|
||||
$gst[] = $values[$labelArray[1]];
|
||||
$gstAmt[] = formatIndianCurrency($values[$labelArray[2]]);
|
||||
$total[] = formatIndianCurrency($values[$labelArray[3]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3744,6 +3763,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
$sheet->getColumnDimension($columnLetter)->setWidth(60);
|
||||
$sheet->getColumnDimension('C')->setWidth(35);
|
||||
|
||||
|
||||
if ($header['parentHeader'] == 'Policy') {
|
||||
|
||||
@ -36,6 +36,53 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.info-icon-wrapper {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
top: 30px;
|
||||
left: 35px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.info-tooltip {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
width: max-content;
|
||||
max-width: 300px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
bottom: 125%; /* Show above icon */
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 12px;
|
||||
white-space: normal;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.info-tooltip::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%; /* Arrow below tooltip */
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: #333 transparent transparent transparent;
|
||||
}
|
||||
|
||||
.info-icon-wrapper:hover .info-tooltip {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row" id="leads_form">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
@ -393,12 +440,18 @@
|
||||
}
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_id").hide();
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_start_date").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_start_date").hide();
|
||||
$('#source_policy_start_date').closest('.form-group').hide();
|
||||
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
$("#source_policy_end_date").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_end_date").hide();
|
||||
$('#source_policy_end_date').closest('.form-group').hide();
|
||||
|
||||
|
||||
|
||||
@ -407,25 +460,27 @@
|
||||
$("#source_policy_start_date").prop("required", true);
|
||||
$("#source_policy_end_date").prop("required", true);
|
||||
|
||||
$("#source_policy_id").show();
|
||||
$("#source_policy_start_date").show();
|
||||
$("#source_policy_start_date").show();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').find('label').show();
|
||||
$('#source_policy_start_date').closest('.form-group').find('label').show();
|
||||
$('#source_policy_end_date').closest('.form-group').find('label').show();
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
let $label = $("#source_policy_id").closest("div") .find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label2 = $("#source_policy_start_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
let $label2 = $("#source_policy_start_date").closest("div") .find("label");
|
||||
|
||||
if ($label2.find(".text-danger").length === 0) {
|
||||
$label2.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label3 = $("#source_policy_end_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
let $label3 = $("#source_policy_end_date").closest("div").find("label");
|
||||
|
||||
if ($label3.find(".text-danger").length === 0) {
|
||||
$label3.append(' <span class="text-danger">*</span>');
|
||||
@ -439,6 +494,17 @@
|
||||
|
||||
}
|
||||
|
||||
if(lead_type != 1){
|
||||
dataIncrement = 1;
|
||||
// updateRenewalFields(dataIncrement);
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
});
|
||||
}
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
@ -448,6 +514,12 @@
|
||||
document.getElementById('source_policy_end_date').readOnly = true;
|
||||
|
||||
$('#source_policy_start_date, #source_policy_end_date').addClass('readonly-select');
|
||||
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#source_policy_id').val("");
|
||||
|
||||
console.log('---- completed ----')
|
||||
});
|
||||
|
||||
console.log('increment count for insurer and tpa ', increment);
|
||||
@ -470,6 +542,11 @@
|
||||
$('#tpa_' + increment).select2();
|
||||
$('#proposed_insurer').select2();
|
||||
$('#proposed_tpa').select2();
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#source_policy_id').val("");
|
||||
|
||||
console.log('---- completed ----')
|
||||
|
||||
|
||||
})
|
||||
@ -556,9 +633,9 @@
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if (policyStartDate.val()) {
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
@ -924,9 +1001,9 @@
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if (policyStartDate.val()) {
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
@ -1022,7 +1099,7 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" onchange="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -1161,115 +1238,210 @@
|
||||
//------------------------ CALCULATION ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function calculatePolicyRunDays(increment) {
|
||||
// function calculatePolicyRunDays(increment) {
|
||||
|
||||
// // console.log('calculatePolicyRunDays function called');
|
||||
// // console.log('increment', increment);
|
||||
// // let lead_type = $('#lead_type').val();
|
||||
// // var policyStartDate = $("#source_policy_start_date");
|
||||
// // if(lead_type == 3){
|
||||
// // policyStartDate = $("#policy_start_date");
|
||||
// // }
|
||||
// // var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
|
||||
// // var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
// // console.log('policyStartDate', policyStartDate)
|
||||
// // console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
// // if (policyStartDate && incurredClaimDate) {
|
||||
// // var timeDiff = Math.abs(policyStartDate - incurredClaimDate); // Time difference in milliseconds
|
||||
// // console.log('timeDiff', timeDiff);
|
||||
// // var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1); // Convert to days and add 1
|
||||
// // console.log('daysDiff', daysDiff);
|
||||
// // $("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
// // }
|
||||
// }
|
||||
|
||||
// function incurredClaimSum(input) {
|
||||
|
||||
// // let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
// // console.log('increment', increment);
|
||||
|
||||
// // // Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
// // let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
// // console.log('paid_claims', paid_claims);
|
||||
|
||||
// // let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
// // console.log('outstanding_claims', outstanding_claims);
|
||||
|
||||
// // // Calculate the incurred claim
|
||||
// // let incurred_claims = paid_claims + outstanding_claims;
|
||||
// // console.log('incurred_claims', incurred_claims);
|
||||
|
||||
// // // Set the calculated value
|
||||
// // $('#incurred_claims_' + increment).val(incurred_claims);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
// // console.log('policy_run_days', policy_run_days);
|
||||
// // console.log('incurred claims ' + incurred_claims);
|
||||
// // // Prevent division by zero in annualised claims calculation
|
||||
// // let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
// // let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
// // console.log('annualised_claims', annualised_claims_roundoff);
|
||||
|
||||
// // $('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // // Prevent division by zero in incurred claim ratio calculation
|
||||
// // let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
// // let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
||||
// // ? (annualised_claims / premium_as_on_date)
|
||||
// // : 0;
|
||||
|
||||
// // let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio)
|
||||
// // ? Math.round(incurred_claim_ratio)
|
||||
// // : 0;
|
||||
|
||||
// // console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
|
||||
// // $('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // let earnedPremium = parseFloat($('#earned_premium_' + increment).val()) || 0;
|
||||
// // console.log('earnedPremium:', earnedPremium);
|
||||
|
||||
// // // Prevent division by zero
|
||||
// // let earnedClaimsRatio = earnedPremium > 0 ? annualised_claims / earnedPremium : 0;
|
||||
|
||||
// // // Round to nearest integer
|
||||
// // let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
||||
// // console.log('earnedClaimsRatio:', earnedClaimsRatio);
|
||||
|
||||
// // // Set the value to the corresponding input
|
||||
// // $('#earned_claims_ratio_' + increment).val(earnedClaimsRatioRounded);
|
||||
|
||||
// }
|
||||
|
||||
// function earnedPremiumCalc(input) {
|
||||
|
||||
// // let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
// // console.log('increment', increment);
|
||||
|
||||
// // let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
|
||||
// // // Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
// // let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
// // console.log('premium_at_inception', premium_at_inception);
|
||||
|
||||
// // let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
// // console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// // // Prevent division by zero and calculate earned premium
|
||||
// // let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
// // console.log('earned_premium', earned_premium);
|
||||
// // let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// // // Set the calculated value with two decimal places
|
||||
// // $('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
// }
|
||||
|
||||
function calculatePolicyMetrics(input) {
|
||||
|
||||
console.log('calculatePolicyRunDays function called');
|
||||
console.log('increment', increment);
|
||||
let lead_type = $('#lead_type').val();
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
if(lead_type == 3){
|
||||
policyStartDate = $("#policy_start_date");
|
||||
}
|
||||
var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
console.log('Lead Type:', lead_type);
|
||||
|
||||
console.log('policyStartDate', policyStartDate)
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
let increment = input.id.split('_').pop(); // Extract increment
|
||||
if(lead_type != 1){
|
||||
increment = "1";
|
||||
}
|
||||
|
||||
console.log('--- calculatePolicyMetrics called ---');
|
||||
console.log('Input ID:', input.id);
|
||||
console.log('Increment:', increment);
|
||||
|
||||
let sourcePolicyDateVal = $('#source_policy_start_date').val()?.trim();
|
||||
let policyStartDateVal = $('#policy_start_date').val()?.trim();
|
||||
let policyStartDateInput = null;
|
||||
|
||||
if (sourcePolicyDateVal) {
|
||||
policyStartDateInput = $('#source_policy_start_date');
|
||||
console.log('Using Source Policy Start Date:', sourcePolicyDateVal);
|
||||
} else if (policyStartDateVal) {
|
||||
policyStartDateInput = $('#policy_start_date');
|
||||
console.log('Using Policy Start Date:', policyStartDateVal);
|
||||
} else {
|
||||
toastr.warning('Policy start date or Date of Commencement is empty. Please fill in the date field.', "WARNING.. !");
|
||||
console.warn('Both policy start dates are missing or invalid');
|
||||
$(input).val('');
|
||||
return; // stop further execution
|
||||
}
|
||||
|
||||
// let policyStartDateInput = (lead_type == 3) ? $('#policy_start_date') : $('#source_policy_start_date');
|
||||
console.log('Policy Start Date Input:', policyStartDateInput.val());
|
||||
|
||||
let policyStartDate = flatpickr.parseDate(policyStartDateInput.val(), "d/m/Y");
|
||||
let incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
console.log('Parsed Policy Start Date:', policyStartDate);
|
||||
console.log('Parsed Incurred Claim Date:', incurredClaimDate);
|
||||
|
||||
if (policyStartDate && incurredClaimDate) {
|
||||
var timeDiff = Math.abs(policyStartDate - incurredClaimDate); // Time difference in milliseconds
|
||||
console.log('timeDiff', timeDiff);
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1); // Convert to days and add 1
|
||||
console.log('daysDiff', daysDiff);
|
||||
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
let timeDiff = Math.abs(incurredClaimDate - policyStartDate);
|
||||
console.log('Time Difference (ms):', timeDiff);
|
||||
|
||||
let daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1);
|
||||
console.log('Policy Run Days:', daysDiff);
|
||||
|
||||
$('#policy_run_days_' + increment).val(daysDiff);
|
||||
}
|
||||
}
|
||||
|
||||
function incurredClaimSum(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
console.log('paid_claims', paid_claims);
|
||||
|
||||
let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
console.log('outstanding_claims', outstanding_claims);
|
||||
console.log('Paid Claims:', paid_claims);
|
||||
console.log('Outstanding Claims:', outstanding_claims);
|
||||
|
||||
// Calculate the incurred claim
|
||||
let incurred_claims = paid_claims + outstanding_claims;
|
||||
console.log('incurred_claims', incurred_claims);
|
||||
|
||||
// Set the calculated value
|
||||
console.log('Incurred Claims:', incurred_claims);
|
||||
$('#incurred_claims_' + increment).val(incurred_claims);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
console.log('incurred claims ' + incurred_claims);
|
||||
// Prevent division by zero in annualised claims calculation
|
||||
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('annualised_claims', annualised_claims_roundoff);
|
||||
console.log('Policy Run Days (Final):', policy_run_days);
|
||||
|
||||
let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0;
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('Annualised Claims:', annualised_claims);
|
||||
console.log('Annualised Claims (Rounded):', annualised_claims_roundoff);
|
||||
$('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
// Prevent division by zero in incurred claim ratio calculation
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
console.log('Premium as on Date:', premium_as_on_date);
|
||||
|
||||
let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
||||
? (annualised_claims / premium_as_on_date)
|
||||
: 0;
|
||||
|
||||
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio)
|
||||
? Math.round(incurred_claim_ratio)
|
||||
: 0;
|
||||
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
|
||||
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? Math.round(incurred_claim_ratio) : 0;
|
||||
console.log('Incurred Claim Ratio:', incurred_claim_ratio);
|
||||
console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff);
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
console.log('Earned Premium:', earned_premium);
|
||||
console.log('Earned Premium (Rounded):', earned_premium_roundoff);
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
|
||||
let earnedPremium = parseFloat($('#earned_premium_' + increment).val()) || 0;
|
||||
console.log('earnedPremium:', earnedPremium);
|
||||
|
||||
// Prevent division by zero
|
||||
let earnedClaimsRatio = earnedPremium > 0 ? annualised_claims / earnedPremium : 0;
|
||||
|
||||
// Round to nearest integer
|
||||
let earnedClaimsRatio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
||||
let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
||||
console.log('earnedClaimsRatio:', earnedClaimsRatio);
|
||||
|
||||
// Set the value to the corresponding input
|
||||
console.log('Earned Claims Ratio:', earnedClaimsRatio);
|
||||
console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded);
|
||||
$('#earned_claims_ratio_' + increment).val(earnedClaimsRatioRounded);
|
||||
|
||||
console.log('--- End of calculatePolicyMetrics ---\n');
|
||||
}
|
||||
|
||||
function earnedPremiumCalc(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
console.log('premium_at_inception', premium_at_inception);
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// Prevent division by zero and calculate earned premium
|
||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// Set the calculated value with two decimal places
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
}
|
||||
|
||||
$(document).on("input", "#incept_emp_count, #incept_dept_count, #renewal_emp_count, #renewal_dept_count, #exp_emp_count, #exp_dept_count", function() {
|
||||
calculateTotalLives(this);
|
||||
@ -1680,6 +1852,23 @@
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
|
||||
$('#source_policy_id').show();
|
||||
$('#source_policy_start_date').show();
|
||||
$('#source_policy_end_date').show();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').show();
|
||||
$('#source_policy_start_date').closest('.form-group').show();
|
||||
$('#source_policy_end_date').closest('.form-group').show();
|
||||
|
||||
}else{
|
||||
|
||||
$('#source_policy_id').hide();
|
||||
$('#source_policy_start_date').hide();
|
||||
$('#source_policy_end_date').hide();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
$('#source_policy_start_date').closest('.form-group').hide();
|
||||
$('#source_policy_end_date').closest('.form-group').hide();
|
||||
}
|
||||
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
@ -1732,6 +1921,7 @@
|
||||
}
|
||||
|
||||
function updateRenewalFields(increment) {
|
||||
console.log('updateRenewalFields function called');
|
||||
$(".renewalCalculation input, .renewalCalculation select").each(function() {
|
||||
let oldId = $(this).attr("id");
|
||||
if (oldId) {
|
||||
|
||||
@ -588,11 +588,15 @@
|
||||
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
|
||||
|
||||
} else if (value != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
if(value == 2){
|
||||
$("#source_policy_id").closest('.form-group').show();
|
||||
}
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
@ -669,9 +673,10 @@
|
||||
|
||||
if (value == 3) {
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
|
||||
}else if(value == 2){
|
||||
$('#source_policy_id').closest('.form-group').show();
|
||||
}
|
||||
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
@ -241,10 +241,14 @@
|
||||
}));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 1000)
|
||||
|
||||
}, 2000)
|
||||
}, 3000)
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php $increment = isset($lead_edit_data) ? "_1" : ''; ?>
|
||||
|
||||
|
||||
<?php $increment = isset($lead_edit_data) ? "_1" : ''; ?>
|
||||
<hr>
|
||||
|
||||
<div class="form-row renewalCalculation">
|
||||
@ -6,71 +8,87 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claim_date">Incurred Claim Date<span class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims_date']) ? $lead_edit_data['incurred_claims_date'] : '' ?>" type="text" class="form-control incurred_claim" id="incurred_claim_date<?= $increment ?>"
|
||||
name="incurred_claim_date[]" placeholder="Enter DOE">
|
||||
name="incurred_claim_date[]" placeholder="Enter DOE" oninput="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="paid_claims">Paid Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['paid_claims']) ? $lead_edit_data['paid_claims'] : '' ?>" type="text" class="form-control" id="paid_claims<?= $increment ?>" name="paid_claims[]"
|
||||
placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
|
||||
placeholder="Enter Paid Claims" oninput="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="outstanding_claims">Outstanding Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['outstanding_claims']) ? $lead_edit_data['outstanding_claims'] : '' ?>" type="text" class="form-control" id="outstanding_claims<?= $increment ?>" name="outstanding_claims[]"
|
||||
placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
|
||||
placeholder="Enter Outstanding Claims" oninput="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claims">Incurred Claim<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims']) ? $lead_edit_data['incurred_claims'] : '' ?>" type="text" class="form-control" id="incurred_claims<?= $increment ?>" name="incurred_claims[]"
|
||||
placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
|
||||
placeholder="Enter Incurred Claim" oninput="calculatePolicyMetrics(this)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="policy_run_days">Policy Run Days<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['policy_run_days']) ? $lead_edit_data['policy_run_days'] : '' ?>" type="text" class="form-control" id="policy_run_days<?= $increment ?>" name="policy_run_days[]"
|
||||
placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this); incurredClaimSum(this)">
|
||||
placeholder="Enter Policy Run Days" oninput="calculatePolicyMetrics(this)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="premium_at_inception">Premium Paid at Inception<span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['premium_at_inception']) ? $lead_edit_data['premium_at_inception'] : '' ?>" type="text" class="form-control" id="premium_at_inception<?= $increment ?>" name="premium_at_inception[]"
|
||||
placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
|
||||
placeholder="Enter Premium Paid" oninput="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="premium_date">Premium as on Date<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['premium_date']) ? $lead_edit_data['premium_date'] : '' ?>" type="text" class="form-control" id="premium_date<?= $increment ?>" name="premium_date[]"
|
||||
placeholder="Enter Premium Date" oninput="incurredClaimSum(this); earnedPremiumCalc(this)">
|
||||
placeholder="Enter Premium Date" oninput="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="earned_premium">Earned Premium<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['earned_premium']) ? $lead_edit_data['earned_premium'] : '' ?>" type="text" class="form-control" id="earned_premium<?= $increment ?>" name="earned_premium[]"
|
||||
placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
|
||||
placeholder="Enter Earned Premium" oninput="calculatePolicyMetrics(this)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="annualised_claims">Annualised Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['annualised_claims']) ? $lead_edit_data['annualised_claims'] : '' ?>" type="text" class="form-control" id="annualised_claims<?= $increment ?>" name="annualised_claims[]"
|
||||
placeholder="Enter Annualised Claims" oninput="incurredClaimSum(this)">
|
||||
placeholder="Enter Annualised Claims" oninput="calculatePolicyMetrics(this)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claims_ratio">Incurred Claims Ratio<span
|
||||
<label for="incurred_claims_ratio">Incurred Claims Ratio(%) <span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims_ratio']) ? $lead_edit_data['incurred_claims_ratio'] : '' ?>" type="text" class="form-control" id="incurred_claims_ratio<?= $increment ?>"
|
||||
name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio">
|
||||
name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="earned_claims_ratio">Earned Claims Ratio<span class="text-danger">*</span></label>
|
||||
<label for="earned_claims_ratio">Earned Claims Ratio(%) <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['earned_claims_ratio']) ? $lead_edit_data['earned_claims_ratio'] : '' ?>" type="text" class="form-control" id="earned_claims_ratio<?= $increment ?>" name="earned_claims_ratio[]"
|
||||
placeholder="Enter Earned Claims Ratio">
|
||||
placeholder="Enter Earned Claims Ratio" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<span class="info-icon-wrapper">
|
||||
<i class="fa fa-info-circle text-primary"></i>
|
||||
<div class="info-tooltip">
|
||||
<strong>Formulas:</strong><br>
|
||||
1. Incurred Claims = Paid Claims + Outstanding Claims<br>
|
||||
2. Policy Run Days = Incurred Claim Date - Policy Start Date + 1<br>
|
||||
3. Earned Premium = (Premium as on Date / 365) × 364<br>
|
||||
4. Annualised Claims = (Incurred Claims / Policy Run Days) × 365<br>
|
||||
5. Incurred Claim Ratio = Annualised Claims / Premium as on Date<br>
|
||||
6. Earned Claims Ratio = Annualised Claims / Earned Premium
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="location">Location <span class="text-danger">*</span></label>
|
||||
<input value="<?php //echo isset($lead_edit_data['location']) ? $lead_edit_data['location'] : '' ?>" type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location">
|
||||
@ -135,6 +153,29 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_emp_count"> No of Employees at Expiry <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_emp_count']) ? $lead_edit_data['exp_emp_count'] : '' ?>" type="text" class="form-control" id="exp_emp_count" name="exp_emp_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_dept_count"> No of Dependents at Expiry <span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_dept_count']) ? $lead_edit_data['exp_dept_count'] : '' ?>" type="text" class="form-control" id="exp_dept_count" name="exp_dept_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_no_of_lives"> Total Lives at Expiry <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_no_of_lives']) ? $lead_edit_data['exp_no_of_lives'] : '' ?>" type="text" class="form-control" id="exp_no_of_lives" name="exp_no_of_lives[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
@ -162,25 +203,3 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_emp_count"> No of Employees at Expiry <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_emp_count']) ? $lead_edit_data['exp_emp_count'] : '' ?>" type="text" class="form-control" id="exp_emp_count" name="exp_emp_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_dept_count"> No of Dependents at Expiry <span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_dept_count']) ? $lead_edit_data['exp_dept_count'] : '' ?>" type="text" class="form-control" id="exp_dept_count" name="exp_dept_count[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="exp_no_of_lives"> Total Lives at Expiry <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['exp_no_of_lives']) ? $lead_edit_data['exp_no_of_lives'] : '' ?>" type="text" class="form-control" id="exp_no_of_lives" name="exp_no_of_lives[]"
|
||||
placeholder="Enter Lives">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user