Set JO type regardless of area support on hub form initialization to trigger inventory filter #800

This commit is contained in:
Ramon Gutierrez 2024-05-16 21:46:02 +08:00
parent 5cf2c3619f
commit 21c97df677
2 changed files with 12 additions and 8 deletions

View file

@ -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) {

View file

@ -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);
}