Merge branch 'main' of bitbucket.org:jubilian/nhance_partner_be
This commit is contained in:
commit
7d5fb477e3
@ -784,7 +784,8 @@ class EnquiryController extends ResourceController
|
||||
}
|
||||
|
||||
// --- 5. Step 4 Compare Dates
|
||||
$msg = $enquiry["name"]." with policy ".$policy["policy_number"]." for vehicle ".$reg_no." already exists and is active.";
|
||||
// $msg = $enquiry["name"]." with policy ".$policy["policy_number"]." for vehicle ".$reg_no." already exists and is active.";
|
||||
$msg = "An active policy already exists for vehicle number ".$reg_no.".";
|
||||
if ($endDate >= $currentDate) {
|
||||
return $this->response->setJSON([
|
||||
"status" => "exists",
|
||||
|
||||
@ -242,16 +242,33 @@ class PolicyController extends ResourceController
|
||||
if (!$policy) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'Data Not Found'], 200);
|
||||
}
|
||||
// Check rc_no first, then fallback to enquiry_reg_no_for_commission
|
||||
// Priority 1: New Form Input ($data)
|
||||
// Priority 2: Existing Policy Record ($policy)
|
||||
// Priority 3: Original Enquiry Record ($enquiry_reg_no)
|
||||
|
||||
$final_reg_no = !empty($data['rc_no'])
|
||||
? $data['rc_no']
|
||||
: (!empty($policy['rc_no'])
|
||||
? $policy['rc_no']
|
||||
: ($data['enquiry_reg_no_for_commission'] ?? null));
|
||||
|
||||
$final_payment_mode = !empty($data['payment_mode'])
|
||||
? $data['payment_mode']
|
||||
: (!empty($policy['payment_mode'])
|
||||
? $policy['payment_mode']
|
||||
: null);
|
||||
|
||||
|
||||
$updateData = [
|
||||
'rc_no' => $data['rc_no'] ?? $policy['rc_no'],
|
||||
'rc_no' => $final_reg_no,
|
||||
'insured_name' => $data['insured_name'] ?? $policy['insured_name'],
|
||||
'issued_date' => format_date_for_database($data['issued_date']),
|
||||
'start_date' => format_date_for_database($data['start_date']),
|
||||
'end_date' => format_date_for_database($data['end_date']),
|
||||
'premium_amount' => $data['premium_amount'] ?? $policy['premium_amount'],
|
||||
'policy_number' => $data['policy_number'] ?? $policy['policy_number'],
|
||||
'payment_mode' => $data['payment_mode'] ?? $policy['payment_mode'],
|
||||
'payment_mode' => $final_payment_mode,
|
||||
'tp' => $data['tp'] ?? null,
|
||||
'od' => $data['od'] ?? null,
|
||||
'pa' => $data['pa'] ?? null,
|
||||
@ -287,8 +304,12 @@ class PolicyController extends ResourceController
|
||||
$EnquiryupdateData['vehicle_type_id'] = $data['enquiry_vehicle_type_id_for_commission'];
|
||||
}
|
||||
|
||||
if (!empty($data['enquiry_reg_no_for_commission'])) {
|
||||
$EnquiryupdateData['reg_no'] = $data['enquiry_reg_no_for_commission'];
|
||||
if ($final_reg_no) {
|
||||
$EnquiryupdateData['reg_no'] = $final_reg_no;
|
||||
}
|
||||
|
||||
if (!empty($data['insured_name'])) {
|
||||
$EnquiryupdateData['name'] = $data['insured_name'];
|
||||
}
|
||||
|
||||
|
||||
@ -299,6 +320,7 @@ class PolicyController extends ResourceController
|
||||
->first();
|
||||
|
||||
if (!empty($policy['enquiry_id'])) {
|
||||
$EnquiryupdateData['updated_by'] = $data['updated_by'];
|
||||
$db = \Config\Database::connect();
|
||||
$db->table('partner_enquiry')
|
||||
->where('id', $policy['enquiry_id'])
|
||||
@ -315,12 +337,12 @@ class PolicyController extends ResourceController
|
||||
->where('id', $id)
|
||||
->first();
|
||||
|
||||
$partnerQuotationUpdateData = [
|
||||
'insurance_plan_type_id' => $data['insurance_plan_type_id'],
|
||||
];
|
||||
$partnerQuotationUpdateData['insurance_plan_type_id'] = $data['insurance_plan_type_id'];
|
||||
if ($final_payment_mode) { $partnerQuotationUpdateData['payment_mode_id'] = $final_payment_mode; }
|
||||
|
||||
|
||||
if (!empty($partnerQuotationUpdateData)) {
|
||||
|
||||
$partnerQuotationUpdateData['updated_by'] = $data['updated_by'];
|
||||
$db = \Config\Database::connect();
|
||||
$db->table('partner_quotation')
|
||||
->where('id', $partnerQuotation['quotation_id'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user