Update function name. Add checking for empty response in getBranchesInventory. #374
This commit is contained in:
parent
eb5710b846
commit
6c02c30370
2 changed files with 14 additions and 9 deletions
|
|
@ -1150,15 +1150,13 @@ class JobOrderController extends Controller
|
||||||
// api call to check inventory
|
// api call to check inventory
|
||||||
// pass the list of branch codes of nearest hubs and the skus
|
// pass the list of branch codes of nearest hubs and the skus
|
||||||
// go through returned list of branch codes
|
// go through returned list of branch codes
|
||||||
$hubs_with_inventory = $im->getBranchInventory($nearest_branch_codes, $skus);
|
$hubs_with_inventory = $im->getBranchesInventory($nearest_branch_codes, $skus);
|
||||||
// TODO: check for empty result for now.
|
|
||||||
if (!empty($hubs_with_inventory))
|
if (!empty($hubs_with_inventory))
|
||||||
{
|
{
|
||||||
$nearest = [];
|
$nearest = [];
|
||||||
$flag_hub_found = false;
|
$flag_hub_found = false;
|
||||||
foreach ($hubs_with_inventory as $hub_with_inventory)
|
foreach ($hubs_with_inventory as $hub_with_inventory)
|
||||||
{
|
{
|
||||||
error_log($hub_with_inventory['BranchCode']);
|
|
||||||
// find hub according to branch code
|
// find hub according to branch code
|
||||||
$found_hub = $em->getRepository(Hub::class)->findOneBy(['branch_code' => $hub_with_inventory['BranchCode']]);
|
$found_hub = $em->getRepository(Hub::class)->findOneBy(['branch_code' => $hub_with_inventory['BranchCode']]);
|
||||||
if ($found_hub != null)
|
if ($found_hub != null)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class InventoryManager
|
||||||
$this->api_auth_token = $api_auth_token;
|
$this->api_auth_token = $api_auth_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBranchInventory($nearest_branch_codes, $skus)
|
public function getBranchesInventory($nearest_branch_codes, $skus)
|
||||||
{
|
{
|
||||||
// api call to check inventory
|
// api call to check inventory
|
||||||
// pass the list of branch codes and the skus
|
// pass the list of branch codes and the skus
|
||||||
|
|
@ -60,11 +60,18 @@ class InventoryManager
|
||||||
|
|
||||||
// response is array of these
|
// response is array of these
|
||||||
// {
|
// {
|
||||||
// "BranchCode": "TestBranch1",
|
// "Id": 37,
|
||||||
// "BranchName": "Test Branch",
|
// "BranchCode": "WestAve",
|
||||||
|
// "BranchName": "West ave. Branch",
|
||||||
|
// "BranchRole": 0,
|
||||||
|
// "Name": "3SMF / GOLD ",
|
||||||
// "SapCode": "WMGD31EL-CPNM0-L",
|
// "SapCode": "WMGD31EL-CPNM0-L",
|
||||||
// "Quantity": 4
|
// "Quantity": 38
|
||||||
// },
|
// }
|
||||||
|
|
||||||
|
// check if the response is empty
|
||||||
|
$results = [];
|
||||||
|
if (!empty($response))
|
||||||
$results = json_decode($response, true);
|
$results = json_decode($response, true);
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue