Enable inventory and rider hub filters for emergency JOs, disable for VIP customers #800
This commit is contained in:
parent
b53aacb840
commit
aae4aaa390
1 changed files with 10 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
use App\Entity\Hub;
|
use App\Entity\Hub;
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
use App\Entity\Battery;
|
use App\Entity\Battery;
|
||||||
|
use App\Ramcar\CustomerClassification;
|
||||||
use App\Service\HubDistributor;
|
use App\Service\HubDistributor;
|
||||||
use App\Service\InventoryManager;
|
use App\Service\InventoryManager;
|
||||||
use App\Service\HubFilterLogger;
|
use App\Service\HubFilterLogger;
|
||||||
|
|
@ -63,8 +63,9 @@ class HubSelector
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
// get the job order object
|
// get the job order object and customer class
|
||||||
$jo = $this->em->getRepository(JobOrder::class)->find($jo_id);
|
$jo = $this->em->getRepository(JobOrder::class)->find($jo_id);
|
||||||
|
$customer_class = $jo->getCustomer()->getCustomerClassification();
|
||||||
|
|
||||||
// error_log('payment methods ' . $payment_method);
|
// error_log('payment methods ' . $payment_method);
|
||||||
// error_log('distance limit ' . $limit_distance);
|
// error_log('distance limit ' . $limit_distance);
|
||||||
|
|
@ -81,6 +82,8 @@ class HubSelector
|
||||||
|
|
||||||
// error_log('date_time hubs ' . json_encode($filtered_hubs));
|
// error_log('date_time hubs ' . json_encode($filtered_hubs));
|
||||||
|
|
||||||
|
// TODO: allow toggling of each filter individually for specific conditions (e.g. customer class, emergency)
|
||||||
|
|
||||||
if (!$flag_emergency)
|
if (!$flag_emergency)
|
||||||
{
|
{
|
||||||
// filter jo types
|
// filter jo types
|
||||||
|
|
@ -98,7 +101,10 @@ class HubSelector
|
||||||
//error_log('inventory hubs ' . json_encode($filtered_hubs));
|
//error_log('inventory hubs ' . json_encode($filtered_hubs));
|
||||||
|
|
||||||
// error_log('round robin hubs ' . json_encode($filtered_hubs));
|
// error_log('round robin hubs ' . json_encode($filtered_hubs));
|
||||||
|
}
|
||||||
|
|
||||||
|
// only enable rider and inventory checks if not VIP
|
||||||
|
if ($customer_class !== CustomerClassification::VIP) {
|
||||||
// available riders filter
|
// available riders filter
|
||||||
$hubs_riders = $this->filterHubsByRiderAvailability($filtered_hubs, $flag_riders_check, $jo_type, $jo, $customer_id);
|
$hubs_riders = $this->filterHubsByRiderAvailability($filtered_hubs, $flag_riders_check, $jo_type, $jo, $customer_id);
|
||||||
$filtered_hubs = $hubs_riders;
|
$filtered_hubs = $hubs_riders;
|
||||||
|
|
@ -106,7 +112,9 @@ class HubSelector
|
||||||
// inventory filter
|
// inventory filter
|
||||||
$hubs_inventory = $this->filterHubsByInventory($filtered_hubs, $flag_inventory_check, $jo_type, $items, $jo, $customer_id);
|
$hubs_inventory = $this->filterHubsByInventory($filtered_hubs, $flag_inventory_check, $jo_type, $items, $jo, $customer_id);
|
||||||
$filtered_hubs = $hubs_inventory;
|
$filtered_hubs = $hubs_inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$flag_emergency) {
|
||||||
// round robin filter
|
// round robin filter
|
||||||
$hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin);
|
$hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin);
|
||||||
$filtered_hubs = $hubs_round_robin;
|
$filtered_hubs = $hubs_round_robin;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue