diff --git a/.travis.yml b/.travis.yml
index d652a08d7..fb3b0bf5a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,20 +19,20 @@ matrix:
# PHP 7.1 is only supported in Magento 2.2.x
# PHP 7.2 is only supported in Magento 2.3.x
include:
- - php: 7.0
- env: MAGENTO_VERSION=2.1.16
- php: 7.0
env: MAGENTO_VERSION=2.1.17
- php: 7.0
- env: MAGENTO_VERSION=2.2.7
- - php: 7.1
+ env: MAGENTO_VERSION=2.1.18
+ - php: 7.0
env: MAGENTO_VERSION=2.2.8
- php: 7.1
- env: MAGENTO_VERSION=2.3.0
+ env: MAGENTO_VERSION=2.2.9
- php: 7.1
- env: MAGENTO_VERSION=2.3.1 # DI_COMPILE=true
+ env: MAGENTO_VERSION=2.3.1
+ - php: 7.2
+ env: MAGENTO_VERSION=2.3.2 # DI_COMPILE=true
- php: 7.2
- env: MAGENTO_VERSION=2.3.1 CODE_COVERAGE=true
+ env: MAGENTO_VERSION=2.3.2 CODE_COVERAGE=true
before_script:
- export PATH=$PATH:$HOME/.composer/vendor/bin
diff --git a/Controller/Adminhtml/PdfDownload.php b/Controller/Adminhtml/PdfDownload.php
index d453068fc..98ea2bfcd 100644
--- a/Controller/Adminhtml/PdfDownload.php
+++ b/Controller/Adminhtml/PdfDownload.php
@@ -154,6 +154,11 @@ public function get($labels, $filename = 'ShippingLabels')
private function filterLabel($labels)
{
return array_filter($labels, function ($label) {
+
+ if (is_array($label)) {
+ return false;
+ }
+
/** @var ShipmentLabelInterface $label */
if (strtoupper($label->getType()) == ProductInfo::SHIPMENT_TYPE_GP) {
$this->filteredLabels[] = $label->getParentId();
diff --git a/Helper/DeliveryOptions/OrderParams.php b/Helper/DeliveryOptions/OrderParams.php
index 0d2399fdd..0408d04a9 100644
--- a/Helper/DeliveryOptions/OrderParams.php
+++ b/Helper/DeliveryOptions/OrderParams.php
@@ -239,13 +239,13 @@ private function addExtraToAddress($params)
$params['address']['Name'] = isset($params['name']) ? $params['name'] : '';
- if (!isset($params['customerData'])) {
+ if ($params['type'] == ProductInfo::TYPE_PICKUP && !isset($params['customerData'])) {
throw new PostnlException(
__('Missing required parameters: customerData')
);
}
- $params['address']['customer'] = $params['customerData'];
+ $params['address']['customer'] = isset($params['customerData']) ? $params['customerData'] : $params['address'];
return $params['address'];
}
diff --git a/Service/Shipment/Label/Validator.php b/Service/Shipment/Label/Validator.php
index 288d373cd..297785ae2 100644
--- a/Service/Shipment/Label/Validator.php
+++ b/Service/Shipment/Label/Validator.php
@@ -52,6 +52,11 @@ class Validator
* @var array
*/
private $errors = [];
+
+ /**
+ * @var bool
+ */
+ private $priorityError = false;
/**
* Validator constructor.
@@ -165,9 +170,10 @@ private function validatePriority(ShipmentInterface $shipment)
}
/** We want to show this notification for every Priority Shipment */
- if ($isPriority) {
+ if ($isPriority && $this->priorityError == false) {
// @codingStandardsIgnoreLine
$this->errors[] = __('Tracked Parcels can only be used if 5 packages or more are delivered in a domestic mail bag with an attached bag label specific for priority parcels.');
+ $this->priorityError = true;
}
return true;
diff --git a/Service/Shipment/Packingslip/MergeWithLabels.php b/Service/Shipment/Packingslip/MergeWithLabels.php
index dd85691ef..5634b3d5e 100644
--- a/Service/Shipment/Packingslip/MergeWithLabels.php
+++ b/Service/Shipment/Packingslip/MergeWithLabels.php
@@ -126,7 +126,7 @@ public function merge($shipmentId, $packingslip, $mergeFirstLabel = false, $conf
return $packingslip;
}
- if (isset($labels['errors'])) {
+ if (isset($labels['errors']) && count($labels['errors']) > 0) {
return $labels['errors'];
}
diff --git a/Service/Timeframe/Options.php b/Service/Timeframe/Options.php
index 2e4157aa8..f33664a83 100644
--- a/Service/Timeframe/Options.php
+++ b/Service/Timeframe/Options.php
@@ -84,7 +84,9 @@ public function get($countryId = 'NL')
$deliveryTimeframesOptions[] = self::EVENING_DELIVERY_OPTION;
}
- if ($this->shippingOptions->isSundayDeliveryActive() && $this->hasSaturdayAsShippingDay()) {
+ // Sunday Delivery is only available for the Netherlands
+ if ($this->shippingOptions->isSundayDeliveryActive()
+ && $this->hasSaturdayAsShippingDay() && $countryId == 'NL') {
$deliveryTimeframesOptions[] = self::SUNDAY_DELIVERY_OPTION;
}
diff --git a/Test/Unit/Webservices/Endpoints/SentDateTest.php b/Test/Unit/Webservices/Endpoints/SentDateTest.php
index f0ab00e2a..4f31aa169 100644
--- a/Test/Unit/Webservices/Endpoints/SentDateTest.php
+++ b/Test/Unit/Webservices/Endpoints/SentDateTest.php
@@ -29,6 +29,7 @@
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
+
namespace TIG\PostNL\Test\Unit\Webservices\Endpoints;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
@@ -62,7 +63,7 @@ public function theParametersAreSetCorrectlyProvider()
['country' => 'DE', 'postcode' => '10179', 'delivery_date' => null],
['country' => 'NL', 'postcode' => '2132WT', 'delivery_date' => '19-11-2016'],
],
- 'Reverse date' => [
+ 'Reverse date' => [
['country' => 'NL', 'postcode' => '1014 BA', 'delivery_date' => '2016-11-19'],
['country' => 'NL', 'postcode' => '1014BA', 'delivery_date' => '19-11-2016'],
],
@@ -89,10 +90,12 @@ public function testTheParametersAreSetCorrectly($input, $expected)
$orderMock = $this->getMock(OrderInterface::class);
$this->mockFunction($orderMock, 'getDeliveryDate', $input['delivery_date']);
- $falbackMock = $this->deliveryDateFallbackMock();
+ $fallbackMock = $this->deliveryDateFallbackMock();
+ $optionsMock = $this->optionsMock();
$instance = $this->getInstance([
- 'dateFallback' => $falbackMock
+ 'dateFallback' => $fallbackMock,
+ 'timeframeOptions' => $optionsMock
]);
$instance->setParameters($address, 1, $orderMock);
@@ -103,20 +106,32 @@ public function testTheParametersAreSetCorrectly($input, $expected)
$this->assertEquals($expected['delivery_date'], $result['GetSentDate']['DeliveryDate']);
}
+ /**
+ * @return \PHPUnit_Framework_MockObject_MockObject
+ */
+ private function optionsMock()
+ {
+ $optionsMock = $this->getFakeMock(\TIG\PostNL\Service\Timeframe\Options::class)->getMock();
+ $optionsExpected = $optionsMock->expects($this->any());
+ $optionsExpected->method('get');
+ $optionsExpected->willReturn(['Daytime']);
+
+ return $optionsMock;
+ }
+
/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
private function deliveryDateFallbackMock()
{
$fallbackMock = $this->getFakeMock(DeliveryDateFallback::class)->getMock();
- $getFalback = $fallbackMock->expects($this->any());
- $getFalback->method('get');
- $getFalback->willReturn('19-11-2016');
-
- $getFalback2 = $fallbackMock->expects($this->any());
- $getFalback2->method('getDate');
- $getFalback2->willReturn('19-11-2016');
+ $getFallback = $fallbackMock->expects($this->any());
+ $getFallback->method('get');
+ $getFallback->willReturn('19-11-2016');
+ $getFallback2 = $fallbackMock->expects($this->any());
+ $getFallback2->method('getDate');
+ $getFallback2->willReturn('19-11-2016');
return $fallbackMock;
}
diff --git a/Webservices/Endpoints/SentDate.php b/Webservices/Endpoints/SentDate.php
index d933d027a..2b2539d44 100644
--- a/Webservices/Endpoints/SentDate.php
+++ b/Webservices/Endpoints/SentDate.php
@@ -34,6 +34,7 @@
use Magento\Customer\Model\Address\AbstractAddress as Address;
use TIG\PostNL\Api\Data\OrderInterface as PostNLOrder;
+use TIG\PostNL\Service\Order\ProductInfo;
use TIG\PostNL\Service\Timeframe\Options;
use TIG\PostNL\Webservices\AbstractEndpoint;
use TIG\PostNL\Webservices\Api\Message;
@@ -158,12 +159,36 @@ public function setParameters($address, $storeId, PostNLOrder $postNLOrder)
'DeliveryDate' => $this->getDeliveryDate($address, $postNLOrder),
'ShippingDuration' => '1', // Request by PostNL not to use $postNLOrder->getShippingDuration()
'AllowSundaySorting' => $this->timeframeOptions->isSundaySortingAllowed(),
- 'Options' => $this->timeframeOptions->get($this->getCountryId())
+ 'Options' => [$this->getOption($postNLOrder)]
],
'Message' => $this->message
];
}
+ /**
+ * GetSentDate 2.2 doesn't support multiple options for requests. That's why we send
+ * along the option actually selected.
+ *
+ * @param PostNLOrder $postNLOrder
+ *
+ * @return string
+ */
+ private function getOption(PostNLOrder $postNLOrder)
+ {
+ $availableOptions = $this->timeframeOptions->get($this->getCountryId());
+ $currentType = $postNLOrder->getType();
+
+ if (in_array($currentType, $availableOptions)) {
+ return $currentType;
+ }
+
+ if ($currentType == ProductInfo::SHIPMENT_TYPE_PG) {
+ return ucfirst(ProductInfo::TYPE_PICKUP);
+ }
+
+ return ProductInfo::SHIPMENT_TYPE_DAYTIME;
+ }
+
/**
* This endpoint is only available for dutch addresses.
*
diff --git a/composer.json b/composer.json
index 2b2074e40..bbb225ee2 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"require": {
"php": "~7.0|~7.1|~7.2",
"ext-soap": "*",
- "magento/framework": ">=100.1.0,<=100.1.17|>=101.0.0,<=101.0.8|>=102.0.0,<=102.0.1",
+ "magento/framework": ">=100.1.0,<=100.1.18|>=101.0.0,<=101.0.9|>=102.0.0,<=102.0.2",
"setasign/fpdi-fpdf": "2.1",
"zendframework/zend-barcode" : "2.5.2|2.7"
},
diff --git a/etc/adminhtml/system/postnlsettings.xml b/etc/adminhtml/system/postnlsettings.xml
index 94a4c3f93..8524e670a 100644
--- a/etc/adminhtml/system/postnlsettings.xml
+++ b/etc/adminhtml/system/postnlsettings.xml
@@ -203,7 +203,8 @@
-
+
+