From b1ff62d9ec6bc4a00c9b6c27dc6dfdfd2178fe62 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Tue, 17 Oct 2023 14:43:06 +0800 Subject: [PATCH] Add back insurance status to vehicle list so latest status can be displayed #761 --- src/Controller/CustomerAppAPI/VehicleController.php | 2 +- src/Entity/CustomerVehicle.php | 6 ++++-- src/Ramcar/InsuranceApplicationStatus.php | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controller/CustomerAppAPI/VehicleController.php b/src/Controller/CustomerAppAPI/VehicleController.php index 24d28a4f..99bee31f 100644 --- a/src/Controller/CustomerAppAPI/VehicleController.php +++ b/src/Controller/CustomerAppAPI/VehicleController.php @@ -190,7 +190,7 @@ class VehicleController extends ApiController // only get the customer's vehicles whose flag_active is true $cvs = $this->em->getRepository(CustomerVehicle::class)->findBy(['flag_active' => true, 'customer' => $cust]); foreach ($cvs as $cv) { - $cv_list[] = $this->generateVehicleInfo($cv); + $cv_list[] = $this->generateVehicleInfo($cv, true); } // response diff --git a/src/Entity/CustomerVehicle.php b/src/Entity/CustomerVehicle.php index a120c71e..a569d4b2 100644 --- a/src/Entity/CustomerVehicle.php +++ b/src/Entity/CustomerVehicle.php @@ -298,10 +298,12 @@ class CustomerVehicle public function getLatestInsuranceApplication() { $criteria = Criteria::create() - ->where(Criteria::expr()->notIn('status', [InsuranceApplicationStatus::EXPIRED, InsuranceApplicationStatus::CANCELLED])) + ->where(Criteria::expr()->notIn('status', [InsuranceApplicationStatus::CANCELLED])) ->orderBy(['date_submit' => Criteria::DESC]) ->setMaxResults(1); - return $this->insurance_applications->matching($criteria)[0]; + $result = $this->insurance_applications->matching($criteria); + + return !empty($result) ? $result[0] : null; } } diff --git a/src/Ramcar/InsuranceApplicationStatus.php b/src/Ramcar/InsuranceApplicationStatus.php index 8908a3a8..8480239c 100644 --- a/src/Ramcar/InsuranceApplicationStatus.php +++ b/src/Ramcar/InsuranceApplicationStatus.php @@ -8,13 +8,11 @@ class InsuranceApplicationStatus extends NameValue const PAID = 'paid'; const COMPLETED = 'completed'; const CANCELLED = 'cancelled'; - const EXPIRED = 'expired'; const COLLECTION = [ 'created' => 'Created', 'paid' => 'Paid', 'completed' => 'Completed', 'cancelled' => 'Cancelled', - 'expired' => 'Expired', ]; }