Skip to content

Commit f35a7a6

Browse files
committed
AC:11798::Shipping price showing diffrent in printed pdf
1 parent 5c8a657 commit f35a7a6

File tree

5 files changed

+40
-50
lines changed

5 files changed

+40
-50
lines changed

app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ abstract class AbstractPdf extends \Magento\Framework\DataObject
4646
* Predefined constants
4747
*/
4848
public const XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID = 'sales_pdf/invoice/put_order_id';
49+
4950
public const XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID = 'sales_pdf/shipment/put_order_id';
51+
5052
public const XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID = 'sales_pdf/creditmemo/put_order_id';
5153

5254
/**
@@ -133,7 +135,7 @@ abstract public function getPdf();
133135
/**
134136
* @var Magento\Tax\Helper\Data
135137
*/
136-
protected $taxHelper;
138+
private $taxHelper;
137139

138140
/**
139141
* @var array $pageSettings
@@ -156,8 +158,11 @@ abstract public function getPdf();
156158
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
157159
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
158160
* @param \Magento\Sales\Model\Order\Address\Renderer $addressRenderer
159-
* @param \Magento\Tax\Helper\Data $taxHelper
161+
* @param TaxHelper $taxHelper
160162
* @param array $data
163+
* @param Database $fileStorageDatabase
164+
* @param RtlTextHandler|null $rtlTextHandler
165+
* @param Image $image
161166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
162167
*/
163168
public function __construct(
@@ -171,8 +176,11 @@ public function __construct(
171176
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
172177
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
173178
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
174-
\Magento\Tax\Helper\Data $taxHelper,
175-
array $data = []
179+
TaxHelper $taxHelper = null,
180+
array $data = [],
181+
Database $fileStorageDatabase = null,
182+
?RtlTextHandler $rtlTextHandler = null,
183+
?Image $image = null
176184
) {
177185
$this->addressRenderer = $addressRenderer;
178186
$this->_paymentData = $paymentData;
@@ -185,46 +193,13 @@ public function __construct(
185193
$this->_pdfTotalFactory = $pdfTotalFactory;
186194
$this->_pdfItemsFactory = $pdfItemsFactory;
187195
$this->inlineTranslation = $inlineTranslation;
188-
$this->taxHelper = $taxHelper;
189-
190-
// Initialize optional dependencies using ObjectManager if not provided
191-
$objectManager = ObjectManager::getInstance();
192-
$this->fileStorageDatabase = $objectManager->get(Database::class);
193-
$this->rtlTextHandler = $objectManager->get(RtlTextHandler::class);
194-
$this->image = $objectManager->get(Image::class);
195-
196+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
197+
$this->fileStorageDatabase = $fileStorageDatabase ?: ObjectManager::getInstance()->get(Database::class);
198+
$this->rtlTextHandler = $rtlTextHandler ?: ObjectManager::getInstance()->get(RtlTextHandler::class);
199+
$this->image = $image ?: ObjectManager::getInstance()->get(Image::class);
196200
parent::__construct($data);
197201
}
198202

199-
/**
200-
* Set optional dependencies
201-
*
202-
* @param Database|null $fileStorageDatabase
203-
* @param RtlTextHandler|null $rtlTextHandler
204-
* @param Image|null $image
205-
* @return void
206-
*/
207-
public function setOptionalDependencies(
208-
Database $fileStorageDatabase = null,
209-
RtlTextHandler $rtlTextHandler = null,
210-
Image $image = null
211-
212-
)
213-
{
214-
if ($fileStorageDatabase) {
215-
$this->fileStorageDatabase = $fileStorageDatabase;
216-
}
217-
if ($rtlTextHandler) {
218-
$this->rtlTextHandler = $rtlTextHandler;
219-
}
220-
if ($image) {
221-
$this->image = $image;
222-
}
223-
224-
}
225-
226-
227-
228203
/**
229204
* Returns the total width in points of the string using the specified font and size.
230205
*
@@ -645,7 +620,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
645620
$totalShippingChargesText .= $order->formatPriceTxt($order->getShippingAmount());
646621
}
647622

648-
if($this->taxHelper->displayShippingBothPrices() && $order->getShippingInclTax() != $order->getShippingAmount()) {
623+
if ($this->taxHelper->displayShippingBothPrices()
624+
&& $order->getShippingInclTax() != $order->getShippingAmount()) {
649625
$totalShippingChargesText .= "(Incl. Tax " . $order->getShippingInclTax() . ")";
650626
}
651627
$totalShippingChargesText .= ")";

app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Magento\Sales\Model\Order\Pdf;
1010

11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Tax\Helper\Data as TaxHelper;
13+
1114
/**
1215
* Sales Order Creditmemo PDF model
1316
*
@@ -55,13 +58,14 @@ public function __construct(
5558
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
5659
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
5760
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
58-
\Magento\Tax\Helper\Data $taxHelper,
61+
TaxHelper $taxHelper = null,
5962
\Magento\Store\Model\StoreManagerInterface $storeManager,
6063
\Magento\Store\Model\App\Emulation $appEmulation,
6164
array $data = []
6265
) {
6366
$this->_storeManager = $storeManager;
6467
$this->appEmulation = $appEmulation;
68+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
6569
parent::__construct(
6670
$paymentData,
6771
$string,
@@ -73,7 +77,7 @@ public function __construct(
7377
$localeDate,
7478
$inlineTranslation,
7579
$addressRenderer,
76-
$taxHelper,
80+
$this->taxHelper,
7781
$data
7882
);
7983
}

app/code/Magento/Sales/Model/Order/Pdf/Invoice.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Sales\Model\Order\Pdf;
77

88
use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Tax\Helper\Data as TaxHelper;
911

1012
/**
1113
* Sales Order Invoice PDF model
@@ -52,13 +54,14 @@ public function __construct(
5254
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
5355
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
5456
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
55-
\Magento\Tax\Helper\Data $taxHelper,
57+
TaxHelper $taxHelper = null,
5658
\Magento\Store\Model\StoreManagerInterface $storeManager,
5759
\Magento\Store\Model\App\Emulation $appEmulation,
5860
array $data = []
5961
) {
6062
$this->_storeManager = $storeManager;
6163
$this->appEmulation = $appEmulation;
64+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
6265
parent::__construct(
6366
$paymentData,
6467
$string,
@@ -70,7 +73,7 @@ public function __construct(
7073
$localeDate,
7174
$inlineTranslation,
7275
$addressRenderer,
73-
$taxHelper,
76+
$this->taxHelper,
7477
$data
7578
);
7679
}

app/code/Magento/Sales/Model/Order/Pdf/Shipment.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Sales\Model\Order\Pdf;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Tax\Helper\Data as TaxHelper;
10+
811
/**
912
* Sales Order Shipment PDF model
1013
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -50,13 +53,14 @@ public function __construct(
5053
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
5154
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
5255
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
53-
\Magento\Tax\Helper\Data $taxHelper,
56+
TaxHelper $taxHelper = null,
5457
\Magento\Store\Model\StoreManagerInterface $storeManager,
5558
\Magento\Store\Model\App\Emulation $appEmulation,
5659
array $data = []
5760
) {
5861
$this->_storeManager = $storeManager;
5962
$this->appEmulation = $appEmulation;
63+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
6064
parent::__construct(
6165
$paymentData,
6266
$string,
@@ -68,7 +72,7 @@ public function __construct(
6872
$localeDate,
6973
$inlineTranslation,
7074
$addressRenderer,
71-
$taxHelper,
75+
$this->taxHelper,
7276
$data
7377
);
7478
}

app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Shipping\Model\Order\Pdf;
77

88
use Magento\Shipping\Helper\Carrier;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Tax\Helper\Data as TaxHelper;
911

1012
/**
1113
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -63,7 +65,7 @@ public function __construct(
6365
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
6466
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
6567
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
66-
\Magento\Tax\Helper\Data $taxHelper,
68+
TaxHelper $taxHelper = null,
6769
Carrier $carrierHelper,
6870
\Magento\Store\Model\StoreManagerInterface $storeManager,
6971
\Magento\Framework\View\LayoutInterface $layout,
@@ -74,6 +76,7 @@ public function __construct(
7476
$this->_storeManager = $storeManager;
7577
$this->_layout = $layout;
7678
$this->_localeResolver = $localeResolver;
79+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
7780

7881
parent::__construct(
7982
$paymentData,
@@ -86,7 +89,7 @@ public function __construct(
8689
$localeDate,
8790
$inlineTranslation,
8891
$addressRenderer,
89-
$taxHelper,
92+
$this->taxHelper,
9093
$data
9194
);
9295
}

0 commit comments

Comments
 (0)