Merge branch 'main' of bitbucket.org:jubilian/nhance_partner_be

This commit is contained in:
Gowtham M 2026-02-02 10:38:50 +05:30
commit 34d8283bd0

View File

@ -718,7 +718,7 @@ class EnquiryController extends ResourceController
// --- 1. Input Validation ---
$reg_no = $this->request->getGet("reg_no");
if (!$reg_no) {
if (empty($reg_no)) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Please provide a valid vehicle registration number.'
@ -772,14 +772,20 @@ class EnquiryController extends ResourceController
]);
}
// --- 4. Step 3: Compare end_date >= CURRENT_DATE ---
$endDate = $policy["end_date"] ?? '';
$currentDate = date("Y-m-d");
// The policy is active if the end_date is TODAY or in the FUTURE.
if ($policy["end_date"] >= $currentDate) {
// ACTIVE POLICY → 'exists'
$msg = $enquiry["name"]." with policy ".$policy["policy_number"]." for vehicle ".$reg_no." already exists and is active.";
// --- 4. Step 3 Check if date is missing or invalid format (0000-00-00)
if (empty($endDate) || $endDate === "0000-00-00") {
return $this->response->setJSON([
"status" => "exists",
"message" => "Policy exists but end date is invalid for $reg_no"
]);
}
// --- 5. Step 4 Compare Dates
$msg = $enquiry["name"]." with policy ".$policy["policy_number"]." for vehicle ".$reg_no." already exists and is active.";
if ($endDate >= $currentDate) {
return $this->response->setJSON([
"status" => "exists",
"message" => $msg,
@ -790,10 +796,10 @@ class EnquiryController extends ResourceController
]);
}
// POLICY expired (end_date is in the past)
// --- 6. POLICY expired (end_date is in the past)
return $this->response->setJSON([
"status" => "not exists",
"message" => "Policy exists but is expired for vehicle number " . $reg_no
"message" => "Policy exists but expired on $endDate for vehicle $reg_no"
]);
}