Skip to content

Commit

Permalink
Merged develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mbe1987 committed Sep 26, 2022
2 parents ae5421e + f15946e commit f591230
Show file tree
Hide file tree
Showing 109 changed files with 7,983 additions and 6,330 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog
## 1.6.6
* new Service CDP (Closest Droppoint) for Paket International
* bugfix: multibyte substring problem for article title in export documents
* templating changes: proper use of smarty.block.parent call in chipping country form
* extended output for soap errors

## 1.6.5
* bugfix for selecting a Paketshop in the Filialfinder

Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pathToModule": "copy_this/modules/mo/mo_dhl",
"prefix": "mo_",
"suffix": "",
"version": "1.6.5",
"version": "1.6.6",
"compatibility": {
"minimumVersion": "6.0",
"maximumVersion": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Mediaopt\DHL\Adapter;


use Mediaopt\DHL\Api\GKV\Request\CreateShipmentOrderRequest;
use Mediaopt\DHL\Api\GKV\CreateShipmentOrderRequest;
use Mediaopt\DHL\Api\GKV\Serviceconfiguration;
use Mediaopt\DHL\Api\GKV\ShipmentOrderType;
use Mediaopt\DHL\Application\Model\Order;
Expand Down
43 changes: 30 additions & 13 deletions src/modules/mo/mo_dhl/Adapter/GKVCustomShipmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
namespace Mediaopt\DHL\Adapter;


use Mediaopt\DHL\Api\GKV\CDP;
use Mediaopt\DHL\Api\GKV\CountryType;
use Mediaopt\DHL\Api\GKV\Economy;
use Mediaopt\DHL\Api\GKV\ExportDocPosition;
use Mediaopt\DHL\Api\GKV\Ident;
use Mediaopt\DHL\Api\GKV\PDDP;
use Mediaopt\DHL\Api\GKV\Serviceconfiguration;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationAdditionalInsurance;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationCashOnDelivery;
Expand All @@ -21,7 +25,6 @@
use Mediaopt\DHL\Application\Model\Order;
use Mediaopt\DHL\Model\MoDHLService;
use Mediaopt\DHL\Shipment\Process;
use OxidEsales\Eshop\Core\Language;
use OxidEsales\Eshop\Core\Registry;

/**
Expand Down Expand Up @@ -51,6 +54,7 @@ public function toCustomizableParametersArray(ShipmentOrderType $shipmentOrder):
'name' => $receiver->getName1(),
'type' => $receiver->getAddress() !== null ? 'address' : ($receiver->getPackstation() !== null ? 'packstation' : 'poftfiliale'),
'address' => $receiver->getAddress() ?: $receiver->getPackstation() ?: $receiver->getPostfiliale(),
'communication' => $receiver->getCommunication(),
],
'returnReceiver' => [
'name' => $returnReceiver->getName()->getName1() . $returnReceiver->getName()->getName2() . $returnReceiver->getName()->getName3(),
Expand All @@ -66,6 +70,8 @@ public function toCustomizableParametersArray(ShipmentOrderType $shipmentOrder):
'cashOnDelivery' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getCashOnDelivery(),
'visualAgeCheck' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getVisualCheckOfAge(),
'pddp' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getPDDP(),
'cdp' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getCDP(),
'economy' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getEconomy(),
'premium' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getPremium(),
'endorsement' => $shipmentOrder->getShipment()->getShipmentDetails()->getService()->getEndorsement(),
],
Expand Down Expand Up @@ -140,6 +146,11 @@ protected function useCustomReceiver(ShipmentOrderType $shipmentOrder, $receiver
if ($receiverData['country']) {
$receiverData['Origin'] = new CountryType($receiverData['country']);
}
if ($communication = $receiver->getCommunication()) {
$communication
->setEmail($receiverData['email'])
->setPhone($receiverData['phone']);
}
$receiverAddress = $receiver->getAddress() ?: $receiver->getPackstation() ?: $receiver->getPostfiliale();
$receiverAddress->assign($receiverData);
}
Expand Down Expand Up @@ -177,7 +188,7 @@ protected function useCustomServices(ShipmentOrderType $shipmentOrder, $services
if ($process->supportsCashOnDelivery()) {
$isActive = filter_var($servicesData['cashOnDelivery']['active'], FILTER_VALIDATE_BOOLEAN);
$details = $servicesData['cashOnDelivery']['codAmount'] ?? null;
$services->setCashOnDelivery(new ServiceconfigurationCashOnDelivery($isActive, 0, $details));
$services->setCashOnDelivery(new ServiceconfigurationCashOnDelivery($isActive, $details));
}
if ($process->supportsIdentCheck()) {
$isActive = filter_var($servicesData['identCheck']['active'], FILTER_VALIDATE_BOOLEAN);
Expand All @@ -199,7 +210,15 @@ protected function useCustomServices(ShipmentOrderType $shipmentOrder, $services
}
if ($process->supportsPDDP()) {
$isActive = filter_var($servicesData['pddp']['active'], FILTER_VALIDATE_BOOLEAN);
$services->setPDDP(new Serviceconfiguration($isActive));
$services->setPDDP(new PDDP($isActive));
}
if ($process->supportsCDP()) {
$isActive = filter_var($servicesData['cdp']['active'], FILTER_VALIDATE_BOOLEAN);
$services->setCDP(new CDP($isActive));
}
if ($process->supportsEconomy()) {
$isActive = filter_var($servicesData['economy']['active'], FILTER_VALIDATE_BOOLEAN);
$services->setEconomy(new Economy($isActive));
}
if ($process->supportsPremium()) {
$isActive = filter_var($servicesData['premium']['active'], FILTER_VALIDATE_BOOLEAN);
Expand All @@ -216,19 +235,17 @@ protected function useCustomServices(ShipmentOrderType $shipmentOrder, $services

/**
* @param array $identCheck
* @return \stdClass
* @return Ident
* @throws \Exception
*/
protected function extractIdent($identCheck) : \stdClass
protected function extractIdent($identCheck) : Ident
{
$ident = new \stdClass();
$ident->surname = $identCheck['surname'];
$ident->givenName = $identCheck['givenName'];
$ident->dateOfBirth = $identCheck['dateOfBirth'] ? (new \DateTime($identCheck['dateOfBirth']))->format('Y-m-d') : null;
$ident->minimumAge = $identCheck['minimumAge']
? 'A' . $identCheck['minimumAge']
: null;
return $ident;
return new Ident(
$identCheck['surname'],
$identCheck['givenName'],
$identCheck['dateOfBirth'] ? (new \DateTime($identCheck['dateOfBirth']))->format('Y-m-d') : null,
$identCheck['minimumAge'] ? 'A' . $identCheck['minimumAge'] : null
);
}

/**
Expand Down
83 changes: 47 additions & 36 deletions src/modules/mo/mo_dhl/Adapter/GKVShipmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,36 @@
namespace Mediaopt\DHL\Adapter;

use Mediaopt\DHL\Api\GKV\BankType;
use Mediaopt\DHL\Api\GKV\CDP;
use Mediaopt\DHL\Api\GKV\CommunicationType;
use Mediaopt\DHL\Api\GKV\CountryType;
use Mediaopt\DHL\Api\GKV\Economy;
use Mediaopt\DHL\Api\GKV\ExportDocPosition;
use Mediaopt\DHL\Api\GKV\ExportDocumentType;
use Mediaopt\DHL\Api\GKV\Ident;
use Mediaopt\DHL\Api\GKV\NameType;
use Mediaopt\DHL\Api\GKV\NativeAddressType;
use Mediaopt\DHL\Api\GKV\NativeAddressTypeNew;
use Mediaopt\DHL\Api\GKV\PackStationType;
use Mediaopt\DHL\Api\GKV\PostfilialeType;
use Mediaopt\DHL\Api\GKV\PDDP;
use Mediaopt\DHL\Api\GKV\PostfilialeTypeNoCountry;
use Mediaopt\DHL\Api\GKV\ReceiverNativeAddressType;
use Mediaopt\DHL\Api\GKV\ReceiverType;
use Mediaopt\DHL\Api\GKV\Serviceconfiguration;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationAdditionalInsurance;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationCashOnDelivery;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationDetails;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationDetailsOptional;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationDetailsPreferredDay;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationDetailsPreferredLocation;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationDetailsPreferredNeighbour;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationEndorsement;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationIC;
use Mediaopt\DHL\Api\GKV\ServiceconfigurationVisualAgeCheck;
use Mediaopt\DHL\Api\GKV\Shipment;
use Mediaopt\DHL\Api\GKV\ShipmentDetailsType;
use Mediaopt\DHL\Api\GKV\ShipmentDetailsTypeType;
use Mediaopt\DHL\Api\GKV\ShipmentItemType;
use Mediaopt\DHL\Api\GKV\ShipmentNotificationType;
use Mediaopt\DHL\Api\GKV\ShipmentService;
use Mediaopt\DHL\Api\GKV\ShipperType;
use Mediaopt\DHL\Application\Model\Article;
use Mediaopt\DHL\Application\Model\Order;
use Mediaopt\DHL\Model\MoDHLNotificationMode;
use Mediaopt\DHL\Model\MoDHLService;
Expand Down Expand Up @@ -68,11 +73,11 @@ public function build(Order $order)

/**
* @param Order $order
* @return ShipmentDetailsType
* @return ShipmentDetailsTypeType
*/
protected function buildShipmentDetails(Order $order): ShipmentDetailsType
protected function buildShipmentDetails(Order $order): ShipmentDetailsTypeType
{
$details = new ShipmentDetailsType($this->getProcess($order)->getServiceIdentifier(), $this->buildAccountNumber($order), $this->buildShipmentDate(), $this->buildShipmentItem($order));
$details = new ShipmentDetailsTypeType($this->getProcess($order)->getServiceIdentifier(), $this->buildAccountNumber($order), $this->buildShipmentDate(), $this->buildShipmentItem($order));
if (Registry::getConfig()->getShopConfVar('mo_dhl__beilegerretoure_active') && $this->getProcess($order)->supportsDHLRetoure() && $returnBookingNumber = $this->buildReturnAccountNumber($order)) {
$details->setReturnShipmentAccountNumber($returnBookingNumber);
}
Expand Down Expand Up @@ -190,14 +195,14 @@ private function buildService(Order $order): ShipmentService
if ($wunschpaket->hasWunschtag($remark) && $process->supportsPreferredDay()) {
$wunschtag = $wunschpaket->extractWunschtag($remark);
$wunschtag = date('Y-m-d', strtotime($wunschtag));
$service->setPreferredDay(new ServiceconfigurationDetails(1, $wunschtag));
$service->setPreferredDay(new ServiceconfigurationDetailsPreferredDay(1, $wunschtag));
}
[$type, $locationPart1, $locationPart2] = $wunschpaket->extractLocation($remark);
if ($wunschpaket->hasWunschnachbar($remark) && $process->supportsPreferredNeighbour()) {
$service->setPreferredNeighbour(new ServiceconfigurationDetails(1, "$locationPart2, $locationPart1"));
$service->setPreferredNeighbour(new ServiceconfigurationDetailsPreferredNeighbour(1, "$locationPart2, $locationPart1"));
}
if ($wunschpaket->hasWunschort($remark) && $process->supportsPreferredLocation()) {
$service->setPreferredLocation(new ServiceconfigurationDetails(1, $locationPart1));
$service->setPreferredLocation(new ServiceconfigurationDetailsPreferredLocation(1, $locationPart1));
}
if ($process->supportsParcelOutletRouting()) {
$isActive = (int) Registry::getConfig()->getShopConfVar('mo_dhl__filialrouting_active');
Expand All @@ -216,7 +221,7 @@ private function buildService(Order $order): ShipmentService
}
if ($process->supportsCashOnDelivery()) {
$active = (int) $order->moDHLUsesService(MoDHLService::MO_DHL__CASH_ON_DELIVERY);
$service->setCashOnDelivery(new ServiceconfigurationCashOnDelivery($active, 0, $this->getEURPrice($order, $order->oxorder__oxtotalordersum->value)));
$service->setCashOnDelivery(new ServiceconfigurationCashOnDelivery($active, $this->getEURPrice($order, $order->oxorder__oxtotalordersum->value)));
}
$orderBrutSum = $this->getEURPrice($order, $order->oxorder__oxtotalbrutsum->value);
if ($process->supportsAdditionalInsurance()) {
Expand All @@ -227,34 +232,42 @@ private function buildService(Order $order): ShipmentService
$active = (bool) ($order->moDHLUsesService(MoDHLService::MO_DHL__PREMIUM));
$service->setPremium(new Serviceconfiguration($active));
}
if ($process->supportsCDP()) {
$active = (bool) ($order->moDHLUsesService(MoDHLService::MO_DHL__CDP));
$service->setCDP(new CDP($active));
}
if ($process->supportsEconomy()) {
$active = (bool) ($order->moDHLUsesService(MoDHLService::MO_DHL__ECONOMY));
$service->setEconomy(new Economy($active));
}
if ($process->supportsEndorsement()) {
$abandonment = (bool) ($order->moDHLUsesService(MoDHLService::MO_DHL__ENDORSEMENT));
$service->setEndorsement(new ServiceconfigurationEndorsement(true, $abandonment ? MoDHLService::MO_DHL__ENDORSEMENT_ABANDONMENT : MoDHLService::MO_DHL__ENDORSEMENT_IMMEDIATE));
}
if ($process->supportsPDDP()) {
$active = (bool) ($order->moDHLUsesService(MoDHLService::MO_DHL__PDDP));
$service->setPDDP(new Serviceconfiguration($active));
$service->setPDDP(new PDDP($active));
}
return $service;
}

/**
* @param Order $order
* @return \stdClass
* @return Ident
*/
protected function createIdent(Order $order) : \stdClass
protected function createIdent(Order $order) : Ident
{
$ident = new \stdClass();
$ident->surname = $order->moDHLGetAddressData('lname');
$ident->givenName = $order->moDHLGetAddressData('fname');
$ident->dateOfBirth = $order->getFieldData('mo_dhl_ident_check_birthday');
$ident->minimumAge = Registry::getConfig()->getShopConfVar('mo_dhl__ident_check_min_age')
$ident = new Ident(
$order->moDHLGetAddressData('lname'),
$order->moDHLGetAddressData('fname'),
$order->getFieldData('mo_dhl_ident_check_birthday'),
Registry::getConfig()->getShopConfVar('mo_dhl__ident_check_min_age')
? 'A' . Registry::getConfig()->getShopConfVar('mo_dhl__ident_check_min_age')
: null;
: null);
if ($order->moDHLUsesService(MoDHLService::MO_DHL__VISUAL_AGE_CHECK18)) {
$ident->minimumAge = 'A18';
} elseif ($order->moDHLUsesService(MoDHLService::MO_DHL__VISUAL_AGE_CHECK16) && !$ident->minimumAge) {
$ident->minimumAge = 'A16';
$ident->setMinimumAge('A18');
} elseif ($order->moDHLUsesService(MoDHLService::MO_DHL__VISUAL_AGE_CHECK16) && !$ident->getMinimumAge()) {
$ident->setMinimumAge('A16');
}
return $ident;
}
Expand All @@ -272,7 +285,7 @@ protected function buildReturnReceiver(): ShipperType
$name = new NameType($config->getShopConfVar('mo_dhl__retoure_receiver_line1'), $config->getShopConfVar('mo_dhl__retoure_receiver_line2'), $config->getShopConfVar('mo_dhl__retoure_receiver_line3'));
$iso2 = $this->getIsoalpha2FromIsoalpha3($config->getShopConfVar('mo_dhl__retoure_receiver_country'));
$country = new CountryType($iso2);
$address = new NativeAddressType($config->getShopConfVar('mo_dhl__retoure_receiver_street'), $config->getShopConfVar('mo_dhl__retoure_receiver_street_number'), $config->getShopConfVar('mo_dhl__retoure_receiver_zip'), $config->getShopConfVar('mo_dhl__retoure_receiver_city'), null, $country);
$address = new NativeAddressTypeNew($config->getShopConfVar('mo_dhl__retoure_receiver_street'), $config->getShopConfVar('mo_dhl__retoure_receiver_street_number'), $config->getShopConfVar('mo_dhl__retoure_receiver_zip'), $config->getShopConfVar('mo_dhl__retoure_receiver_city'), $country);
return new ShipperType($name, $address);
}

