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

This commit is contained in:
Gowtham M 2026-01-03 15:49:20 +05:30
commit 87fdb4f0d9

View File

@ -712,7 +712,9 @@ class EnquiryController extends ResourceController
])->setStatusCode(400);
}
if ($reg_no == 'New' || $reg_no == 'new' || $reg_no == 'NEW') {
$normalized_input = strtoupper(preg_replace('/[^A-Za-z0-9]/', '', $reg_no));
if ($normalized_input === 'NEW') {
return $this->response->setJSON([
"status" => "not exists",
"message" => "No active record found for this vehicle number in enquiries."
@ -723,34 +725,33 @@ class EnquiryController extends ResourceController
// Get the LATEST ACTIVE enquiry record for the registration number
$enquiry = $this->db->table("partner_enquiry")
->select("*")
->where("reg_no", $reg_no)
->where("is_active", 1) // Only consider active enquiries
->where("is_active", 1)
->groupStart()
// This replaces common separators in the DB column with empty strings
->where("REPLACE(REPLACE(REPLACE(reg_no, ' ', ''), '-', ''), '.', '') =", $normalized_input)
->groupEnd()
->orderBy("id", "DESC")
->get()
->getRowArray();
// If no active enquiry is found, the vehicle is considered 'not' a duplicate
if (!$enquiry) {
return $this->response->setJSON([
"status" => "not exists",
"message" => "No active record found for this vehicle number in enquiries."
"message" => "No active record found for $reg_no"
]);
}
// NOTE: The previous check for $enquiry["is_active"] == 0 is now redundant
// because the query already filters for where("is_active", 1).
// --- 3. Step 2: Check in partner_policy (Active Policy for Enquiry) ---
// Get the LATEST ACTIVE policy for the found enquiry
$policy = $this->db->table("partner_policy")
->select("*")
->where("enquiry_id", $enquiry["id"])
->where("is_active", 1) // Only consider active policies
->where("is_active", 1)
->orderBy("id", "DESC")
->get()
->getRowArray();
// If no active policy is found for the active enquiry, return "not"
if (!$policy) {
return $this->response->setJSON([
"status" => "exists",
@ -782,15 +783,5 @@ class EnquiryController extends ResourceController
"message" => "Policy exists but is expired for vehicle number " . $reg_no
]);
}
}