Skip to content

Commit 2854866

Browse files
Merge pull request #7789 from magento-gl/DHL_AC-3023_JULY_28_22
2 parents 471f4d3 + 207465c commit 2854866

File tree

5 files changed

+64
-56
lines changed

5 files changed

+64
-56
lines changed

app/code/Magento/Dhl/Model/Carrier.php

+24-23
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
5757
*
5858
* @var string[]
5959
*/
60-
protected $_customizableContainerTypes = [self::DHL_CONTENT_TYPE_NON_DOC];
60+
protected $_customizableContainerTypes = [self::DHL_CONTENT_TYPE_NON_DOC, self::DHL_CONTENT_TYPE_DOC];
6161

6262
/**
6363
* Code of the carrier
@@ -1533,7 +1533,7 @@ protected function _doRequest()
15331533
' xmlns:req="http://www.dhl.com"' .
15341534
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' .
15351535
' xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd"' .
1536-
' schemaVersion="6.2" />';
1536+
' schemaVersion="10.0" />';
15371537
$xml = $this->_xmlElFactory->create(['data' => $xmlStr]);
15381538

15391539
$nodeRequest = $xml->addChild('Request', '', '');
@@ -1562,13 +1562,11 @@ protected function _doRequest()
15621562
$xml->addChild('RegionCode', $originRegion, '');
15631563
}
15641564
$xml->addChild('RequestedPickupTime', 'N', '');
1565-
$xml->addChild('NewShipper', 'N', '');
15661565
$xml->addChild('LanguageCode', 'EN', '');
1567-
$xml->addChild('PiecesEnabled', 'Y', '');
15681566

15691567
/** Billing */
15701568
$nodeBilling = $xml->addChild('Billing', '', '');
1571-
$nodeBilling->addChild('ShipperAccountNumber', (string)$this->getConfigData('account'));
1569+
$nodeBilling->addChild('ShipperAccountNumber', (string)substr($this->getConfigData('account'), 0, 9));
15721570
/**
15731571
* Method of Payment:
15741572
* S (Shipper)
@@ -1580,13 +1578,12 @@ protected function _doRequest()
15801578
/**
15811579
* Shipment bill to account – required if Shipping PaymentType is other than 'S'
15821580
*/
1583-
$nodeBilling->addChild('BillingAccountNumber', (string)$this->getConfigData('account'));
1581+
$nodeBilling->addChild('BillingAccountNumber', (string)substr($this->getConfigData('account'), 0, 9));
15841582
if ($this->isDutiable(
15851583
$rawRequest->getShipperAddressCountryCode(),
15861584
$rawRequest->getRecipientAddressCountryCode()
15871585
)) {
1588-
$nodeBilling->addChild('DutyPaymentType', 'S');
1589-
$nodeBilling->addChild('DutyAccountNumber', (string)$this->getConfigData('account'));
1586+
$nodeBilling->addChild('DutyAccountNumber', (string)substr($this->getConfigData('account'), 0, 9));
15901587
}
15911588

15921589
/** Receiver */
@@ -1601,11 +1598,16 @@ protected function _doRequest()
16011598
$address = $rawRequest->getRecipientAddressStreet1() . ' ' . $rawRequest->getRecipientAddressStreet2();
16021599
$address = $this->string->split($address, 45, false, true);
16031600
if (is_array($address)) {
1601+
$addressLineNumber = 1;
16041602
foreach ($address as $addressLine) {
1605-
$nodeConsignee->addChild('AddressLine', $addressLine);
1603+
if ($addressLineNumber > 3) {
1604+
break;
1605+
}
1606+
$nodeConsignee->addChild('AddressLine'.$addressLineNumber, $addressLine);
1607+
$addressLineNumber++;
16061608
}
16071609
} else {
1608-
$nodeConsignee->addChild('AddressLine', $address);
1610+
$nodeConsignee->addChild('AddressLine1', $address);
16091611
}
16101612

16111613
$nodeConsignee->addChild('City', $rawRequest->getRecipientAddressCity());
@@ -1633,7 +1635,7 @@ protected function _doRequest()
16331635
* value should lie in between 1 to 9999.This field is mandatory.
16341636
*/
16351637
$nodeCommodity = $xml->addChild('Commodity', '', '');
1636-
$nodeCommodity->addChild('CommodityCode', '1');
1638+
$nodeCommodity->addChild('CommodityCode', substr('01', 0, 18));
16371639

