Fix issues found during testing. #575

This commit is contained in:
Korina Cordero 2021-06-03 09:22:58 +00:00
parent c3ffbb20ff
commit 2ebfe4cccb
3 changed files with 41 additions and 4 deletions

View file

@ -25,7 +25,7 @@ class HubCriteria
$this->limit_distance = 500;
$this->jo_type = '';
$this->date_time = null;
$this->has_inventory = false;
$this->flag_inventory_check = false;
$this->items = [];
$this->payment_method = '';
$flag_emergency = false;

View file

@ -64,24 +64,32 @@ class HubSelector
$hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time);
$filtered_hubs = $hubs_date_time;
//error_log('date_time hubs ' . json_encode($filtered_hubs));
// filter jo types
$hubs_jo_type = $this->filterHubsByJoType($filtered_hubs, $jo_type);
$filtered_hubs = $hubs_jo_type;
//error_log('jo_type hubs ' . json_encode($filtered_hubs));
// filter hubs by payment methods
$hubs_payment_method = $this->filterHubsByPaymentMethod($filtered_hubs, $payment_method);
$filtered_hubs = $hubs_payment_method;
//error_log('payment hubs ' . json_encode($filtered_hubs));
// inventory filter
$hubs_inventory = $this->filterHubsByInventory($filtered_hubs, $flag_inventory_check,
$jo_type, $items);
$filtered_hubs = $hubs_inventory;
//error_log('inventory hubs ' . json_encode($filtered_hubs));
// round robin filter
$hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs);
$filtered_hubs = $hubs_round_robin;
error_log(json_encode($filtered_hubs));
//error_log('round robin hubs ' . json_encode($filtered_hubs));
// max results filter
$hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results);

View file

@ -1945,6 +1945,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get rejection reasons
$params['rejection_reasons'] = JORejectionReason::getCollection();
$hub_criteria = new HubCriteria();
// get battery (if any)
$skus = [];
$items = [];
@ -1965,12 +1967,13 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$items[$sap_code] = $item_count + 1;
else
$items[$sap_code] = $item_count;
$hub_criteria->addItem($sap_code, $item_count);
}
}
// get closest hubs
// set hub criteria
$hub_criteria = new HubCriteria();
$hub_criteria->setPoint($obj->getCoordinates())
->setLimitResults(50)
->setPaymentMethod($obj->getModeOfPayment())
@ -2229,8 +2232,34 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get rejection reasons
$params['rejection_reasons'] = JORejectionReason::getCollection();
// get closest hubs
$hub_criteria = new HubCriteria();
// get battery (if any)
$skus = [];
$items = [];
$invoice = $obj->getInvoice();
$inv_items = $invoice->getItems();
foreach ($inv_items as $inv_item)
{
$batt = $inv_item->getBattery();
if ($batt == null)
continue;
$skus[] = $batt->getSapCode();
$item_count = 1;
if (!empty($batt->getSapCode()))
{
$sap_code = $batt->getSapCode();
if (isset($items[$sap_code]))
$items[$sap_code] = $item_count + 1;
else
$items[$sap_code] = $item_count;
}
$hub_criteria->addItem($sap_code, $item_count);
}
// get closest hubs
$hub_criteria->setPoint($obj->getCoordinates())
->setLimitResults(50);
$hubs = $hub_selector->find($hub_criteria);