47 $this->_config = $taxConfig;
48 parent::__construct($context,
$data);
58 return $this->_config->displaySalesFullSummary($this->
getOrder()->
getStore());
76 public function initTotals()
80 $this->_order = $parent->getOrder();
81 $this->_source = $parent->getSource();
84 $allowTax = $this->_source->getTaxAmount() > 0 || $this->_config->displaySalesZeroTax(
$store);
85 $grandTotal = (double)$this->_source->getGrandTotal();
86 if (!$grandTotal || $allowTax && !$this->_config->displaySalesTaxWithGrandTotal(
$store)) {
103 protected function _addTax($after =
'discount')
105 $taxTotal = new \Magento\Framework\DataObject([
'code' =>
'tax',
'block_name' => $this->
getNameInLayout()]);
117 return $this->_order->getStore();
128 $subtotal = $parent->getTotal(
'subtotal');
132 if ($this->_config->displaySalesSubtotalBoth(
$store)) {
133 $subtotal = (double)$this->_source->getSubtotal();
134 $baseSubtotal = (double)$this->_source->getBaseSubtotal();
135 $subtotalIncl = (double)$this->_source->getSubtotalInclTax();
136 $baseSubtotalIncl = (double)$this->_source->getBaseSubtotalInclTax();
138 if (!$subtotalIncl || !$baseSubtotalIncl) {
140 $subtotalIncl = $subtotal
141 + $this->_source->getTaxAmount()
142 - $this->_source->getShippingTaxAmount();
143 $baseSubtotalIncl = $baseSubtotal
144 + $this->_source->getBaseTaxAmount()
145 - $this->_source->getBaseShippingTaxAmount();
147 if ($this->_source instanceof
Order) {
149 foreach ($this->_source->getAllItems() as
$item) {
150 $subtotalIncl +=
$item->getDiscountTaxCompensationAmount();
151 $baseSubtotalIncl +=
$item->getBaseDiscountTaxCompensationAmount();
156 $subtotalIncl = max(0, $subtotalIncl);
157 $baseSubtotalIncl = max(0, $baseSubtotalIncl);
158 $totalExcl = new \Magento\Framework\DataObject(
160 'code' =>
'subtotal_excl',
161 'value' => $subtotal,
162 'base_value' => $baseSubtotal,
163 'label' =>
__(
'Subtotal (Excl.Tax)'),
166 $totalIncl = new \Magento\Framework\DataObject(
168 'code' =>
'subtotal_incl',
169 'value' => $subtotalIncl,
170 'base_value' => $baseSubtotalIncl,
171 'label' =>
__(
'Subtotal (Incl.Tax)'),
174 $parent->addTotal($totalExcl,
'subtotal');
175 $parent->addTotal($totalIncl,
'subtotal_excl');
176 $parent->removeTotal(
'subtotal');
177 }
elseif ($this->_config->displaySalesSubtotalInclTax(
$store)) {
178 $subtotalIncl = (double)$this->_source->getSubtotalInclTax();
179 $baseSubtotalIncl = (double)$this->_source->getBaseSubtotalInclTax();
181 if (!$subtotalIncl) {
182 $subtotalIncl = $this->_source->getSubtotal() +
183 $this->_source->getTaxAmount() -
184 $this->_source->getShippingTaxAmount();
186 if (!$baseSubtotalIncl) {
187 $baseSubtotalIncl = $this->_source->getBaseSubtotal() +
188 $this->_source->getBaseTaxAmount() -
189 $this->_source->getBaseShippingTaxAmount();
192 $total = $parent->getTotal(
'subtotal');
194 $total->setValue(max(0, $subtotalIncl));
195 $total->setBaseValue(max(0, $baseSubtotalIncl));
208 $shipping = $parent->getTotal(
'shipping');
213 if ($this->_config->displaySalesShippingBoth(
$store)) {
214 $shipping = (double)$this->_source->getShippingAmount();
215 $baseShipping = (double)$this->_source->getBaseShippingAmount();
216 $shippingIncl = (double)$this->_source->getShippingInclTax();
217 if (!$shippingIncl) {
218 $shippingIncl = $shipping + (double)$this->_source->getShippingTaxAmount();
220 $baseShippingIncl = (double)$this->_source->getBaseShippingInclTax();
221 if (!$baseShippingIncl) {
222 $baseShippingIncl = $baseShipping + (double)$this->_source->getBaseShippingTaxAmount();
225 $totalExcl = new \Magento\Framework\DataObject(
227 'code' =>
'shipping',
228 'value' => $shipping,
229 'base_value' => $baseShipping,
230 'label' =>
__(
'Shipping & Handling (Excl.Tax)'),
233 $totalIncl = new \Magento\Framework\DataObject(
235 'code' =>
'shipping_incl',
236 'value' => $shippingIncl,
237 'base_value' => $baseShippingIncl,
238 'label' =>
__(
'Shipping & Handling (Incl.Tax)'),
241 $parent->addTotal($totalExcl,
'shipping');
242 $parent->addTotal($totalIncl,
'shipping');
243 }
elseif ($this->_config->displaySalesShippingInclTax(
$store)) {
244 $shippingIncl = $this->_source->getShippingInclTax();
245 if (!$shippingIncl) {
246 $shippingIncl = $this->_source->getShippingAmount() + $this->_source->getShippingTaxAmount();
248 $baseShippingIncl = $this->_source->getBaseShippingInclTax();
249 if (!$baseShippingIncl) {
250 $baseShippingIncl = $this->_source->getBaseShippingAmount() +
251 $this->_source->getBaseShippingTaxAmount();
253 $total = $parent->getTotal(
'shipping');
255 $total->setValue($shippingIncl);
256 $total->setBaseValue($baseShippingIncl);
276 $grandototal = $parent->getTotal(
'grand_total');
277 if (!$grandototal || !(
double)$this->_source->getGrandTotal()) {
281 if ($this->_config->displaySalesTaxWithGrandTotal(
$store)) {
282 $grandtotal = $this->_source->getGrandTotal();
283 $baseGrandtotal = $this->_source->getBaseGrandTotal();
284 $grandtotalExcl = $grandtotal - $this->_source->getTaxAmount();
285 $baseGrandtotalExcl = $baseGrandtotal - $this->_source->getBaseTaxAmount();
286 $grandtotalExcl = max($grandtotalExcl, 0);
287 $baseGrandtotalExcl = max($baseGrandtotalExcl, 0);
288 $totalExcl = new \Magento\Framework\DataObject(
290 'code' =>
'grand_total',
292 'value' => $grandtotalExcl,
293 'base_value' => $baseGrandtotalExcl,
294 'label' =>
__(
'Grand Total (Excl.Tax)'),
297 $totalIncl = new \Magento\Framework\DataObject(
299 'code' =>
'grand_total_incl',
301 'value' => $grandtotal,
302 'base_value' => $baseGrandtotal,
303 'label' =>
__(
'Grand Total (Incl.Tax)'),
306 $parent->addTotal($totalExcl,
'grand_total');
308 $parent->addTotal($totalIncl,
'tax');
elseif(isset( $params[ 'redirect_parent']))
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Model\Config $taxConfig, array $data=[])
_addTax($after='discount')