Skip to content

Commit dfb37c9

Browse files
authored
#43 fixed warehouse identification for getCity (#44)
1 parent abc8347 commit dfb37c9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Delivery/NovaPoshtaApi2.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,14 @@ public function getCity($cityName, $areaName = '', $warehouseDescription = '')
581581
if (count($data) > 1 && $warehouseDescription) {
582582
foreach ($data as $cityData) {
583583
$warehouseData = $this->getWarehouse($cityData['Ref'], $warehouseDescription);
584-
if (!$warehouseData) {
584+
$warehouseDescriptions = array(
585+
$warehouseData['data'][0]['Description'],
586+
$warehouseData['data'][0]['DescriptionRu']
587+
);
588+
if (in_array($warehouseDescription, $warehouseDescriptions)) {
589+
$data = array($cityData);
585590
break;
586591
}
587-
$data = array($cityData);
588592
}
589593
}
590594
// Error

tests/NovaPoshtaApi2Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public function testGetDocumentDeliveryDate()
575575
'db5c88d1-391c-11dd-90d9-001a92567626',
576576
'8d5a980d-391c-11dd-90d9-001a92567626',
577577
'WarehouseWarehouse',
578-
date('d.m.Y')
578+
date('d.m.Y', time() + 60 * 60 * 4)
579579
);
580580
$this->assertTrue($result['success']);
581581
}

0 commit comments

Comments
 (0)