Expand All @@ -291,24 +304,23 @@ protected function buildShipper(): ShipperType
);
$iso2 = $this->getIsoalpha2FromIsoalpha3($config->getShopConfVar('mo_dhl__sender_country'));
$country = new CountryType($iso2);
$address = new NativeAddressType(
$address = new NativeAddressTypeNew(
$this->convertSpecialChars($config->getShopConfVar('mo_dhl__sender_street')),
$config->getShopConfVar('mo_dhl__sender_street_number'),
$config->getShopConfVar('mo_dhl__sender_zip'),
$this->convertSpecialChars($config->getShopConfVar('mo_dhl__sender_city')),
null,
$country
);
return new ShipperType($name, $address);
}

/**
* @param Order $order
* @return PostfilialeType
* @return PostfilialeTypeNoCountry
*/
private function buildPostfiliale(Order $order): PostfilialeType
private function buildPostfiliale(Order $order): PostfilialeTypeNoCountry
{
return new PostfilialeType($order->moDHLGetAddressData('streetnr'), $order->moDHLGetAddressData('addinfo'), $order->moDHLGetAddressData('zip'), $order->moDHLGetAddressData('city'));
return new PostfilialeTypeNoCountry($order->moDHLGetAddressData('streetnr'), $order->moDHLGetAddressData('addinfo'), $order->moDHLGetAddressData('zip'), $order->moDHLGetAddressData('city'));
}