16381640
/** Dutiable */
16391641
if ($this->isDutiable(
@@ -1647,6 +1649,7 @@ protected function _doRequest()
16471649
);
16481650
$baseCurrencyCode = $this->_storeManager->getWebsite($rawRequest->getWebsiteId())->getBaseCurrencyCode();
16491651
$nodeDutiable->addChild('DeclaredCurrency', $baseCurrencyCode);
1652+
$nodeDutiable->addChild('TermsOfTrade', 'DAP');
16501653
}
16511654

16521655
/**
@@ -1663,18 +1666,23 @@ protected function _doRequest()
16631666

16641667
/** Shipper */
16651668
$nodeShipper = $xml->addChild('Shipper', '', '');
1666-
$nodeShipper->addChild('ShipperID', (string)$this->getConfigData('account'));
1669+
$nodeShipper->addChild('ShipperID', (string)substr($this->getConfigData('account'), 0, 9));
16671670
$nodeShipper->addChild('CompanyName', $rawRequest->getShipperContactCompanyName());
1668-
$nodeShipper->addChild('RegisteredAccount', (string)$this->getConfigData('account'));
1671+
$nodeShipper->addChild('RegisteredAccount', (string)substr($this->getConfigData('account'), 0, 9));
16691672

16701673
$address = $rawRequest->getShipperAddressStreet1() . ' ' . $rawRequest->getShipperAddressStreet2();
16711674
$address = $this->string->split($address, 45, false, true);
16721675
if (is_array($address)) {
1676+
$addressLineNumber = 1;
16731677
foreach ($address as $addressLine) {
1674-
$nodeShipper->addChild('AddressLine', $addressLine);
1678+
if ($addressLineNumber > 3) {
1679+
break;
1680+
}
1681+
$nodeShipper->addChild('AddressLine'.$addressLineNumber, $addressLine);
1682+
$addressLineNumber++;
16751683
}
16761684
} else {
1677-
$nodeShipper->addChild('AddressLine', $address);
1685+
$nodeShipper->addChild('AddressLine1', $address);
16781686
}
16791687

16801688
$nodeShipper->addChild('City', $rawRequest->getShipperAddressCity());
@@ -1742,7 +1750,6 @@ protected function _doRequest()
17421750
protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17431751
{
17441752
$nodeShipmentDetails = $xml->addChild('ShipmentDetails', '', '');
1745-
$nodeShipmentDetails->addChild('NumberOfPieces', count($rawRequest->getPackages()));
17461753

17471754
$nodePieces = $nodeShipmentDetails->addChild('Pieces', '', '');
17481755

@@ -1776,7 +1783,6 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17761783
$nodePiece->addChild('PieceContents', $this->string->substr(implode(',', $content), 0, 34));
17771784
}
17781785

1779-
$nodeShipmentDetails->addChild('Weight', sprintf('%.3f', $rawRequest->getPackageWeight()));
17801786
$nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1));
17811787
$nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod());
17821788
$nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod());
@@ -1785,12 +1791,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17851791
$this->_coreDate->date('Y-m-d', strtotime('now + 1day'))
17861792
);
17871793
$nodeShipmentDetails->addChild('Contents', 'DHL Parcel');
1788-
/**
1789-
* The DoorTo Element defines the type of delivery service that applies to the shipment.
1790-
* The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to
1791-
* Door non-compliant)
1792-
*/
1793-
$nodeShipmentDetails->addChild('DoorTo', 'DD');
1794+
17941795
$nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1));
17951796
$contentType = isset($package['params']['container']) ? $package['params']['container'] : '';
17961797
$packageType = $contentType === self::DHL_CONTENT_TYPE_NON_DOC ? 'CP' : 'EE';

app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup_content.phtml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
</div>
3232
<div class="admin__control-table-wrapper admin__page-subsection">
33-
<table class="data-table admin__control-table">
33+
<table class="data-table admin__control-table admin__control-table">
3434
<thead>
3535
<tr>
3636
<th class="col-type"><?= $block->escapeHtml(__('Type')) ?></th>
@@ -46,9 +46,9 @@
4646
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display: none', 'th.col-custom') ?>
4747
<?php endif ?>
4848
<th class="col-total-weight"><?= $block->escapeHtml(__('Total Weight')) ?></th>
49-
<th class="col-length"><?= $block->escapeHtml(__('Length')) ?></th>
50-
<th class="col-width"><?= $block->escapeHtml(__('Width')) ?></th>
51-
<th class="col-height"><?= $block->escapeHtml(__('Height')) ?></th>
49+
<th class="col-length _required"><span><?= $block->escapeHtml(__('Length')) ?></span></th>
50+
<th class="col-width _required"><span><?= $block->escapeHtml(__('Width')) ?></span></th>
51+
<th class="col-height _required"><span><?= $block->escapeHtml(__('Height')) ?></span></th>
5252
<th>&nbsp;</th>
5353
<?php if ($block->getDeliveryConfirmationTypes()): ?>
5454
<th class="col-signature"><?= $block->escapeHtml(__('Signature Confirmation')) ?></th>

