Comment out call to inventory manager. #374

This commit is contained in:
Korina Cordero 2020-04-08 09:31:28 +00:00
parent ab6ed4a185
commit 917459f228

View file

@ -2265,15 +2265,36 @@ class APIController extends Controller
foreach ($hubs as $hub)
{
$nearest_hubs_with_distance[] = $hub;
if (!empty($hub['hub']->getBranchCode()))
$nearest_branch_codes[] = $hub['hub']->getBranchCode();
//if (!empty($hub['hub']->getBranchCode()))
// $nearest_branch_codes[] = $hub['hub']->getBranchCode();
}
// check if nearest hubs have branch codes
if (count($nearest_branch_codes) == 0)
return $selected_hub;
//if (count($nearest_branch_codes) == 0)
// return $selected_hub;
// assume all 10 have stock
// find the nearest hub with available riders
$nearest = null;
foreach ($nearest_hubs_with_distance as $nhd)
{
if (count($nhd['hub']->getAvailableRiders()) > 0)
{
if (empty($nearest))
$nearest = $nhd;
else
{
if ($nhd['distance'] < $nearest['distance'])
$nearest = $nhd;
}
}
}
$selected_hub = $nearest['hub'];
// uncomment this snippet when inventory check becomes active
// get battery sku
/*
if ($batt != null)
{
$skus[] = $batt->getSAPCode();
@ -2281,7 +2302,8 @@ class APIController extends Controller
// api call to check inventory
// pass the list of branch codes of nearest hubs and the skus
// go through returned list of branch codes
$hubs_with_inventory = $im->getBranchesInventory($nearest_branch_codes, $skus);
// bypass inventory check for now
// $hubs_with_inventory = $im->getBranchesInventory($nearest_branch_codes, $skus);
if (!empty($hubs_with_inventory))
{
$nearest = [];
@ -2321,7 +2343,7 @@ class APIController extends Controller
}
$selected_hub = $nearest['hub'];
}
}
} */
return $selected_hub;
}