Tax.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Tax report resource model
  8. */
  9. namespace Magento\Tax\Model\ResourceModel\Report;
  10. class Tax extends \Magento\Reports\Model\ResourceModel\Report\AbstractReport
  11. {
  12. /**
  13. * @var \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory
  14. */
  15. protected $_createdAtFactory;
  16. /**
  17. * @var \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory
  18. */
  19. protected $_updatedAtFactory;
  20. /**
  21. * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
  22. * @param \Psr\Log\LoggerInterface $logger
  23. * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
  24. * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
  25. * @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
  26. * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
  27. * @param \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory $createdAtFactory
  28. * @param \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory $updatedAtFactory
  29. * @param string $connectionName
  30. */
  31. public function __construct(
  32. \Magento\Framework\Model\ResourceModel\Db\Context $context,
  33. \Psr\Log\LoggerInterface $logger,
  34. \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
  35. \Magento\Reports\Model\FlagFactory $reportsFlagFactory,
  36. \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
  37. \Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
  38. \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory $createdAtFactory,
  39. \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory $updatedAtFactory,
  40. $connectionName = null
  41. ) {
  42. $this->_createdAtFactory = $createdAtFactory;
  43. $this->_updatedAtFactory = $updatedAtFactory;
  44. parent::__construct(
  45. $context,
  46. $logger,
  47. $localeDate,
  48. $reportsFlagFactory,
  49. $timezoneValidator,
  50. $dateTime,
  51. $connectionName
  52. );
  53. }
  54. /**
  55. * Resource initialization
  56. *
  57. * @return void
  58. */
  59. protected function _construct()
  60. {
  61. $this->_init('tax_order_aggregated_created', 'id');
  62. }
  63. /**
  64. * Aggregate Tax data
  65. *
  66. * @param mixed $from
  67. * @param mixed $to
  68. * @return $this
  69. */
  70. public function aggregate($from = null, $to = null)
  71. {
  72. /** @var $createdAt \Magento\Tax\Model\ResourceModel\Report\Tax\Createdat */
  73. $createdAt = $this->_createdAtFactory->create();
  74. /** @var $updatedAt \Magento\Tax\Model\ResourceModel\Report\Tax\Updatedat */
  75. $updatedAt = $this->_updatedAtFactory->create();
  76. $createdAt->aggregate($from, $to);
  77. $updatedAt->aggregate($from, $to);
  78. $this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_TAX_FLAG_CODE);
  79. return $this;
  80. }
  81. }