Skip to content

Commit

Permalink
merge develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-rikjonkmans committed Jan 9, 2018
2 parents dea3652 + b2b5815 commit bf27cbf
Show file tree
Hide file tree
Showing 81 changed files with 1,586 additions and 383 deletions.
31 changes: 19 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,30 @@ env:
global:
- CODE_COVERAGE=false

# We have decided to only test the latest two of each major releases.
matrix:
- MAGENTO_VERSION=2.1.0
- MAGENTO_VERSION=2.1.1
- MAGENTO_VERSION=2.1.2
- MAGENTO_VERSION=2.1.3
# - MAGENTO_VERSION=2.1.4 # Skipping 2.1.4 as 2.1.5 = 2.1.4 + copyright updates
- MAGENTO_VERSION=2.1.5
- MAGENTO_VERSION=2.1.6
- MAGENTO_VERSION=2.1.7
- MAGENTO_VERSION=2.1.8
- MAGENTO_VERSION=2.1.9
- MAGENTO_VERSION=2.2.0
# - MAGENTO_VERSION=2.1.0
# - MAGENTO_VERSION=2.1.1
# - MAGENTO_VERSION=2.1.2
# - MAGENTO_VERSION=2.1.3
# - MAGENTO_VERSION=2.1.4
# - MAGENTO_VERSION=2.1.5
# - MAGENTO_VERSION=2.1.6
# - MAGENTO_VERSION=2.1.7
# - MAGENTO_VERSION=2.1.8
# - MAGENTO_VERSION=2.1.9
- MAGENTO_VERSION=2.1.10
- MAGENTO_VERSION=2.1.11
# - MAGENTO_VERSION=2.2.0
- MAGENTO_VERSION=2.2.1
- MAGENTO_VERSION=2.2.2

matrix:
# PHP 7.1 would be supported in Magento since Magento 2.2
# And there wouldn't be support of PHP 7.1 in Magento 2.0 or 2.1
include:
- php: 7.1
env: MAGENTO_VERSION=2.2.0 CODE_COVERAGE=true
env: MAGENTO_VERSION=2.2.2 CODE_COVERAGE=true

before_script:
- export PATH=$PATH:$HOME/.composer/vendor/bin
Expand Down
5 changes: 5 additions & 0 deletions Api/Data/ShipmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,9 @@ public function getExtraCoverAmount();
* @return \Magento\Sales\Api\Data\ShipmentInterface
*/
public function getShipment();

/**
* @return bool
*/
public function canChangeParcelCount();
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Grid/Order/ShipmentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function getCellContents($item)
}

if ($order->getProductCode()) {
$output = $this->shipmentType->render($order->getType());
$output = $this->shipmentType->render($order->getProductCode(), $order->getType());
}

return $output;
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Grid/Shipment/ShipmentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function getCellContents($item)
}

if ($shipment->getShipmentType()) {
return $this->codeRenderer->render($shipment->getShipmentType());
return $this->codeRenderer->render($shipment->getProductCode(), $shipment->getShipmentType());
}

return '';
Expand Down
50 changes: 3 additions & 47 deletions Block/Adminhtml/Renderer/ShipmentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,14 @@ public function __construct(
}

/**
* @param $type
*
* @return array
*/
// @codingStandardsIgnoreStart
private function getLabel($type)
{
$label = '';
$comment = '';

switch ($type) {
case 'Daytime':
$label = __('Domestic');
break;
case 'Evening':
$label = __('Domestic');
$comment = __('Evening');
break;
case 'ExtraAtHome':
case 'Extra@Home':
$label = __('Extra@Home');
break;
case 'Sunday':
$label = __('Sunday');
break;
case 'PG':
$label = __('Post office');
break;
case 'PGE':
$label = __('Post office');
$comment = __('Early morning pickup');
break;
case 'EPS':
$label = __('EPS');
break;
}

return [
'label' => $label,
'comment' => $comment,
];
}
// @codingStandardsIgnoreStop

/**
* @param $code
* @param $type
*
* @return string
*/
public function render($type)
public function render($code, $type)
{
$type = $this->getLabel($type);
$type = $this->productOptions->getLabel($code, $type);
$output = (string)$type['label'];

if ($type['comment']) {
Expand Down
28 changes: 26 additions & 2 deletions Block/Adminhtml/Shipment/Options/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
use Magento\Sales\Model\OrderRepository;
use TIG\PostNL\Api\Data\ShipmentInterface;
use TIG\PostNL\Block\Adminhtml\Shipment\OptionsAbstract;
use TIG\PostNL\Config\Provider\ProductOptions;
use TIG\PostNL\Config\Source\Options\ProductOptions as ProductOptionSource;
Expand All @@ -53,6 +54,11 @@ class View extends OptionsAbstract
*/
private $productCodeRenderer;

/**
* @var ShipmentInterface
*/
private $shipment;

/**
* @param Context $context
* @param ProductOptions $productOptions
Expand Down Expand Up @@ -93,14 +99,32 @@ public function getProductOptionValue()
{
/** @var PostNLShipment $postNLShipment */
$postNLShipment = $this->getPostNLShipment();
return $this->productCodeRenderer->render($postNLShipment->getProductCode(), false);
return $this->productCodeRenderer->render(
$postNLShipment->getProductCode(),
$postNLShipment->getShipmentType()
);
}

/**
* @return null|\TIG\PostNL\Api\Data\ShipmentInterface
*/
public function getPostNLShipment()
{
return $this->postNLShipmentRepository->getByFieldWithValue('shipment_id', $this->getShipment()->getId());
if ($this->shipment === null) {
$this->shipment = $this->postNLShipmentRepository->getByFieldWithValue(
'shipment_id',
$this->getShipment()->getId()
);
}

return $this->shipment;
}

/**
* @return bool
*/
public function canChangeParcelCount()
{
return $this->getPostNLShipment()->canChangeParcelCount();
}
}
59 changes: 59 additions & 0 deletions Config/CheckoutConfiguration/EveningDeliveryBeFee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @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\Config\CheckoutConfiguration;

