From 890ccb7f772523185b2c56dec054ec19c26a6d64 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 11 Apr 2022 15:18:31 +0200 Subject: [PATCH 1/4] Store additional BillThirdParty for BillThirdPartyConsignee Store this separately so it can be treated differently than a regular BillThirdParty, as it has to be stored in a different root element in the XML being generated. BillThirdPartyConsignee can be a regular BillThirdParty object --- src/Entity/PaymentInformation.php | 24 ++++++++++++++++++++++++ src/Entity/ShipmentCharge.php | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/Entity/PaymentInformation.php b/src/Entity/PaymentInformation.php index 7a074b4e..0d5416cd 100644 --- a/src/Entity/PaymentInformation.php +++ b/src/Entity/PaymentInformation.php @@ -21,6 +21,11 @@ class PaymentInformation */ private $billThirdParty; + /** + * @var BillThirdParty + */ + private $billThirdPartyConsignee; + /** * @var FreightCollect */ @@ -89,6 +94,25 @@ public function setBillThirdParty(BillThirdParty $billThirdParty = null) return $this; } + /** + * @return BillThirdParty + */ + public function getBillThirdPartyConsignee() + { + return $this->billThirdPartyConsignee; + } + + /** + * @param BillThirdParty $billThirdPartyConsignee + * @return PaymentInformation + */ + public function setBillThirdPartyConsignee(BillThirdParty $billThirdPartyConsignee = null) + { + $this->billThirdPartyConsignee = $billThirdPartyConsignee; + + return $this; + } + /** * @return FreightCollect */ diff --git a/src/Entity/ShipmentCharge.php b/src/Entity/ShipmentCharge.php index 0155b270..cc358dcb 100644 --- a/src/Entity/ShipmentCharge.php +++ b/src/Entity/ShipmentCharge.php @@ -33,6 +33,11 @@ class ShipmentCharge */ private $billThirdParty; + /** + * @var BillThirdParty + */ + private $billThirdPartyConsignee; + /** * @var bool */ @@ -105,6 +110,25 @@ public function setBillThirdParty(BillThirdParty $billThirdParty = null) return $this; } + /** + * @return BillThirdParty + */ + public function getBillThirdPartyConsignee() + { + return $this->billThirdPartyConsignee; + } + + /** + * @param BillThirdParty $billThirdPartyConsignee + * @return ShipmentCharge + */ + public function setBillThirdPartyConsignee(BillThirdParty $billThirdPartyConsignee = null) + { + $this->billThirdPartyConsignee = $billThirdPartyConsignee; + + return $this; + } + /** * @return bool */ From a35a0eefa4f869f4f90751a27e603eb280da3700 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 11 Apr 2022 15:21:02 +0200 Subject: [PATCH 2/4] Write the additional BillThirdParty as BillThirdPartyConsignee element --- src/Shipping.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Shipping.php b/src/Shipping.php index 92e3c49a..c0b8da48 100644 --- a/src/Shipping.php +++ b/src/Shipping.php @@ -355,16 +355,30 @@ private function createConfirmRequest( $node = $node->appendChild($xml->createElement('BillThirdParty')); $btpNode = $node->appendChild($xml->createElement('BillThirdPartyShipper')); $btpNode->appendChild($xml->createElement('AccountNumber', $rec->getBillThirdParty()->getAccountNumber())); - + $tpNode = $btpNode->appendChild($xml->createElement('ThirdParty')); $addressNode = $tpNode->appendChild($xml->createElement('Address')); - + $thirdPartAddress = $rec->getBillThirdParty()->getThirdPartyAddress(); if (isset($thirdPartAddress) && $rec->getBillThirdParty()->getThirdPartyAddress()->getPostalCode()) { $addressNode->appendChild($xml->createElement('PostalCode', $rec->getBillThirdParty()->getThirdPartyAddress()->getPostalCode())); } - + $addressNode->appendChild($xml->createElement('CountryCode', $rec->getBillThirdParty()->getThirdPartyAddress()->getCountryCode())); + } elseif ($rec->getBillThirdPartyConsignee()) { + $node = $node->appendChild($xml->createElement('BillThirdParty')); + $btpNode = $node->appendChild($xml->createElement('BillThirdPartyConsignee')); + $btpNode->appendChild($xml->createElement('AccountNumber', $rec->getBillThirdPartyConsignee()->getAccountNumber())); + + $tpNode = $btpNode->appendChild($xml->createElement('ThirdParty')); + $addressNode = $tpNode->appendChild($xml->createElement('Address')); + + $thirdPartAddress = $rec->getBillThirdPartyConsignee()->getThirdPartyAddress(); + if (isset($thirdPartAddress) && $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getPostalCode()) { + $addressNode->appendChild($xml->createElement('PostalCode', $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getPostalCode())); + } + + $addressNode->appendChild($xml->createElement('CountryCode', $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getCountryCode())); } elseif ($rec->getConsigneeBilled()) { $node->appendChild($xml->createElement('ConsigneeBilled')); } From e07dddbbef751c4bd3ce539453984051cdea0ac3 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Wed, 13 Apr 2022 10:37:00 +0200 Subject: [PATCH 3/4] Strip redundant methods from PaymentInformation These are only required on the ShipmentCharge, where it is then passed onto the XML creating logic. --- src/Entity/PaymentInformation.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Entity/PaymentInformation.php b/src/Entity/PaymentInformation.php index 0d5416cd..a4f7b7a9 100644 --- a/src/Entity/PaymentInformation.php +++ b/src/Entity/PaymentInformation.php @@ -94,25 +94,6 @@ public function setBillThirdParty(BillThirdParty $billThirdParty = null) return $this; } - /** - * @return BillThirdParty - */ - public function getBillThirdPartyConsignee() - { - return $this->billThirdPartyConsignee; - } - - /** - * @param BillThirdParty $billThirdPartyConsignee - * @return PaymentInformation - */ - public function setBillThirdPartyConsignee(BillThirdParty $billThirdPartyConsignee = null) - { - $this->billThirdPartyConsignee = $billThirdPartyConsignee; - - return $this; - } - /** * @return FreightCollect */ From 5e16315990fd816efb09b4c81eba46b2872ac63f Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Wed, 13 Apr 2022 10:48:14 +0200 Subject: [PATCH 4/4] Fix coding standards violations --- src/Entity/ShipmentCharge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/ShipmentCharge.php b/src/Entity/ShipmentCharge.php index cc358dcb..774f4d35 100644 --- a/src/Entity/ShipmentCharge.php +++ b/src/Entity/ShipmentCharge.php @@ -36,7 +36,7 @@ class ShipmentCharge /** * @var BillThirdParty */ - private $billThirdPartyConsignee; + private $billThirdPartyConsignee; /** * @var bool @@ -110,7 +110,7 @@ public function setBillThirdParty(BillThirdParty $billThirdParty = null) return $this; } - /** + /** * @return BillThirdParty */ public function getBillThirdPartyConsignee()