app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ define(['prototype'], function () {
7171
if (this.packagesContent.childElements().length == 0) {
7272
this.newPackage();
7373
}
74+
const allowedPackageTypes = ["N","D"];
75+
76+
if (!Object.values(this.customizableContainers).some(packageType => allowedPackageTypes.includes(packageType))) {
77+
$('packaging_window').select(
78+
'th.col-length,th.col-width,th.col-height'
79+
).forEach(element => {
80+
element.classList.remove('_required')
81+
});
82+
}
7483
jQuery(this.window).modal('openModal');
7584
},
7685

@@ -262,7 +271,15 @@ define(['prototype'], function () {
262271
}
263272
dimensionElements.each(callback);
264273

265-
return result = $$('[id^="package_block_"] input').collect(function (element) {
274+
const allowedPackageTypes = ["N","D"];
275+
276+
if (Object.values(this.customizableContainers).some(packageType => allowedPackageTypes.includes(packageType))) {
277+
dimensionElements.each(function(element) {
278+
$(element).addClassName('required-entry');
279+
});
280+
}
281+
282+
return result = $$('[id^="package_block_"] input').collect(function (element) {
266283
return this.validateElement(element);
267284
}, this).all();
268285
},

dev/tests/integration/testsuite/Magento/Dhl/_files/domestic_shipment_request.xml

+8-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<req:ShipmentRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" schemaVersion="6.2">
9+
xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" schemaVersion="10.0">
1010
<Request xmlns="">
1111
<ServiceHeader>
1212
<MessageTime>currentTime</MessageTime>
@@ -21,17 +21,15 @@
2121
</Request>
2222
<RegionCode xmlns="">CHECKED</RegionCode>
2323
<RequestedPickupTime xmlns="">N</RequestedPickupTime>
24-
<NewShipper xmlns="">N</NewShipper>
2524
<LanguageCode xmlns="">EN</LanguageCode>
26-
<PiecesEnabled xmlns="">Y</PiecesEnabled>
2725
<Billing xmlns="">
28-
<ShipperAccountNumber>1234567890</ShipperAccountNumber>
26+
<ShipperAccountNumber>123456789</ShipperAccountNumber>
2927
<ShippingPaymentType>S</ShippingPaymentType>
30-
<BillingAccountNumber>1234567890</BillingAccountNumber>
28+
<BillingAccountNumber>123456789</BillingAccountNumber>
3129
</Billing>
3230
<Consignee xmlns="">
3331
<CompanyName/>
34-
<AddressLine>15099 Some Blvd</AddressLine>
32+
<AddressLine1>15099 Some Blvd</AddressLine1>
3533
<City/>
3634
<PostalCode/>
3735
<CountryCode/>
@@ -42,14 +40,13 @@
4240
</Contact>
4341
</Consignee>
4442
<Commodity xmlns="">
45-
<CommodityCode>1</CommodityCode>
43+
<CommodityCode>01</CommodityCode>
4644
</Commodity>
4745
<Reference xmlns="">
4846
<ReferenceID>shipment reference</ReferenceID>
4947
<ReferenceType>St</ReferenceType>
5048
</Reference>
5149
<ShipmentDetails xmlns="">
52-
<NumberOfPieces>1</NumberOfPieces>
5350
<Pieces xmlns="">
5451
<Piece xmlns="">
5552
<PieceID>1</PieceID>
@@ -61,22 +58,20 @@
6158
<PieceContents>item_name</PieceContents>
6259
</Piece>
6360
</Pieces>
64-
<Weight>0.454</Weight>
6561
<WeightUnit>K</WeightUnit>
6662
<GlobalProductCode/>
6763
<LocalProductCode/>
6864
<Date>currentTime</Date>
6965
<Contents>DHL Parcel</Contents>
70-
<DoorTo>DD</DoorTo>
7166
<DimensionUnit>C</DimensionUnit>
7267
<PackageType>CP</PackageType>
7368
<CurrencyCode>USD</CurrencyCode>
7469
</ShipmentDetails>
7570
<Shipper xmlns="">
76-
<ShipperID>1234567890</ShipperID>
71+
<ShipperID>123456789</ShipperID>
7772
<CompanyName/>
78-
<RegisteredAccount>1234567890</RegisteredAccount>
79-
<AddressLine>4956 Some Way</AddressLine>
73+
<RegisteredAccount>123456789</RegisteredAccount>
74+
<AddressLine1>4956 Some Way</AddressLine1>
8075
<City/>
8176
<PostalCode/>
8277
<CountryCode/>

dev/tests/integration/testsuite/Magento/Dhl/_files/shipment_request.xml

+10-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<req:ShipmentRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" schemaVersion="6.2">
9+
xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" schemaVersion="10.0">
1010
<Request xmlns="">
1111
<ServiceHeader>
1212
<MessageTime>currentTime</MessageTime>
@@ -21,19 +21,16 @@
2121
</Request>
2222
<RegionCode xmlns="">CHECKED</RegionCode>
2323
<RequestedPickupTime xmlns="">N</RequestedPickupTime>
24-
<NewShipper xmlns="">N</NewShipper>
2524
<LanguageCode xmlns="">EN</LanguageCode>
26-
<PiecesEnabled xmlns="">Y</PiecesEnabled>
2725
<Billing xmlns="">
28-
<ShipperAccountNumber>1234567890</ShipperAccountNumber>
26+
<ShipperAccountNumber>123456789</ShipperAccountNumber>
2927
<ShippingPaymentType>S</ShippingPaymentType>
30-
<BillingAccountNumber>1234567890</BillingAccountNumber>
31-
<DutyPaymentType>S</DutyPaymentType>
32-
<DutyAccountNumber>1234567890</DutyAccountNumber>
28+
<BillingAccountNumber>123456789</BillingAccountNumber>
29+
<DutyAccountNumber>123456789</DutyAccountNumber>
3330
</Billing>
3431
<Consignee xmlns="">
3532
<CompanyName/>
36-
<AddressLine>15099 Some Blvd</AddressLine>
33+
<AddressLine1>15099 Some Blvd</AddressLine1>
3734
<City/>
3835
<PostalCode/>
3936
<CountryCode/>
@@ -44,18 +41,18 @@
4441
</Contact>
4542
</Consignee>
4643
<Commodity xmlns="">
47-
<CommodityCode>1</CommodityCode>
44+
<CommodityCode>01</CommodityCode>
4845
</Commodity>
4946
<Dutiable xmlns="">
5047
<DeclaredValue>10.00</DeclaredValue>
5148
<DeclaredCurrency>USD</DeclaredCurrency>
49+
<TermsOfTrade>DAP</TermsOfTrade>
5250
</Dutiable>
5351
<Reference xmlns="">
5452
<ReferenceID>shipment reference</ReferenceID>
5553
<ReferenceType>St</ReferenceType>
5654
</Reference>
5755
<ShipmentDetails xmlns="">
58-
<NumberOfPieces>1</NumberOfPieces>
5956
<Pieces xmlns="">
6057
<Piece xmlns="">
6158
<PieceID>1</PieceID>
@@ -67,23 +64,21 @@
6764
<PieceContents>item_name</PieceContents>
6865
</Piece>
6966
</Pieces>
70-
<Weight>0.454</Weight>
7167
<WeightUnit>K</WeightUnit>
7268
<GlobalProductCode/>
7369
<LocalProductCode/>
7470
<Date>currentTime</Date>
7571
<Contents>DHL Parcel</Contents>
76-
<DoorTo>DD</DoorTo>
7772
<DimensionUnit>C</DimensionUnit>
7873
<PackageType>CP</PackageType>
7974
<IsDutiable>Y</IsDutiable>
8075
<CurrencyCode>USD</CurrencyCode>
8176
</ShipmentDetails>
8277
<Shipper xmlns="">
83-
<ShipperID>1234567890</ShipperID>
78+
<ShipperID>123456789</ShipperID>
8479
<CompanyName/>
85-
<RegisteredAccount>1234567890</RegisteredAccount>
86-
<AddressLine>4956 Some Way</AddressLine>
80+
<RegisteredAccount>123456789</RegisteredAccount>
81+
<AddressLine1>4956 Some Way</AddressLine1>
8782
<City/>
8883
<PostalCode/>
8984
<CountryCode/>

0 commit comments

Comments
 (0)