diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 22f72376..b5f4701a 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -2402,8 +2402,11 @@ class LeadsController extends BaseController
}
}
+ $is_placement = false;
if ($recipient_type == 'placement') {
+ $is_placement = true;
+
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
$lead_update_data = [
@@ -2468,7 +2471,7 @@ class LeadsController extends BaseController
//delete attachment file
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()
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 1453430f..c6c9aaa8 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -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,9 +499,11 @@ 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' => 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,
- '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,
'created_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);
} 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);
}
}
@@ -2586,7 +2594,7 @@ class PolicyTransactionController extends BaseController
public function dmsSearch()
{
// echo 'scbsc';die();
- if ($this->request->getMethod() == 'post') {
+ if ($this->request->is('post')) {
// $jsonData = (array)$this->request->getJSON();
$customer_id = $this->request->getPost('customer_id');
$policy_id = $this->request->getPost('policy_id');
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 52e5f52c..eae819ea 100755
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -741,44 +741,47 @@ if (!function_exists('check_cd_entry_exist')) {
}
}
-
-
-
if (!function_exists('expected_amount_calc')) {
-
function expected_amount_calc($data, $index)
{
- $agreed_amount = (int)($data['agreed_amount'][$index] ?? 0);
- $agreed_bp_per = (int)$data['agreed_bp'][$index] ?? 0;
- $agreed_tp_per = (int)$data['agreed_tp'][$index] ?? 0;
- $agreed_tep_per = (int)$data['agreed_ter'][$index] ?? 0;
+ $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 = (int)$data['standard_bp'][$index] ?? 0;
- $standard_tp_per = (int)$data['standard_tp'][$index] ?? 0;
- $standard_tep_per = (int)$data['standard_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);
- $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;
if ($agreed_amount > 0) {
$expectedAmount = $agreed_amount;
} elseif ($sum_of_agreed_premium > 0) {
- $sum_of_bp_amt = ($base_premium * $agreed_bp_per) / 100;
- $sum_of_tp_amt = ($third_part_premium * $agreed_tp_per) / 100;
- $sum_of_tep_amt = ($terrisom_premium * $agreed_tep_per) / 100;
- $expectedAmount = $sum_of_bp_amt + $sum_of_tp_amt + $sum_of_tep_amt;
+ $expectedAmount =
+ ($base_premium * $agreed_bp_per / 100) +
+ ($third_part_premium * $agreed_tp_per / 100) +
+ ($terrisom_premium * $agreed_tep_per / 100);
} else {
- $sum_of_bp_amt = ($base_premium * $standard_bp_per) / 100;
- $sum_of_tp_amt = ($third_part_premium * $standard_tp_per) / 100;
- $sum_of_tep_amt = ($terrisom_premium * $standard_tep_per) / 100;
- $expectedAmount = $sum_of_bp_amt + $sum_of_tp_amt + $sum_of_tep_amt;
+ $expectedAmount =
+ ($base_premium * $standard_bp_per / 100) +
+ ($third_part_premium * $standard_tp_per / 100) +
+ ($terrisom_premium * $standard_tep_per / 100);
}
- return $expectedAmount;
+ return round($expectedAmount, 2); // Optional: round to 2 decimal places
}
-}
\ No newline at end of file
+}
diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php
index 90878893..c981df21 100644
--- a/app/Views/leads_form.php
+++ b/app/Views/leads_form.php
@@ -1234,15 +1234,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) {
diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php
index b3c03320..91e024f1 100644
--- a/app/Views/policy_transaction_endorsement_form.php
+++ b/app/Views/policy_transaction_endorsement_form.php
@@ -153,7 +153,7 @@
@@ -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) {
diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php
index 9c321e2e..c6b285c8 100644
--- a/app/Views/policy_transaction_endorsement_list.php
+++ b/app/Views/policy_transaction_endorsement_list.php
@@ -633,10 +633,10 @@ document.addEventListener("DOMContentLoaded", function () {
text: 'Select Client'
}));
- $('#client_id').append($('