FIX_ENDORSEMENT_ISSUE : RV
This commit is contained in:
parent
d0f017a228
commit
44e5825b12
@ -461,6 +461,12 @@ class PolicyTransactionController extends BaseController
|
||||
$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
|
||||
$coShareDetails[] = [
|
||||
'pt_id' => $pt_id,
|
||||
@ -493,10 +499,10 @@ class PolicyTransactionController extends BaseController
|
||||
'actual_bp_brokerage_amt' => $data['actual_bp_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,
|
||||
'exp_amt' => $data['exp_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,
|
||||
'stamp_duty' => $data['stamp_duty'][$index] ?? 0,
|
||||
'cop_amt' => $data['co_premium'][$index] ?? 0,
|
||||
'cop_amt' => $cop_amt,
|
||||
'variance' => $data['variance'][$index] ?? 0,
|
||||
'reward' => $data['reward'][$index] ?? null,
|
||||
'created_by' => get_session_userid() ?? null,
|
||||
@ -1657,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);
|
||||
} else {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -742,4 +742,51 @@ if (!function_exists('check_cd_entry_exist')) {
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('expected_amount_calc')) {
|
||||
function expected_amount_calc($data, $index)
|
||||
{
|
||||
$agreed_amount = (float) ($data['agreed_amount'][$index] ?? 0);
|
||||
$agreed_bp_per = (float) ($data['agreed_bp'][$index] ?? 0);
|
||||
$agreed_tp_per = (float) ($data['agreed_tp'][$index] ?? 0);
|
||||
$agreed_tep_per = (float) ($data['agreed_ter'][$index] ?? 0);
|
||||
|
||||
$standard_bp_per = (float) ($data['standard_bp'][$index] ?? 0);
|
||||
$standard_tp_per = (float) ($data['standard_tp'][$index] ?? 0);
|
||||
$standard_tep_per = (float) ($data['standard_ter'][$index] ?? 0);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
if ($agreed_amount > 0) {
|
||||
$expectedAmount = $agreed_amount;
|
||||
} elseif ($sum_of_agreed_premium > 0) {
|
||||
$expectedAmount =
|
||||
($base_premium * $agreed_bp_per / 100) +
|
||||
($third_part_premium * $agreed_tp_per / 100) +
|
||||
($terrisom_premium * $agreed_tep_per / 100);
|
||||
} else {
|
||||
$expectedAmount =
|
||||
($base_premium * $standard_bp_per / 100) +
|
||||
($third_part_premium * $standard_tp_per / 100) +
|
||||
($terrisom_premium * $standard_tep_per / 100);
|
||||
}
|
||||
|
||||
return round($expectedAmount, 2); // Optional: round to 2 decimal places
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1232,15 +1232,19 @@
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let earned_premium = Number($('#earned_premium_' + increment).val()) || 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
let earnedPremium = parseFloat($('#earned_premium_' + increment).val()) || 0;
|
||||
console.log('earnedPremium:', earnedPremium);
|
||||
|
||||
// Prevent division by zero in earned claims ratio calculation
|
||||
let earned_claims_ratio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
||||
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
|
||||
console.log('earned_claims_ratio', earned_claims_ratio);
|
||||
// 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);
|
||||
|
||||
$('#earned_claims_ratio_' + increment).val(earned_claims_ration_roundoff);
|
||||
}
|
||||
|
||||
function earnedPremiumCalc(input) {
|
||||
|
||||
@ -153,7 +153,7 @@
|
||||
<label for="client_branch">Client<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_id" name="client_id" required>
|
||||
<option value="">Select Client</option>
|
||||
<option value="add_client"> + Add Client</option>
|
||||
<!-- <option value="add_client"> + Add Client</option> -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -652,14 +652,19 @@ $(document).ready(function(){
|
||||
|
||||
populateTable(res.data);
|
||||
|
||||
$('#btnSubmit').prop('disabled', false).data('disable', false);
|
||||
|
||||
}else{
|
||||
$('#ct_type').val(1)
|
||||
addInsurerColumn()
|
||||
// addInsurerColumn()
|
||||
toastr.warning("There is no policy inception data.", 'WARNING!');
|
||||
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
||||
}
|
||||
}else{
|
||||
$('#ct_type').val(1)
|
||||
addInsurerColumn()
|
||||
// addInsurerColumn()
|
||||
toastr.warning(res.message, 'WARNING!');
|
||||
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
@ -633,10 +633,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
text: 'Select Client'
|
||||
}));
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
// $('#client_id').append($('<option>', {
|
||||
// value: 'add_client',
|
||||
// text: '+ Add Client'
|
||||
// }));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user