From 21c97df677488b943217c08325f03cb1a0a82656 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 16 May 2024 21:46:02 +0800 Subject: [PATCH] Set JO type regardless of area support on hub form initialization to trigger inventory filter #800 --- src/Service/HubSelector.php | 12 ++++++------ src/Service/JobOrderHandler/ResqJobOrderHandler.php | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index eeeba2db..f16b4615 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -271,19 +271,19 @@ class HubSelector { // check if this is enabled if (!$flag_inventory_check) { - //rror_log("INVENTORY CHECK " . $jo_id . ": DISABLED"); + error_log("INVENTORY CHECK " . $jo_id . ": DISABLED"); return $hubs; } // check hub list is not empty if (empty($hubs)) { - //error_log("INVENTORY CHECK " . $jo_id . ": NO HUBS"); + error_log("INVENTORY CHECK " . $jo_id . ": NO HUBS"); return $hubs; } // check item list is not empty if (empty($items)) { - //error_log("INVENTORY CHECK " . $jo_id . ": NO ITEMS"); + error_log("INVENTORY CHECK " . $jo_id . ": NO ITEMS"); return $hubs; } @@ -291,7 +291,7 @@ class HubSelector if ($jo_type != ServiceType::BATTERY_REPLACEMENT_NEW && $jo_type != ServiceType::BATTERY_REPLACEMENT_WARRANTY ) { - //error_log("INVENTORY CHECK " . $jo_id . ": INVALID SERVICE TYPE"); + error_log("INVENTORY CHECK " . $jo_id . ": INVALID SERVICE TYPE: " . $jo_type); return $hubs; } @@ -311,11 +311,11 @@ class HubSelector // call inventory manager for all hubs for selected SKUs $skus = array_keys($items); - //error_log("CHECKING INVENTORY FOR " . count($skus) . " ITEM(S) ON HUBS " . count($branch_codes) . "..."); + error_log("CHECKING INVENTORY FOR " . count($skus) . " ITEM(S) ON HUBS " . count($branch_codes) . "..."); $branches = $this->im->getBranchesInventory($branch_codes, $skus); - //error_log("REQUEST COMPLETE, RESULT COUNT: " . count($branches)); + error_log("REQUEST COMPLETE, RESULT COUNT: " . count($branches)); // check each result to see if sufficient quantity exists to meet request foreach ($branches as $branch) { diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 02d2e8df..a6a9449b 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -2551,6 +2551,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setDateTime($obj->getDateSchedule()) ->setLimitResults(50); + // NOTE: set JO type regardless, for now + $hub_criteria->setJoType($obj->getServiceType()); + // check if hub filter is enabled. If not, use default values // for the rest of the HubCriteria fields if ($this->hub_filter_enabled == 'true') @@ -2562,7 +2565,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // error_log('Area is covered by hub filtering'); $hub_criteria->setLimitDistance($this->cust_distance_limit) ->setPaymentMethod($obj->getModeOfPayment()) - ->setJoType($obj->getServiceType()) ->setRoundRobin(true); } } @@ -2897,13 +2899,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setDateTime($obj->getDateSchedule()) ->setLimitResults(50); + // NOTE: set JO type regardless, for now + $hub_criteria->setJoType($obj->getServiceType()); + if ($this->hub_geofence->isCovered($long, $lat)) { // if true, set other values for HubCriteria // error_log('Area is covered by hub'); $hub_criteria->setLimitDistance($this->cust_distance_limit) ->setPaymentMethod($obj->getModeOfPayment()) - ->setJoType($obj->getServiceType()) ->setRoundRobin(true); }