use TIG\PostNL\Config\Provider\ShippingOptions;

class EveningDeliveryBeFee implements CheckoutConfigurationInterface
{
/**
* @var ShippingOptions
*/
private $shippingOptions;

/**
* @param ShippingOptions $shippingOptions
*/
public function __construct(
ShippingOptions $shippingOptions
) {
$this->shippingOptions = $shippingOptions;
}

/**
* @return bool|mixed
*/
public function getValue()
{
return $this->shippingOptions->getEveningDeliveryFee('BE');
}
}
59 changes: 59 additions & 0 deletions Config/CheckoutConfiguration/IsEveningDeliveryBeActive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @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\Config\CheckoutConfiguration;

use TIG\PostNL\Config\Provider\ShippingOptions;

class IsEveningDeliveryBeActive implements CheckoutConfigurationInterface
{
/**
* @var ShippingOptions
*/
private $shippingOptions;

/**
* @param ShippingOptions $shippingOptions
*/
public function __construct(
ShippingOptions $shippingOptions
) {
$this->shippingOptions = $shippingOptions;
}

/**
* @return bool|mixed
*/
public function getValue()
{
return $this->shippingOptions->isEveningDeliveryActive('BE');
}
}
4 changes: 2 additions & 2 deletions Config/Csv/Import/Tablerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ private function getCsvData($scopeId, $conditionName)
$csvData = [];

// @codingStandardsIgnoreLine
if (empty($_FILES['groups']['tmp_name']['tig_postnl']['fields']['import']['value'])) {
if (empty($_FILES['groups']['tmp_name']['tig_postnl']['fields']['tablerate_import']['value'])) {
return $csvData;
}

// @codingStandardsIgnoreLine
$filePath = $_FILES['groups']['tmp_name']['tig_postnl']['fields']['import']['value'];
$filePath = $_FILES['groups']['tmp_name']['tig_postnl']['fields']['tablerate_import']['value'];

$website = $this->storeManager->getWebsite($scopeId);
$websiteId = $website->getId();
Expand Down
18 changes: 17 additions & 1 deletion Config/Provider/AddressConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
*/
namespace TIG\PostNL\Config\Provider;

/**
* This class contains all posible values of the address info parsed inside of the configuration.
* Which will cause that it is too long for Code Sniffer to check.
*/
// @codingStandardsIgnoreFile
class AddressConfiguration extends AbstractConfigProvider
{

Expand Down Expand Up @@ -60,7 +65,8 @@ public function getAddressInfo($store = null)
'housenumber' => $this->getHousenumber($store),
'housenumber_addition' => $this->getHousenumberAddition($store),
'postcode' => $this->getPostcode($store),
'city' => $this->getCity($store)
'city' => $this->getCity($store),
'country' => $this->getCountry(),
];

return $shippersAddress;
Expand Down Expand Up @@ -155,4 +161,14 @@ public function getCity($store = null)
{
return $this->getConfigFromXpath(self::XPATH_GENERAL_CITY, $store);
}

/**
* At this moment only sending from NL is allowed. This may change in the future.
*
* @return string
*/
public function getCountry()
{
return 'NL';
}
}
9 changes: 9 additions & 0 deletions Config/Provider/ProductOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ProductOptions extends AbstractConfigProvider
const XPATH_DEFAULT_EVENING_PRODUCT_OPTION = 'tig_postnl/productoptions/default_evening_option';
const XPATH_DEFAULT_EXTRAATHOME_PRODUCT_OPTION = 'tig_postnl/productoptions/default_extraathome_option';
const XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION = 'tig_postnl/productoptions/default_pakjegemak_option';
const XPATH_DEFAULT_EVENING_BE_PRODUCT_OPTION = 'tig_postnl/productoptions/default_evening_be_option';
const XPATH_DEFAULT_PAKJEGEMAK_EARLY_PRODUCT_OPTION = 'tig_postnl/productoptions/default_pakjegemak_early_option';
const XPATH_DEFAULT_SUNDAY_PRODUCT_OPTION = 'tig_postnl/productoptions/default_sunday_option';

Expand Down Expand Up @@ -76,6 +77,14 @@ public function getDefaultExtraAtHomeProductOption()
/**
* @return string|int
*/
public function getDefaultEveningBeProductOption()
{
return $this->getConfigFromXpath(self::XPATH_DEFAULT_EVENING_BE_PRODUCT_OPTION);
}

/**
* @return mixed
*/
public function getDefaultPakjeGemakProductOption()
{
return $this->getConfigFromXpath(self::XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION);
Expand Down
Loading

0 comments on commit bf27cbf

Please sign in to comment.