Skip to content

Commit 76362cf

Browse files
committed
Merge remote-tracking branch 'origin/AC-11798' into spartans_pr_04072024
2 parents eb21a4e + 18e679e commit 76362cf

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\MediaStorage\Helper\File\Storage\Database;
1313
use Magento\Sales\Model\RtlTextHandler;
1414
use Magento\Store\Model\ScopeInterface;
15+
use Magento\Tax\Helper\Data as TaxHelper;
1516

1617
/**
1718
* Sales Order PDF abstract model
@@ -131,6 +132,11 @@ abstract public function getPdf();
131132
*/
132133
protected $addressRenderer;
133134

135+
/**
136+
* @var Magento\Tax\Helper\Data
137+
*/
138+
private $taxHelper;
139+
134140
/**
135141
* @var array $pageSettings
136142
*/
@@ -156,6 +162,7 @@ abstract public function getPdf();
156162
* @param Database $fileStorageDatabase
157163
* @param RtlTextHandler|null $rtlTextHandler
158164
* @param Image $image
165+
* @param TaxHelper $taxHelper
159166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
160167
*/
161168
public function __construct(
@@ -172,7 +179,8 @@ public function __construct(
172179
array $data = [],
173180
Database $fileStorageDatabase = null,
174181
?RtlTextHandler $rtlTextHandler = null,
175-
?Image $image = null
182+
?Image $image = null,
183+
?TaxHelper $taxHelper = null
176184
) {
177185
$this->addressRenderer = $addressRenderer;
178186
$this->_paymentData = $paymentData;
@@ -185,6 +193,7 @@ public function __construct(
185193
$this->_pdfTotalFactory = $pdfTotalFactory;
186194
$this->_pdfItemsFactory = $pdfItemsFactory;
187195
$this->inlineTranslation = $inlineTranslation;
196+
$this->taxHelper = $taxHelper ?: ObjectManager::getInstance()->get(TaxHelper::class);
188197
$this->fileStorageDatabase = $fileStorageDatabase ?: ObjectManager::getInstance()->get(Database::class);
189198
$this->rtlTextHandler = $rtlTextHandler ?: ObjectManager::getInstance()->get(RtlTextHandler::class);
190199
$this->image = $image ?: ObjectManager::getInstance()->get(Image::class);
@@ -604,11 +613,18 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
604613
}
605614

606615
$yShipments = $this->y;
607-
$totalShippingChargesText = "("
608-
. __('Total Shipping Charges')
609-
. " "
610-
. $order->formatPriceTxt($order->getShippingAmount())
611-
. ")";
616+
$totalShippingChargesText = "(" . __('Total Shipping Charges') . " ";
617+
if ($this->taxHelper->displayShippingPriceIncludingTax()) {
618+
$totalShippingChargesText .= $order->formatPriceTxt($order->getShippingInclTax());
619+
} else {
620+
$totalShippingChargesText .= $order->formatPriceTxt($order->getShippingAmount());
621+
}
622+
623+
if ($this->taxHelper->displayShippingBothPrices()
624+
&& $order->getShippingInclTax() != $order->getShippingAmount()) {
625+
$totalShippingChargesText .= "(Incl. Tax " . $order->getShippingInclTax() . ")";
626+
}
627+
$totalShippingChargesText .= ")";
612628

613629
$page->drawText($totalShippingChargesText, 285, $yShipments - $topMargin, 'UTF-8');
614630
$yShipments -= $topMargin + 10;

app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Sales\Model\Order\Pdf\ItemsFactory;
2121
use Magento\Sales\Model\Order\Pdf\Total\DefaultTotal;
2222
use Magento\Sales\Model\Order\Pdf\Total\Factory;
23+
use Magento\Tax\Helper\Data as TaxHelper;
2324
use PHPUnit\Framework\TestCase;
2425

2526
/**
@@ -49,6 +50,7 @@ public function testInsertTotals()
4950
$filesystem = $this->createMock(Filesystem::class);
5051
$pdfItemsFactory = $this->createMock(ItemsFactory::class);
5152
$localeMock = $this->getMockForAbstractClass(TimezoneInterface::class);
53+
$taxHelper = $this->createMock(TaxHelper::class);
5254

5355
// Setup config file totals
5456
$configTotals = ['item1' => [''], 'item2' => ['model' => 'custom_class']];
@@ -98,7 +100,12 @@ public function testInsertTotals()
98100
$pdfItemsFactory,
99101
$localeMock,
100102
$translate,
101-
$addressRenderer
103+
$addressRenderer,
104+
[],
105+
null,
106+
null,
107+
null,
108+
$taxHelper
102109
],
103110
'',
104111
true,
@@ -134,6 +141,7 @@ public function testDrawLineBlocks()
134141
$localeMock = $this->getMockForAbstractClass(TimezoneInterface::class);
135142
$translate = $this->getMockForAbstractClass(StateInterface::class);
136143
$addressRenderer = $this->createMock(Renderer::class);
144+
$taxHelper = $this->createMock(TaxHelper::class);
137145

138146
$abstractPdfMock = $this->getMockForAbstractClass(
139147
AbstractPdf::class,
@@ -147,7 +155,12 @@ public function testDrawLineBlocks()
147155
$pdfItemsFactory,
148156
$localeMock,
149157
$translate,
150-
$addressRenderer
158+
$addressRenderer,
159+
[],
160+
null,
161+
null,
162+
null,
163+
$taxHelper
151164
],
152165
'',
153166
true,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf
1414
{
1515
/**
16-
* Carrier helper
17-
*
1816
* @var \Magento\Shipping\Helper\Carrier
1917
*/
2018
protected $_carrierHelper;
@@ -93,7 +91,7 @@ public function __construct(
9391
/**
9492
* Format pdf file
9593
*
96-
* @param null $shipment
94+
* @param void $shipment
9795
* @return \Zend_Pdf
9896
*/
9997
public function getPdf($shipment = null)

0 commit comments

Comments
 (0)