Fix available rider filter to also consider flag_active and current_job_order #800

This commit is contained in:
Ramon Gutierrez 2024-06-27 10:58:11 +08:00
parent 44b3753ece
commit e8b14ff379
2 changed files with 7 additions and 3 deletions

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