/**
Expand Down Expand Up @@ -373,11 +385,10 @@ protected function buildExportDocument(Order $order)
return null;
}
$config = Registry::getConfig();
$exportDocumentType = new ExportDocumentType(
$exportDocumentType = (new ExportDocumentType(
'COMMERCIAL_GOODS',
$this->convertSpecialChars($config->getShopConfVar('mo_dhl__sender_city')),
$this->getEURPrice($order, $order->oxorder__oxdelcost->value)
);
$this->convertSpecialChars($config->getShopConfVar('mo_dhl__sender_city'))
))->setAdditionalFee($this->getEURPrice($order, $order->oxorder__oxdelcost->value));

$iso2 = $this->getIsoalpha2FromIsoalpha3($config->getShopConfVar('mo_dhl__sender_country'));

Expand All @@ -393,7 +404,7 @@ protected function buildExportDocument(Order $order)
$iso2,
$orderArticle->getArticle()->getFieldData(MoDHLService::MO_DHL__ZOLLTARIF),
$count,
$this->getArticleWeight($orderArticle, $config, true),
$this->getArticleWeight($orderArticle, $config),
$this->getEURPrice($order, $orderArticle->getPrice()->getPrice())
);
}
Expand Down Expand Up @@ -480,7 +491,7 @@ protected function getArticleTitle(OrderArticle $orderArticle, array $receiverLa
$title = $orderArticle->getArticle()->getFieldData('oxtitle');
}

return substr($this->convertSpecialChars($title), 0, 50);
return mb_substr($this->convertSpecialChars($title), 0, 50);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Mediaopt\DHL\Adapter;

use Mediaopt\DHL\Api\GKV\CountryType;
use Mediaopt\DHL\Api\GKV\NameType;
use Mediaopt\DHL\Api\GKV\NativeAddressType;
use Mediaopt\DHL\Api\GKV\ReceiverType;
use Mediaopt\DHL\Api\GKV\ShipperType;
use Mediaopt\DHL\Api\Internetmarke\Address;
use Mediaopt\DHL\Api\Internetmarke\AddressBinding;
use Mediaopt\DHL\Api\Internetmarke\CompanyName;
Expand All @@ -16,7 +11,6 @@
use Mediaopt\DHL\Api\Internetmarke\ShoppingCartPDFPosition;
use Mediaopt\DHL\Api\Internetmarke\VoucherLayout;
use Mediaopt\DHL\Api\Internetmarke\VoucherPosition;
use Mediaopt\DHL\ServiceProvider\Branch;
use Mediaopt\DHL\Application\Model\Order;
use OxidEsales\Eshop\Core\Registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace Mediaopt\DHL\Adapter;

use Mediaopt\DHL\Api\GKV\Request\CreateShipmentOrderRequest;
use Mediaopt\DHL\Api\GKV\Serviceconfiguration;
use Mediaopt\DHL\Api\GKV\ShipmentOrderType;
use Mediaopt\DHL\Api\Internetmarke\CreateShopOrderIdRequest;
use Mediaopt\DHL\Api\Internetmarke\ShoppingCartPDFPosition;
use Mediaopt\DHL\Api\Internetmarke\ShoppingCartPDFRequestType;
use Mediaopt\DHL\Api\Internetmarke\VoucherLayout;
use Mediaopt\DHL\Application\Model\Order;
use Mediaopt\DHL\Model\MoDHLInternetmarkeProduct;
use OxidEsales\Eshop\Core\DatabaseProvider;
Expand Down
Loading

0 comments on commit f591230

Please sign in to comment.