12
12
use Magento \MediaStorage \Helper \File \Storage \Database ;
13
13
use Magento \Sales \Model \RtlTextHandler ;
14
14
use Magento \Store \Model \ScopeInterface ;
15
+ use Magento \Tax \Helper \Data as TaxHelper ;
15
16
16
17
/**
17
18
* Sales Order PDF abstract model
@@ -131,6 +132,11 @@ abstract public function getPdf();
131
132
*/
132
133
protected $ addressRenderer ;
133
134
135
+ /**
136
+ * @var Magento\Tax\Helper\Data
137
+ */
138
+ private $ taxHelper ;
139
+
134
140
/**
135
141
* @var array $pageSettings
136
142
*/
@@ -156,6 +162,7 @@ abstract public function getPdf();
156
162
* @param Database $fileStorageDatabase
157
163
* @param RtlTextHandler|null $rtlTextHandler
158
164
* @param Image $image
165
+ * @param TaxHelper $taxHelper
159
166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
160
167
*/
161
168
public function __construct (
@@ -172,7 +179,8 @@ public function __construct(
172
179
array $ data = [],
173
180
Database $ fileStorageDatabase = null ,
174
181
?RtlTextHandler $ rtlTextHandler = null ,
175
- ?Image $ image = null
182
+ ?Image $ image = null ,
183
+ ?TaxHelper $ taxHelper = null
176
184
) {
177
185
$ this ->addressRenderer = $ addressRenderer ;
178
186
$ this ->_paymentData = $ paymentData ;
@@ -185,6 +193,7 @@ public function __construct(
185
193
$ this ->_pdfTotalFactory = $ pdfTotalFactory ;
186
194
$ this ->_pdfItemsFactory = $ pdfItemsFactory ;
187
195
$ this ->inlineTranslation = $ inlineTranslation ;
196
+ $ this ->taxHelper = $ taxHelper ?: ObjectManager::getInstance ()->get (TaxHelper::class);
188
197
$ this ->fileStorageDatabase = $ fileStorageDatabase ?: ObjectManager::getInstance ()->get (Database::class);
189
198
$ this ->rtlTextHandler = $ rtlTextHandler ?: ObjectManager::getInstance ()->get (RtlTextHandler::class);
190
199
$ this ->image = $ image ?: ObjectManager::getInstance ()->get (Image::class);
@@ -604,11 +613,18 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
604
613
}
605
614
606
615
$ 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 .= ") " ;
612
628
613
629
$ page ->drawText ($ totalShippingChargesText , 285 , $ yShipments - $ topMargin , 'UTF-8 ' );
614
630
$ yShipments -= $ topMargin + 10 ;
0 commit comments