Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
Srinivas-Saravanan 2025-05-30 16:01:48 +05:30
commit 6629f61895
8 changed files with 99 additions and 59 deletions

View File

@ -2402,8 +2402,11 @@ class LeadsController extends BaseController
} }
} }
$is_placement = false;
if ($recipient_type == 'placement') { if ($recipient_type == 'placement') {
$is_placement = true;
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2); list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
$lead_update_data = [ $lead_update_data = [
@ -2468,7 +2471,7 @@ class LeadsController extends BaseController
//delete attachment file //delete attachment file
unlink($file_path); unlink($file_path);
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result_data], 200); return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result_data, 'is_placement' => $is_placement], 200);
} }
public function getLevelContects() public function getLevelContects()

View File

@ -461,6 +461,12 @@ class PolicyTransactionController extends BaseController
$insurer_id = null; $insurer_id = null;
} }
if($data['bro_payable_by'] == 1){
$cop_amt = isset($data['co_premium'][$index]) && ($data['co_premium'][$index] != "0.00" || !empty($data['co_premium'][$index]) ) ? $data['co_premium'][$index] : ($data['base_premium'][$index] ?? 0);
}else{
$cop_amt = $data['co_premium'][$index] ?? 0;
}
// Prepare each co-share detail entry // Prepare each co-share detail entry
$coShareDetails[] = [ $coShareDetails[] = [
'pt_id' => $pt_id, 'pt_id' => $pt_id,
@ -493,9 +499,11 @@ class PolicyTransactionController extends BaseController
'actual_bp_brokerage_amt' => $data['actual_bp_brokerage_amt'][$index] ?? 0, 'actual_bp_brokerage_amt' => $data['actual_bp_brokerage_amt'][$index] ?? 0,
'actual_tp_brokerage_amt' => $data['actual_tp_brokerage_amt'][$index] ?? 0, 'actual_tp_brokerage_amt' => $data['actual_tp_brokerage_amt'][$index] ?? 0,
'actual_tep_brokerage_amt' => $data['actual_tep_brokerage_amt'][$index] ?? 0, 'actual_tep_brokerage_amt' => $data['actual_tep_brokerage_amt'][$index] ?? 0,
'exp_amt' => isset($data['exp_amt'][$index]) && !empty($data['exp_amt'][$index]) ? $data['exp_amt'][$index] : expected_amount_calc($data, $index), 'amount' => $data['total'][$index] ?? 0, 'exp_amt' => isset($data['exp_amt'][$index]) && !empty($data['exp_amt'][$index]) ? $data['exp_amt'][$index] : expected_amount_calc($data, $index),
'amount' => $data['total'][$index] ?? 0,
'stamp_duty' => $data['stamp_duty'][$index] ?? 0, 'stamp_duty' => $data['stamp_duty'][$index] ?? 0,
'cop_amt' => isset($data['co_premium'][$index]) && !empty($data['co_premium'][$index]) ? $data['co_premium'][$index] : ($data['base_premium'][$index] ?? 0), 'variance' => $data['variance'][$index] ?? 0, 'cop_amt' => $cop_amt,
'variance' => $data['variance'][$index] ?? 0,
'reward' => $data['reward'][$index] ?? null, 'reward' => $data['reward'][$index] ?? null,
'created_by' => get_session_userid() ?? null, 'created_by' => get_session_userid() ?? null,
'updated_by' => get_session_userid() ?? null, 'updated_by' => get_session_userid() ?? null,
@ -1655,7 +1663,7 @@ class PolicyTransactionController extends BaseController
return $this->respond(['status' => true, 'code' => 200, 'data' => $totalCount, 'is_copay_yes' => $is_copay_yes, "cd_master_data" => $cd_ac_no], 200); return $this->respond(['status' => true, 'code' => 200, 'data' => $totalCount, 'is_copay_yes' => $is_copay_yes, "cd_master_data" => $cd_ac_no], 200);
} else { } else {
$insurer_data = $this->clientPolicyModel->where('id', $client_policy_id)->where('is_active', 1)->first(); $insurer_data = $this->clientPolicyModel->where('id', $client_policy_id)->where('is_active', 1)->first();
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to get data'], 200); return $this->respond(['status' => false, 'code' => 404, 'message' => 'There is no policy inception data.'], 200);
} }
} }
@ -2586,7 +2594,7 @@ class PolicyTransactionController extends BaseController
public function dmsSearch() public function dmsSearch()
{ {
// echo 'scbsc';die(); // echo 'scbsc';die();
if ($this->request->getMethod() == 'post') { if ($this->request->is('post')) {
// $jsonData = (array)$this->request->getJSON(); // $jsonData = (array)$this->request->getJSON();
$customer_id = $this->request->getPost('customer_id'); $customer_id = $this->request->getPost('customer_id');
$policy_id = $this->request->getPost('policy_id'); $policy_id = $this->request->getPost('policy_id');

View File

@ -741,44 +741,47 @@ if (!function_exists('check_cd_entry_exist')) {
} }
} }
if (!function_exists('expected_amount_calc')) { if (!function_exists('expected_amount_calc')) {
function expected_amount_calc($data, $index) function expected_amount_calc($data, $index)
{ {
$agreed_amount = (int)($data['agreed_amount'][$index] ?? 0); $agreed_amount = (float) ($data['agreed_amount'][$index] ?? 0);
$agreed_bp_per = (int)$data['agreed_bp'][$index] ?? 0; $agreed_bp_per = (float) ($data['agreed_bp'][$index] ?? 0);
$agreed_tp_per = (int)$data['agreed_tp'][$index] ?? 0; $agreed_tp_per = (float) ($data['agreed_tp'][$index] ?? 0);
$agreed_tep_per = (int)$data['agreed_ter'][$index] ?? 0; $agreed_tep_per = (float) ($data['agreed_ter'][$index] ?? 0);
$standard_bp_per = (int)$data['standard_bp'][$index] ?? 0; $standard_bp_per = (float) ($data['standard_bp'][$index] ?? 0);
$standard_tp_per = (int)$data['standard_tp'][$index] ?? 0; $standard_tp_per = (float) ($data['standard_tp'][$index] ?? 0);
$standard_tep_per = (int)$data['standard_ter'][$index] ?? 0; $standard_tep_per = (float) ($data['standard_ter'][$index] ?? 0);
$base_premium = (int)$data['base_premium'][$index] ?? 0;
$third_part_premium = (int)$data['tp_premium'][$index] ?? 0;
$terrisom_premium = (int)$data['ter_premium'][$index] ?? 0;
$sum_of_agreed_premium =$agreed_bp_per + $agreed_tp_per + $agreed_tep_per; if($data['bro_payable_by'] == 0){
$base_premium = (float) ($data['co_premium'][$index] ?? 0);
$third_part_premium = (float) ($data['co_tp_premium'][$index] ?? 0);
$terrisom_premium = (float) ($data['co_ter_premium'][$index] ?? 0);
}else{
$base_premium = (float) ($data['base_premium'][$index] ?? 0);
$third_part_premium = (float) ($data['tp_premium'][$index] ?? 0);
$terrisom_premium = (float) ($data['ter_premium'][$index] ?? 0);
}
$sum_of_agreed_premium = $agreed_bp_per + $agreed_tp_per + $agreed_tep_per;
$expectedAmount = 0; $expectedAmount = 0;
if ($agreed_amount > 0) { if ($agreed_amount > 0) {
$expectedAmount = $agreed_amount; $expectedAmount = $agreed_amount;
} elseif ($sum_of_agreed_premium > 0) { } elseif ($sum_of_agreed_premium > 0) {
$sum_of_bp_amt = ($base_premium * $agreed_bp_per) / 100; $expectedAmount =
$sum_of_tp_amt = ($third_part_premium * $agreed_tp_per) / 100; ($base_premium * $agreed_bp_per / 100) +
$sum_of_tep_amt = ($terrisom_premium * $agreed_tep_per) / 100; ($third_part_premium * $agreed_tp_per / 100) +
$expectedAmount = $sum_of_bp_amt + $sum_of_tp_amt + $sum_of_tep_amt; ($terrisom_premium * $agreed_tep_per / 100);
} else { } else {
$sum_of_bp_amt = ($base_premium * $standard_bp_per) / 100; $expectedAmount =
$sum_of_tp_amt = ($third_part_premium * $standard_tp_per) / 100; ($base_premium * $standard_bp_per / 100) +
$sum_of_tep_amt = ($terrisom_premium * $standard_tep_per) / 100; ($third_part_premium * $standard_tp_per / 100) +
$expectedAmount = $sum_of_bp_amt + $sum_of_tp_amt + $sum_of_tep_amt; ($terrisom_premium * $standard_tep_per / 100);
} }
return $expectedAmount; return round($expectedAmount, 2); // Optional: round to 2 decimal places
} }
} }

View File

@ -1234,15 +1234,19 @@
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
let earned_premium = Number($('#earned_premium_' + increment).val()) || 0; let earnedPremium = parseFloat($('#earned_premium_' + increment).val()) || 0;
console.log('earned_premium', earned_premium); console.log('earnedPremium:', earnedPremium);
// Prevent division by zero in earned claims ratio calculation // Prevent division by zero
let earned_claims_ratio = earned_premium > 0 ? annualised_claims / earned_premium : 0; let earnedClaimsRatio = earnedPremium > 0 ? annualised_claims / earnedPremium : 0;
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
console.log('earned_claims_ratio', earned_claims_ratio); // 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);
$('#earned_claims_ratio_' + increment).val(earned_claims_ration_roundoff);
} }
function earnedPremiumCalc(input) { function earnedPremiumCalc(input) {

View File

@ -153,7 +153,7 @@
<label for="client_branch">Client<span class="text-danger">*</span></label> <label for="client_branch">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required> <select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option> <option value="">Select Client</option>
<option value="add_client"> + Add Client</option> <!-- <option value="add_client"> + Add Client</option> -->
</select> </select>
</div> </div>
@ -652,14 +652,19 @@ $(document).ready(function(){
populateTable(res.data); populateTable(res.data);
$('#btnSubmit').prop('disabled', false).data('disable', false);
}else{ }else{
$('#ct_type').val(1) $('#ct_type').val(1)
addInsurerColumn() // addInsurerColumn()
toastr.warning("There is no policy inception data.", 'WARNING!');
$('#btnSubmit').prop('disabled', true).data('disable', true);
} }
}else{ }else{
$('#ct_type').val(1) $('#ct_type').val(1)
addInsurerColumn() // addInsurerColumn()
toastr.warning(res.message, 'WARNING!');
$('#btnSubmit').prop('disabled', true).data('disable', true);
} }
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {

View File

@ -633,10 +633,10 @@ document.addEventListener("DOMContentLoaded", function () {
text: 'Select Client' text: 'Select Client'
})); }));
$('#client_id').append($('<option>', { // $('#client_id').append($('<option>', {
value: 'add_client', // value: 'add_client',
text: '+ Add Client' // text: '+ Add Client'
})); // }));
$.each(data, function(index, item) { $.each(data, function(index, item) {

View File

@ -861,6 +861,8 @@
<script> <script>
let intervalId;
$(document).ready(function () { $(document).ready(function () {
console.log("Document ready"); console.log("Document ready");
@ -870,15 +872,19 @@ $(document).ready(function () {
if (lead_status != "won") { if (lead_status != "won") {
console.log("Lead status is not 'won', setting interval for submitData"); console.log("Lead status is not 'won', setting interval for submitData");
setInterval(function () { startInterval();
console.log("Calling submitData(1) at 20-second interval");
submitData(1);
}, 20000);
} else { } else {
console.log("Lead status is 'won', submitData will not be called"); console.log("Lead status is 'won', submitData will not be called");
} }
}); });
function startInterval() {
intervalId = setInterval(function () {
console.log("Calling submitData(1) at 20-second interval");
submitData(1);
}, 20000);
}
const openDialogBtn = document.getElementById('openDialogBtn'); const openDialogBtn = document.getElementById('openDialogBtn');
@ -3732,6 +3738,10 @@ function ajaxRequest(formData) {
console.log(res); console.log(res);
if (res.status == 'success' && res.code == 200) { if (res.status == 'success' && res.code == 200) {
toastr.success('Mail send Successfully', 'SUCCESS') toastr.success('Mail send Successfully', 'SUCCESS')
if(res.is_placement == true){
clearInterval(intervalId);
console.log('******** Intervel Cleared ********')
}
} else { } else {
if (res.messgae) { if (res.messgae) {
toastr.error(res.messgae, 'ERROR') toastr.error(res.messgae, 'ERROR')
@ -5993,7 +6003,6 @@ function appendMultiFileData(data) {
// $('#is_installment_switch').prop('checked', true).trigger('change'); // $('#is_installment_switch').prop('checked', true).trigger('change');
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update $('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
} }
}); });
} }

View File

@ -635,8 +635,9 @@
// monitorTableChanges(); // monitorTableChanges();
}); });
$(document).ready(function () { let intervalId;
$(document).ready(function () {
console.log("Document ready"); console.log("Document ready");
let lead_status = '<?= isset($lead_data['status']) ? $lead_data['status'] : '' ?>'; let lead_status = '<?= isset($lead_data['status']) ? $lead_data['status'] : '' ?>';
@ -645,15 +646,18 @@
if (lead_status != "won") { if (lead_status != "won") {
console.log("Lead status is not 'won', setting interval for submitData"); console.log("Lead status is not 'won', setting interval for submitData");
setInterval(function () { startInterval();
console.log("Calling submitData(1) at 20-second interval");
saveRFQ(true);
}, 20000);
} else { } else {
console.log("Lead status is 'won', submitData will not be called"); console.log("Lead status is 'won', submitData will not be called");
} }
}); });
function startInterval() {
intervalId = setInterval(function () {
console.log("Calling submitData(1) at 20-second interval");
saveRFQ(true);
}, 20000);
}
var tableCount = 0; var tableCount = 0;
const policies = <?= json_encode($policies) ?>; const policies = <?= json_encode($policies) ?>;
@ -4996,7 +5000,11 @@
// // console.log(res); // // console.log(res);
if (res.status == 'success' && res.code == 200) { if (res.status == 'success' && res.code == 200) {
toastr.success('Mail send Successfully', 'SUCCESS') toastr.success('Mail send Successfully', 'SUCCESS');
if(res.is_placement == true){
clearInterval(intervalId);
console.log('******** Intervel Cleared ********')
}
} else { } else {
if (res.messgae) { if (res.messgae) {
toastr.error(res.messgae, 'ERROR') toastr.error(res.messgae, 'ERROR')