Resolve "Add notification number to hub" #1466

Merged
korina.cordero merged 22 commits from 552-add-notification-number-to-hub into master 2021-04-28 07:28:40 +00:00
Showing only changes of commit 498c88ce38 - Show all commits

View file

@ -71,14 +71,36 @@ class HubSelector
protected function filterHubsByRoundRobin($hubs)
{
if (empty($hubs))
return $hubs;
}
protected function filterHubsByMaxResults($hubs, $limit_result)
{
if (empty($hubs))
return $hubs;
if (empty($limit_result))
return $hubs;
}
protected function filterHubsByJoType($hubs, $jo_type)
{
if (empty($hubs))
return $hubs;
if (empty($jo_type))
return $hubs;
$results = [];
foreach ($hubs as $hub)
{
$has_jo_type = false;
// check if hub offers the jo_type
// TODO: add service to hub
if ($has_jo_type)
$results[] = $hub;
}
return $results;
}
protected function filterHubsByDateAndTime($hubs, $date_time)
@ -95,6 +117,17 @@ class HubSelector
{
// go through each hub's opening times to check if hub is open
// for the specified time
// get hub opening and closing times
$time_open = date("H:i:s", $hub->getTimeOpen());
$time_close = date("H:i:s", $hub->getTimeClose());
$filter_time = date("H:i:s", $date_time);
if (($filter_time >= $time_open) &&
($filter_time <= $time_close))
{
$results[] = $hub;
}
}
return $results;
@ -115,11 +148,17 @@ class HubSelector
{
if ($jo_type == ServiceType::BATTERY_REPLACEMENT_NEW)
{
// call inventory
// call inventory
$has_items = $this->checkInventory($items, $hub);
if ($has_items)
$results[] = $hub;
}
if ($jo_type == ServiceType::BATTERY_REPLACEMENT_WARRANTY)
{
// call inventory
$has_items = $this->checkInventory($items, $hub);
if ($has_items)
$results[] = $hub;
}
}
}
@ -174,8 +213,23 @@ class HubSelector
protected function checkInventory($items, $hub)
{
// check if hub has all items
$skus = [];
$hubs[] = $hub;
$result = false;
foreach ($items as $item)
{
// add sap code of item/battery into array since
// getBranchesInventory takes in an array of hubs/branches
// and an array of skus
$sku[] = $item->getSAPCode();
}
// call InventoryManager's getBranchesInventory to check if hub has all items
$result = $this->im->getBranchesInventory($hubs, $skus);
// return true or false
return $result;
}
// convert db distance to kilometers