From 8d97a41e7b89ea1d77dea6b92daeded873c88c62 Mon Sep 17 00:00:00 2001 From: Jeffrey Branderhorst Date: Tue, 15 Mar 2022 12:57:07 +0100 Subject: [PATCH 01/17] POSTNLM2-1277 - PR request voor het sorteren van de matrix rates - https://github.com/tig-nl/postnl-magento2/issues/293 --- Service/Carrier/Price/Matrixrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Service/Carrier/Price/Matrixrate.php b/Service/Carrier/Price/Matrixrate.php index 23b409a1c..713d4d10c 100644 --- a/Service/Carrier/Price/Matrixrate.php +++ b/Service/Carrier/Price/Matrixrate.php @@ -94,7 +94,7 @@ public function __construct( */ public function getRate(RateRequest $request, $parcelType, $store = null) { - $matrixrateCollection = $this->matrixrateCollection->addOrder('subtotal', 'DESC'); + $matrixrateCollection = $this->matrixrateCollection->addOrder('subtotal', 'DESC')->addOrder('weight', 'DESC'); $this->shippingVatEnabled = $this->taxHelper->shippingPriceIncludesTax($store); $parcelType = $parcelType ?: 'regular'; $collection = $matrixrateCollection->toArray(); From a1ed7bc49dd1e98c7774d2fc8f3873227181387e Mon Sep 17 00:00:00 2001 From: Mickey Beijer Date: Mon, 2 May 2022 12:51:08 +0200 Subject: [PATCH 02/17] POSTNLM2-1292 : bugfix where stated address doesn't always give the right product code for BE addresses --- etc/config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/config.xml b/etc/config.xml index 3c7a6e353..59628184f 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -87,6 +87,7 @@ 4946 4952 3385 + 4960 0 2 From 10a58ac8d86989756d420702b1fb844b88107ce9 Mon Sep 17 00:00:00 2001 From: Kevin van Dijk Date: Thu, 12 May 2022 11:02:40 +0200 Subject: [PATCH 03/17] Magento 2.4.4 and PHP 8.1 support --- Block/Adminhtml/Config/Support/SupportTab.php | 2 +- Helper/Tracking/Mail.php | 4 ++-- Helper/Tracking/Track.php | 4 ++-- Logging/Log.php | 2 +- Service/Pdf/Fpdi.php | 5 ++--- composer.json | 4 ++-- etc/config.xml | 2 +- view/frontend/email/track_and_trace.html | 10 +++++----- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Block/Adminhtml/Config/Support/SupportTab.php b/Block/Adminhtml/Config/Support/SupportTab.php index cf0946ef9..7768ea10b 100644 --- a/Block/Adminhtml/Config/Support/SupportTab.php +++ b/Block/Adminhtml/Config/Support/SupportTab.php @@ -38,7 +38,7 @@ class SupportTab extends Template implements RendererInterface { - const POSTNL_VERSION = '1.12.1'; + const POSTNL_VERSION = '1.12.2'; const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postnl/supported_magento_version'; diff --git a/Helper/Tracking/Mail.php b/Helper/Tracking/Mail.php index 13695b26a..f8fc5473b 100644 --- a/Helper/Tracking/Mail.php +++ b/Helper/Tracking/Mail.php @@ -122,7 +122,7 @@ public function send() try { $this->trackAndTraceEmail->sendMessage(); } catch (MailException $exception) { - $this->logging->addCritical($exception->getLogMessage()); + $this->logging->critical($exception->getLogMessage()); } } @@ -158,7 +158,7 @@ public function set($shipment, $url) $address = $shipment->getShippingAddress(); $transport->addTo($address->getEmail(), $address->getFirstname() . ' ' . $address->getLastname()); $transport = $this->addBccEmail($transport); - $this->logging->addInfo('Track And Trace email build for :' . $address->getEmail()); + $this->logging->info('Track And Trace email build for :' . $address->getEmail()); $this->trackAndTraceEmail = $transport->getTransport(); } // @codingStandardsIgnoreEnd diff --git a/Helper/Tracking/Track.php b/Helper/Tracking/Track.php index c30b81643..b37535981 100644 --- a/Helper/Tracking/Track.php +++ b/Helper/Tracking/Track.php @@ -190,7 +190,7 @@ public function send($shipment) */ private function addTrackingNumbersToShipment($shipment, $trackingNumbers) { - $this->logging->addDebug('Adding trackingnumbers to shipment_id : '. $shipment->getId(), $trackingNumbers); + $this->logging->debug('Adding trackingnumbers to shipment_id : '. $shipment->getId(), $trackingNumbers); $shipment = $this->resetTrackingKey($shipment); foreach ($trackingNumbers as $number) { @@ -217,7 +217,7 @@ private function addTrackingNumbersToShipment($shipment, $trackingNumbers) private function addReturnTrackingNumbersToShipment($postNLShipment) { $shipment = $postNLShipment->getShipment(); - $this->logging->addDebug('Adding return trackingnumbers to shipment_id : '. $shipment->getId()); + $this->logging->debug('Adding return trackingnumbers to shipment_id : '. $shipment->getId()); $returnItems = $this->getList($postNLShipment); foreach ($returnItems as $item) { diff --git a/Logging/Log.php b/Logging/Log.php index 8579b9593..7e5eb0bef 100644 --- a/Logging/Log.php +++ b/Logging/Log.php @@ -64,7 +64,7 @@ public function __construct( * * @return bool */ - public function addRecord($level, $message, array $context = []) + public function addRecord($level, $message, array $context = []):bool { if (!$this->logConfig->canLog($level)) { return false; diff --git a/Service/Pdf/Fpdi.php b/Service/Pdf/Fpdi.php index 0e714f3da..20c52aca3 100644 --- a/Service/Pdf/Fpdi.php +++ b/Service/Pdf/Fpdi.php @@ -172,9 +172,7 @@ protected function _endpage() */ public function concatPdf($pdfToConcat, $size = Fpdi::PAGE_SIZE_A6) { - $filename = $this->file->save($pdfToConcat->Output('S')); - - $pages = $this->setSourceFile($filename); + $pages = $pdfToConcat->PageNo(); for ($page = 1; $page <= $pages; $page++) { $this->AddPage('P', $size); @@ -182,6 +180,7 @@ public function concatPdf($pdfToConcat, $size = Fpdi::PAGE_SIZE_A6) $this->useTemplate($pageId); } + $filename = $this->file->save($pdfToConcat->Output('S')); $this->file->cleanup(); } } diff --git a/composer.json b/composer.json index 9161288b7..f444904b8 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "tig/postnl-magento2", "description": "TIG Magento 2 PostNL extension", "require": { - "php": "~7.0|~7.1|~7.2|~7.3|~7.4", + "php": "~7.0|~7.1|~7.2|~7.3|~7.4|~8.1", "ext-soap": "*", "magento/framework": "~102.0|~103.0", "setasign/fpdf": "^1.8.2", @@ -11,7 +11,7 @@ }, "type": "magento2-module", "license": "CC-BY-NC-ND-3.0", - "version": "1.12.1", + "version": "1.12.2", "authors": [ { "name": "TIG", diff --git a/etc/config.xml b/etc/config.xml index 3c7a6e353..21e217fc0 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -47,7 +47,7 @@ - 2.3.5 - 2.3.7-p2, 2.4.0 - 2.4.3-p1 + 2.3.5 - 2.3.7-p3, 2.4.0 - 2.4.4 0 diff --git a/view/frontend/email/track_and_trace.html b/view/frontend/email/track_and_trace.html index e86ed4cf3..1c24a5d47 100644 --- a/view/frontend/email/track_and_trace.html +++ b/view/frontend/email/track_and_trace.html @@ -33,10 +33,10 @@

  • - {{trans "Order"}} {{var order.getIncrementId()}}
    - {{var DateAndTime}} + {{trans "Order"}} {{var order.increment_id}}
    + {{var dateAndTime}}
  • - {{if postnlShipment.getPostNLOrder().getDeliveryDate()}} + {{if delivery_date}}
  • {{trans "Expected Delivery"}}
    {{var delivery_date}} @@ -55,10 +55,10 @@

    - {{var shippingAddress.getCity()}} {{var shippingAddress.getPostcode()}} + {{var shippingAddress.city}} {{var shippingAddress.postcode}}

  • - {{var shippingAddress.getCountryId()}} + {{var shippingAddress.country_id}}
  • From c7ea78bc68eef644c99c50c3d28c9f07bc4fcf8a Mon Sep 17 00:00:00 2001 From: Michiel Vonk Date: Mon, 16 May 2022 14:50:26 +0200 Subject: [PATCH 04/17] Globalpack postcode str is null fixes + concat fix --- Helper/AbstractTracking.php | 2 +- Service/Pdf/Fpdi.php | 5 +++-- Service/Shipment/Label/Merge.php | 2 +- Webservices/Parser/Label/Shipments.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Helper/AbstractTracking.php b/Helper/AbstractTracking.php index e1447db60..f860f2208 100644 --- a/Helper/AbstractTracking.php +++ b/Helper/AbstractTracking.php @@ -204,7 +204,7 @@ protected function generateTrackAndTraceUrl(OrderAddressInterface $address, $tra $params = [ 'B' => $trackingNumber, 'D' => $address->getCountryId(), - 'P' => str_replace(' ', '', $address->getPostcode()), + 'P' => str_replace(' ', '', $address->getPostcode() ?? ''), 'T' => $type, 'L' => $language ]; diff --git a/Service/Pdf/Fpdi.php b/Service/Pdf/Fpdi.php index 20c52aca3..0e714f3da 100644 --- a/Service/Pdf/Fpdi.php +++ b/Service/Pdf/Fpdi.php @@ -172,7 +172,9 @@ protected function _endpage() */ public function concatPdf($pdfToConcat, $size = Fpdi::PAGE_SIZE_A6) { - $pages = $pdfToConcat->PageNo(); + $filename = $this->file->save($pdfToConcat->Output('S')); + + $pages = $this->setSourceFile($filename); for ($page = 1; $page <= $pages; $page++) { $this->AddPage('P', $size); @@ -180,7 +182,6 @@ public function concatPdf($pdfToConcat, $size = Fpdi::PAGE_SIZE_A6) $this->useTemplate($pageId); } - $filename = $this->file->save($pdfToConcat->Output('S')); $this->file->cleanup(); } } diff --git a/Service/Shipment/Label/Merge.php b/Service/Shipment/Label/Merge.php index b05e493eb..3e5e0632d 100644 --- a/Service/Shipment/Label/Merge.php +++ b/Service/Shipment/Label/Merge.php @@ -116,7 +116,7 @@ private function mergeA6Labels($labels, $createNewPdf) * therefore check if there are A6 labels to merge. */ if (!empty($a6Labels)) { - $a6result = $this->a6Merger->files($a6Labels, $createNewPdf); + $a6result = $this->a6Merger->files($a6Labels, true); $a4result->concatPdf($a6result); } diff --git a/Webservices/Parser/Label/Shipments.php b/Webservices/Parser/Label/Shipments.php index 957376f67..14d94d16f 100644 --- a/Webservices/Parser/Label/Shipments.php +++ b/Webservices/Parser/Label/Shipments.php @@ -141,7 +141,7 @@ private function getAddressData($shippingAddress, $addressType = '01') 'Street' => $streetData['street'][0], 'HouseNr' => $houseNr, 'HouseNrExt' => $houseNrExt, - 'Zipcode' => strtoupper(str_replace(' ', '', $shippingAddress->getPostcode())), + 'Zipcode' => strtoupper(str_replace(' ', '', $shippingAddress->getPostcode() ?? '')), 'City' => $shippingAddress->getCity(), 'Region' => $shippingAddress->getRegion(), 'Countrycode' => $shippingAddress->getCountryId(), From ac812b15e0b1005f19a038f118698f43464268ac Mon Sep 17 00:00:00 2001 From: Michiel Vonk Date: Mon, 16 May 2022 15:15:58 +0200 Subject: [PATCH 05/17] Changed tags for compability with JQuery Migrate --- .../web/template/billing-address/details.html | 14 ++++----- .../address-renderer/default.html | 14 ++++----- .../address-renderer/default.html | 14 ++++----- view/frontend/web/template/shipping.html | 30 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/view/frontend/web/template/billing-address/details.html b/view/frontend/web/template/billing-address/details.html index 05cf5af30..a3d4c7b10 100644 --- a/view/frontend/web/template/billing-address/details.html +++ b/view/frontend/web/template/billing-address/details.html @@ -5,17 +5,17 @@ */ -->
    - -
    - -
    - ,
    -
    + +
    + +
    + ,
    +

    - +
    diff --git a/view/frontend/web/template/shipping-address/address-renderer/default.html b/view/frontend/web/template/shipping-address/address-renderer/default.html index f415bac71..0d4f377a8 100644 --- a/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -5,21 +5,21 @@ */ -->
    - -
    - + +
    +
    - +

    - ,
    -
    + ,
    +

    - +
    diff --git a/view/frontend/web/template/shipping-information/address-renderer/default.html b/view/frontend/web/template/shipping-information/address-renderer/default.html index 08b00e1cc..ad5a19966 100644 --- a/view/frontend/web/template/shipping-information/address-renderer/default.html +++ b/view/frontend/web/template/shipping-information/address-renderer/default.html @@ -5,21 +5,21 @@ */ --> - -
    - + +
    + - +
    - ,
    -
    + ,
    +

    - +
    diff --git a/view/frontend/web/template/shipping.html b/view/frontend/web/template/shipping.html index de5bca09e..a51a93cdf 100644 --- a/view/frontend/web/template/shipping.html +++ b/view/frontend/web/template/shipping.html @@ -8,14 +8,14 @@ */ -->
  • -
    +
    - - - + + + @@ -23,17 +23,17 @@ class="action action-show-popup" click="showFormPopUp" visible="!isNewAddressAdded()"> - +
    + render="shippingFormTemplate">
    - + - +
  • @@ -45,9 +45,9 @@
    + data-role="title">
    - +
    - +
    - +
    + translate="'Sorry, no quotes are available for this order at this time'">
    From 6d455c3bc56e2646d9e22e35854a04116b4f6a21 Mon Sep 17 00:00:00 2001 From: Michiel Vonk Date: Tue, 17 May 2022 12:45:39 +0200 Subject: [PATCH 06/17] Fixed PHPStan return issues --- Block/Adminhtml/Grid/AbstractGrid.php | 3 +- Config/Provider/ShippingOptions.php | 4 +- Controller/Adminhtml/LabelAbstract.php | 2 +- .../Adminhtml/Order/CreateShipments.php | 5 +++ Model/ResourceModel/Tablerate.php | 1 + Service/Shipment/Label/SizeInterface.php | 40 ------------------- .../Shipment/Labelling/GenerateAbstract.php | 2 +- Service/Shipment/ResetPostNLShipment.php | 5 +++ Service/Validation/Factory.php | 3 +- Setup/Patch/Data/ResetBEDefaultOption.php | 2 + .../UpdateDisableDeliveryDaysAttribute.php | 2 + Webservices/Api/Exception.php | 7 +++- .../Endpoints/Address/RestInterface.php | 2 +- Webservices/Endpoints/Barcode.php | 2 + Webservices/ExceptionHandler.php | 2 +- 15 files changed, 32 insertions(+), 50 deletions(-) delete mode 100644 Service/Shipment/Label/SizeInterface.php diff --git a/Block/Adminhtml/Grid/AbstractGrid.php b/Block/Adminhtml/Grid/AbstractGrid.php index 074cc5e43..f84a7a5f1 100644 --- a/Block/Adminhtml/Grid/AbstractGrid.php +++ b/Block/Adminhtml/Grid/AbstractGrid.php @@ -69,8 +69,9 @@ protected function prepareData() return null; } + /** - * @return array + * @return void */ // @codingStandardsIgnoreLine protected function handleItems() diff --git a/Config/Provider/ShippingOptions.php b/Config/Provider/ShippingOptions.php index 8fda4d7f4..d4115ebe2 100644 --- a/Config/Provider/ShippingOptions.php +++ b/Config/Provider/ShippingOptions.php @@ -276,9 +276,7 @@ public function isLetterboxPackageActive() */ public function canUseBeProducts() { - if ($this->getConfigFromXpath(self::XPATH_SHIPPING_OPTION_COUNTRY) === 'BE') { - return true; - } + return $this->getConfigFromXpath(self::XPATH_SHIPPING_OPTION_COUNTRY) === 'BE'; } } /** diff --git a/Controller/Adminhtml/LabelAbstract.php b/Controller/Adminhtml/LabelAbstract.php index b6ed0c402..8485baf3c 100644 --- a/Controller/Adminhtml/LabelAbstract.php +++ b/Controller/Adminhtml/LabelAbstract.php @@ -36,7 +36,7 @@ use TIG\PostNL\Service\Shipment\Labelling\GetLabels; use TIG\PostNL\Service\Shipment\Packingslip\GetPackingslip; -use TIG\PostNL\Controller\AdminHtml\PdfDownload as GetPdf; +use TIG\PostNL\Controller\Adminhtml\PdfDownload as GetPdf; use TIG\PostNL\Service\Handler\BarcodeHandler; use TIG\PostNL\Helper\Tracking\Track; use \Magento\Sales\Model\Order\Shipment; diff --git a/Controller/Adminhtml/Order/CreateShipments.php b/Controller/Adminhtml/Order/CreateShipments.php index d7f872585..b09cb632e 100644 --- a/Controller/Adminhtml/Order/CreateShipments.php +++ b/Controller/Adminhtml/Order/CreateShipments.php @@ -74,6 +74,11 @@ class CreateShipments extends Action */ private $errors = []; + /** + * @var OrderCollectionFactory + */ + private $collectionFactory; + /** * @param Context $context * @param Filter $filter diff --git a/Model/ResourceModel/Tablerate.php b/Model/ResourceModel/Tablerate.php index e4e449b88..99f068dd4 100644 --- a/Model/ResourceModel/Tablerate.php +++ b/Model/ResourceModel/Tablerate.php @@ -147,6 +147,7 @@ public function uploadAndImport(DataObject $object, $importData) $this->logger->critical($exception); throw new PostnlException(__('An error occurred while importing the table rates.'), 'POSTNL-0251'); } + return $this; } /** diff --git a/Service/Shipment/Label/SizeInterface.php b/Service/Shipment/Label/SizeInterface.php deleted file mode 100644 index 786a11a1c..000000000 --- a/Service/Shipment/Label/SizeInterface.php +++ /dev/null @@ -1,40 +0,0 @@ -ResponseShipment)) { - throw new PostNLException(sprintf('Invalid generateLabel response: %1', var_export($response, true))); + throw new PostNLException(sprintf('Invalid generateLabel response: %s', var_export($response, true))); } return $responseShipments->ResponseShipment; diff --git a/Service/Shipment/ResetPostNLShipment.php b/Service/Shipment/ResetPostNLShipment.php index 0e8ce0861..9fd7fffb8 100644 --- a/Service/Shipment/ResetPostNLShipment.php +++ b/Service/Shipment/ResetPostNLShipment.php @@ -60,6 +60,11 @@ class ResetPostNLShipment */ private $shipmentRepository; + /** + * @var ShipmentService + */ + private $shipmentService; + /** * @param DeleteLabel $labelDeleteHandler * @param DeleteBarcode $barcodeDeleteHandler diff --git a/Service/Validation/Factory.php b/Service/Validation/Factory.php index a7de87f26..c72bc4425 100644 --- a/Service/Validation/Factory.php +++ b/Service/Validation/Factory.php @@ -91,7 +91,7 @@ public function validate($type, $value) * @param $type * @param $value * - * @return bool + * @return bool|null */ private function callValidator($type, $value) { @@ -114,6 +114,7 @@ private function callValidator($type, $value) case 'duplicate-import': return $this->validators['duplicateImport']->validate($value); } + return null; } /** diff --git a/Setup/Patch/Data/ResetBEDefaultOption.php b/Setup/Patch/Data/ResetBEDefaultOption.php index 5c2c86b73..8812dd42a 100644 --- a/Setup/Patch/Data/ResetBEDefaultOption.php +++ b/Setup/Patch/Data/ResetBEDefaultOption.php @@ -109,5 +109,7 @@ public function apply() ); } }); + + return $this; } } diff --git a/Setup/Patch/Data/UpdateDisableDeliveryDaysAttribute.php b/Setup/Patch/Data/UpdateDisableDeliveryDaysAttribute.php index 84a8db5ef..526e58f81 100644 --- a/Setup/Patch/Data/UpdateDisableDeliveryDaysAttribute.php +++ b/Setup/Patch/Data/UpdateDisableDeliveryDaysAttribute.php @@ -88,5 +88,7 @@ public function apply() /** @var EavSetup $eavSetup */ $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); $eavSetup->updateAttribute(Product::ENTITY, 'postnl_disable_delivery_days', 'default_value', 0); + + return $this; } } diff --git a/Webservices/Api/Exception.php b/Webservices/Api/Exception.php index 68bc9bbcc..bbd3b17c8 100644 --- a/Webservices/Api/Exception.php +++ b/Webservices/Api/Exception.php @@ -78,6 +78,8 @@ public function changeRequestXml($xml) { $this->requestXml = $xml; $this->composeMessage(); + + return $this; } /** @@ -90,6 +92,8 @@ public function changeResponseXml($xml) { $this->responseXml = $xml; $this->composeMessage(); + + return $this; } /** @@ -143,8 +147,9 @@ private function composeMessage() /** * @param $message + * @param $xml * - * @return string + * @return void */ private function addXml($message, $xml) { diff --git a/Webservices/Endpoints/Address/RestInterface.php b/Webservices/Endpoints/Address/RestInterface.php index 95438a414..dc71b9aed 100644 --- a/Webservices/Endpoints/Address/RestInterface.php +++ b/Webservices/Endpoints/Address/RestInterface.php @@ -46,7 +46,7 @@ public function getEndpoint(); /** * @param array $data * - * @return array + * @return void */ public function updateRequestData(array $data); diff --git a/Webservices/Endpoints/Barcode.php b/Webservices/Endpoints/Barcode.php index 1e2d485c3..11c38377a 100644 --- a/Webservices/Endpoints/Barcode.php +++ b/Webservices/Endpoints/Barcode.php @@ -169,6 +169,8 @@ public function getLocation() public function changeProductCode($productCode) { $this->productCode = $productCode; + + return $this; } /** diff --git a/Webservices/ExceptionHandler.php b/Webservices/ExceptionHandler.php index 432dbfe5f..a72632954 100644 --- a/Webservices/ExceptionHandler.php +++ b/Webservices/ExceptionHandler.php @@ -135,7 +135,7 @@ private function addCifErrorsToException() } /** - * @return Api\Exception + * @return void */ private function prepareException(Client $client) { From b0d069e623d300b09fd9b25117dc15feaed9410c Mon Sep 17 00:00:00 2001 From: Michiel Vonk Date: Tue, 31 May 2022 14:13:24 +0200 Subject: [PATCH 07/17] POSTNLM2-1318 POSTNLM2-1317 Fixed toolbar template --- view/base/web/template/grid/toolbar.html | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/view/base/web/template/grid/toolbar.html b/view/base/web/template/grid/toolbar.html index 7f9c4ad7b..b9e7cd231 100644 --- a/view/base/web/template/grid/toolbar.html +++ b/view/base/web/template/grid/toolbar.html @@ -6,20 +6,19 @@ -->
    -
    - +
    +
    -
    +
    -
    -
    +
    +
    -
    @@ -30,7 +29,7 @@
    + data-bind="visible: $data.currentSelected() == 'change_parcel'">