Tax.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Model\Sales\Pdf;
  7. class Tax extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
  8. {
  9. /**
  10. * @var \Magento\Tax\Model\Config
  11. */
  12. protected $_taxConfig;
  13. /**
  14. * @param \Magento\Tax\Helper\Data $taxHelper
  15. * @param \Magento\Tax\Model\Calculation $taxCalculation
  16. * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory
  17. * @param \Magento\Tax\Model\Config $taxConfig
  18. * @param array $data
  19. */
  20. public function __construct(
  21. \Magento\Tax\Helper\Data $taxHelper,
  22. \Magento\Tax\Model\Calculation $taxCalculation,
  23. \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory,
  24. \Magento\Tax\Model\Config $taxConfig,
  25. array $data = []
  26. ) {
  27. $this->_taxConfig = $taxConfig;
  28. parent::__construct($taxHelper, $taxCalculation, $ordersFactory, $data);
  29. }
  30. /**
  31. * Check if tax amount should be included to grandtotal block
  32. * array(
  33. * $index => array(
  34. * 'amount' => $amount,
  35. * 'label' => $label,
  36. * 'font_size'=> $font_size
  37. * )
  38. * )
  39. * @return array
  40. */
  41. public function getTotalsForDisplay()
  42. {
  43. $store = $this->getOrder()->getStore();
  44. if ($this->_taxConfig->displaySalesTaxWithGrandTotal($store)) {
  45. return [];
  46. }
  47. $totals = [];
  48. if ($this->_taxConfig->displaySalesFullSummary($store)) {
  49. $totals = $this->getFullTaxInfo();
  50. }
  51. $totals = array_merge($totals, parent::getTotalsForDisplay());
  52. return $totals;
  53. }
  54. }