Add hub selector filtering for available riders, refactor inventory filter to... #1731

Merged
arcticzero merged 42 commits from 800-automatically-reject-jo-if-no-riders-or-inventory into master 2024-07-18 08:34:03 +00:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit e8b14ff379 - Show all commits

View file

@ -114,7 +114,9 @@ class Hub
public function getAvailableRiders()
{
$crit = Criteria::create();
$crit->where(Criteria::expr()->eq('flag_available', true));
$crit->where(Criteria::expr()->eq('flag_available', true))
->where(Criteria::expr()->eq('flag_active', true))
->where(Criteria::expr()->eq('current_job_order', null));
return $this->riders->matching($crit);
}

View file

@ -31,7 +31,7 @@ class RiderAvailabilityHubFilter extends BaseHubFilter implements HubFilterInter
// check customer class
if (!empty($params['customer_class']) && $params['customer_class'] == CustomerClassification::VIP) {
error_log("INVENTORY CHECK " . $this->getJOID() . ": VIP CLASS");
error_log("RIDER CHECK " . $this->getJOID() . ": VIP CLASS");
return $hubs;
}
@ -40,8 +40,10 @@ class RiderAvailabilityHubFilter extends BaseHubFilter implements HubFilterInter
foreach ($hubs as $hub_data) {
$hub = $hub_data['hub'];
$available_riders = count($hub->getAvailableRiders());
// check we have available riders
if ($hub->getAvailableRiders() === 0) {
error_log("TOTAL RIDERS: " . $available_riders);
if ($available_riders === 0) {
// if we have a JO, create rejection record and notify
if (!empty($jo_id)) {
// create rejection report entry