Subtotal.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 Subtotal extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
  8. {
  9. /**
  10. * Get array of arrays with totals information for display in PDF
  11. * array(
  12. * $index => array(
  13. * 'amount' => $amount,
  14. * 'label' => $label,
  15. * 'font_size'=> $font_size
  16. * )
  17. * )
  18. * @return array
  19. */
  20. public function getTotalsForDisplay()
  21. {
  22. $store = $this->getOrder()->getStore();
  23. $helper = $this->_taxHelper;
  24. $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
  25. if ($this->getSource()->getSubtotalInclTax()) {
  26. $amountInclTax = $this->getSource()->getSubtotalInclTax();
  27. } else {
  28. $amountInclTax = $this->getAmount() +
  29. $this->getSource()->getTaxAmount() -
  30. $this->getSource()->getShippingTaxAmount();
  31. }
  32. $amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax);
  33. $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
  34. if ($helper->displaySalesSubtotalBoth($store)) {
  35. $totals = [
  36. [
  37. 'amount' => $this->getAmountPrefix() . $amount,
  38. 'label' => __('Subtotal (Excl. Tax)') . ':',
  39. 'font_size' => $fontSize,
  40. ],
  41. [
  42. 'amount' => $this->getAmountPrefix() . $amountInclTax,
  43. 'label' => __('Subtotal (Incl. Tax)') . ':',
  44. 'font_size' => $fontSize
  45. ],
  46. ];
  47. } elseif ($helper->displaySalesSubtotalInclTax($store)) {
  48. $totals = [
  49. [
  50. 'amount' => $this->getAmountPrefix() . $amountInclTax,
  51. 'label' => __($this->getTitle()) . ':',
  52. 'font_size' => $fontSize,
  53. ],
  54. ];
  55. } else {
  56. $totals = [
  57. [
  58. 'amount' => $this->getAmountPrefix() . $amount,
  59. 'label' => __($this->getTitle()) . ':',
  60. 'font_size' => $fontSize,
  61. ],
  62. ];
  63. }
  64. return $totals;
  65. }
  66. }