1212use Magento \MediaStorage \Helper \File \Storage \Database ;
1313use Magento \Sales \Model \RtlTextHandler ;
1414use 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 ;
0 commit comments