WeeeTaxTest.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Test\Unit\Model\Total\Quote;
  7. use Magento\Tax\Model\Calculation;
  8. use Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector as CTC;
  9. /**
  10. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  11. */
  12. class WeeeTaxTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**#@+
  15. * Constants for array keys
  16. */
  17. const KEY_WEEE_TOTALS = 'weee_total_excl_tax';
  18. const KEY_WEEE_BASE_TOTALS = 'weee_base_total_excl_tax';
  19. /**#@-*/
  20. /**
  21. * @var \Magento\Weee\Model\Total\Quote\WeeeTax
  22. */
  23. protected $weeeCollector;
  24. /**
  25. * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Quote\Model\Quote
  26. */
  27. protected $quoteMock;
  28. /**
  29. * \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  30. */
  31. protected $objectManagerHelper;
  32. protected function setUp()
  33. {
  34. $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  35. $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
  36. }
  37. /**
  38. * Setup tax helper with an array of methodName, returnValue
  39. *
  40. * @param array $taxConfig
  41. * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Helper\Data
  42. */
  43. protected function setupTaxHelper($taxConfig)
  44. {
  45. $taxHelper = $this->createMock(\Magento\Tax\Helper\Data::class);
  46. foreach ($taxConfig as $method => $value) {
  47. $taxHelper->expects($this->any())->method($method)->will($this->returnValue($value));
  48. }
  49. return $taxHelper;
  50. }
  51. /**
  52. * Setup weee helper with an array of methodName, returnValue
  53. *
  54. * @param array $weeeConfig
  55. * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Weee\Helper\Data
  56. */
  57. protected function setupWeeeHelper($weeeConfig)
  58. {
  59. $weeeHelper = $this->createMock(\Magento\Weee\Helper\Data::class);
  60. foreach ($weeeConfig as $method => $value) {
  61. $weeeHelper->expects($this->any())->method($method)->will($this->returnValue($value));
  62. }
  63. return $weeeHelper;
  64. }
  65. /**
  66. * Setup an item mock
  67. *
  68. * @param float $itemQty
  69. * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item
  70. */
  71. protected function setupItemMock($itemQty)
  72. {
  73. $itemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [
  74. 'getProduct',
  75. 'getQuote',
  76. 'getAddress',
  77. 'getTotalQty',
  78. '__wakeup',
  79. ]);
  80. $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
  81. $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock));
  82. $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($itemQty));
  83. return $itemMock;
  84. }
  85. /**
  86. * Setup address mock
  87. *
  88. * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item $itemMock
  89. * @param boolean $isWeeeTaxable
  90. * @param array $itemWeeeTaxDetails
  91. * @param array $addressData
  92. * @return \PHPUnit_Framework_MockObject_MockObject
  93. */
  94. protected function setupTotalMock($itemMock, $isWeeeTaxable, $itemWeeeTaxDetails, $addressData)
  95. {
  96. $totalMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Total::class, [
  97. '__wakeup',
  98. 'getWeeeCodeToItemMap',
  99. 'getExtraTaxableDetails',
  100. 'getWeeeTotalExclTax',
  101. 'getWeeeBaseTotalExclTax',
  102. ]);
  103. $map = [];
  104. $extraDetails = [];
  105. $weeeTotals = 0;
  106. $weeeBaseTotals = 0;
  107. if ($isWeeeTaxable) {
  108. $i = 1;
  109. $weeeTaxDetails = [];
  110. foreach ($itemWeeeTaxDetails as $itemData) {
  111. $code = 'weee' . $i++ . '-myWeeeCode';
  112. $map[$code] = $itemMock;
  113. $weeeTaxDetails[] = [
  114. CTC::KEY_TAX_DETAILS_TYPE => 'weee',
  115. CTC::KEY_TAX_DETAILS_CODE => $code,
  116. CTC::KEY_TAX_DETAILS_PRICE_EXCL_TAX => $itemData['weee_tax_applied_amount'],
  117. CTC::KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX => $itemData['base_weee_tax_applied_amount'],
  118. CTC::KEY_TAX_DETAILS_PRICE_INCL_TAX => $itemData['weee_tax_applied_amount_incl_tax'],
  119. CTC::KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX =>
  120. $itemData['base_weee_tax_applied_amount_incl_tax'],
  121. CTC::KEY_TAX_DETAILS_ROW_TOTAL => $itemData['weee_tax_applied_row_amount'],
  122. CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL => $itemData['base_weee_tax_applied_row_amnt'],
  123. CTC::KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX =>
  124. $itemData['weee_tax_applied_row_amount_incl_tax'],
  125. CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX =>
  126. $itemData['base_weee_tax_applied_row_amnt_incl_tax'],
  127. ];
  128. }
  129. $extraDetails = [
  130. 'weee' => [
  131. 'sequence-1' => $weeeTaxDetails
  132. ],
  133. ];
  134. } else {
  135. if (isset($addressData[self::KEY_WEEE_TOTALS])) {
  136. $weeeTotals = $addressData[self::KEY_WEEE_TOTALS];
  137. }
  138. if (isset($addressData[self::KEY_WEEE_BASE_TOTALS])) {
  139. $weeeBaseTotals = $addressData[self::KEY_WEEE_BASE_TOTALS];
  140. }
  141. }
  142. $totalMock->expects($this->any())->method('getWeeeCodeToItemMap')->will($this->returnValue($map));
  143. $totalMock->expects($this->any())->method('getExtraTaxableDetails')->will($this->returnValue($extraDetails));
  144. $totalMock
  145. ->expects($this->any())
  146. ->method('getWeeeTotalExclTax')
  147. ->will($this->returnValue($weeeTotals));
  148. $totalMock
  149. ->expects($this->any())
  150. ->method('getWeeeBaseTotalExclTax')
  151. ->will($this->returnValue($weeeBaseTotals));
  152. return $totalMock;
  153. }
  154. /**
  155. * Setup shipping assignment mock.
  156. * @param \PHPUnit_Framework_MockObject_MockObject $addressMock
  157. * @param \PHPUnit_Framework_MockObject_MockObject $itemMock
  158. * @return \PHPUnit_Framework_MockObject_MockObject
  159. */
  160. protected function setupShippingAssignmentMock($addressMock, $itemMock)
  161. {
  162. $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class);
  163. $shippingMock->expects($this->any())->method('getAddress')->willReturn($addressMock);
  164. $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class);
  165. $itemMock = $itemMock ? [$itemMock] : [];
  166. $shippingAssignmentMock->expects($this->any())->method('getItems')->willReturn($itemMock);
  167. $shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shippingMock);
  168. return $shippingAssignmentMock;
  169. }
  170. /**
  171. * Verify that correct fields of item has been set
  172. *
  173. * @param \PHPUnit_Framework_MockObject_MockObject|null $item
  174. * @param array $itemData
  175. */
  176. public function verifyItem($item, $itemData)
  177. {
  178. if (!$item) {
  179. return;
  180. }
  181. foreach ($itemData as $key => $value) {
  182. $this->assertEquals($value, $item->getData($key), 'item ' . $key . ' is incorrect');
  183. }
  184. }
  185. /**
  186. * Verify that correct fields of address has been set
  187. *
  188. * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address
  189. * @param array $addressData
  190. */
  191. public function verifyTotals($address, $addressData)
  192. {
  193. foreach ($addressData as $key => $value) {
  194. if ($key != self::KEY_WEEE_TOTALS && $key != self::KEY_WEEE_BASE_TOTALS) {
  195. // just check the output values
  196. $this->assertEquals($value, $address->getData($key), 'address ' . $key . ' is incorrect');
  197. }
  198. }
  199. }
  200. public function testFetch()
  201. {
  202. $serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
  203. $weeeTotal = 17;
  204. $totalMock = new \Magento\Quote\Model\Quote\Address\Total(
  205. [],
  206. $serializerMock
  207. );
  208. $taxHelper = $this->setupTaxHelper([]);
  209. $weeeHelper = $this->setupWeeeHelper(['getTotalAmounts' => $weeeTotal]);
  210. $this->weeeCollector = $this->objectManagerHelper->getObject(
  211. \Magento\Weee\Model\Total\Quote\WeeeTax::class,
  212. ['taxData' => $taxHelper, 'weeeData' => $weeeHelper]
  213. );
  214. $expectedResult = [
  215. 'code' => 'weee',
  216. 'title' => __('FPT'),
  217. 'value' => $weeeTotal,
  218. 'area' => null,
  219. ];
  220. $this->assertEquals($expectedResult, $this->weeeCollector->fetch($this->quoteMock, $totalMock));
  221. }
  222. public function testFetchWithZeroAmounts()
  223. {
  224. $serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
  225. $totalMock = new \Magento\Quote\Model\Quote\Address\Total(
  226. [],
  227. $serializerMock
  228. );
  229. $taxHelper = $this->setupTaxHelper([]);
  230. $weeeHelper = $this->setupWeeeHelper(['getTotalAmounts' => null]);
  231. $this->weeeCollector = $this->objectManagerHelper->getObject(
  232. \Magento\Weee\Model\Total\Quote\WeeeTax::class,
  233. ['taxData' => $taxHelper, 'weeeData' => $weeeHelper]
  234. );
  235. $this->assertNull($this->weeeCollector->fetch($this->quoteMock, $totalMock));
  236. }
  237. /**
  238. * Test the collect function of the weee collector
  239. *
  240. * @param array $taxConfig
  241. * @param array $weeeConfig
  242. * @param array $itemWeeeTaxDetails
  243. * @param float $itemQty
  244. * @param array $addressData
  245. * @dataProvider collectDataProvider
  246. */
  247. public function testCollect($taxConfig, $weeeConfig, $itemWeeeTaxDetails, $itemQty, $addressData = [])
  248. {
  249. //Setup
  250. if ($itemQty > 0) {
  251. $itemMock = $this->setupItemMock($itemQty);
  252. } else {
  253. $itemMock = null;
  254. }
  255. $totalMock = $this->setupTotalMock($itemMock, $weeeConfig['isTaxable'], $itemWeeeTaxDetails, $addressData);
  256. $addressMock = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
  257. $shippingAssignmentMock = $this->setupShippingAssignmentMock($addressMock, $itemMock);
  258. $taxHelper = $this->setupTaxHelper($taxConfig);
  259. $weeeHelper = $this->setupWeeeHelper($weeeConfig);
  260. $arguments = [
  261. 'taxData' => $taxHelper,
  262. 'weeeData' => $weeeHelper,
  263. ];
  264. $this->weeeCollector = $this->objectManagerHelper->getObject(
  265. \Magento\Weee\Model\Total\Quote\WeeeTax::class,
  266. $arguments
  267. );
  268. //Execute
  269. $this->weeeCollector->collect($this->quoteMock, $shippingAssignmentMock, $totalMock);
  270. //Verify
  271. $summed = [];
  272. foreach ($itemWeeeTaxDetails as $itemWeeeTaxDetail) {
  273. foreach ($itemWeeeTaxDetail as $key => $value) {
  274. $summed[$key] = (array_key_exists($key, $summed) ? $value + $summed[$key] : $value);
  275. }
  276. }
  277. $this->verifyItem($itemMock, $summed);
  278. $this->verifyTotals($totalMock, $addressData);
  279. }
  280. /**
  281. * Data provider for testCollect
  282. *
  283. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  284. * Multiple datasets
  285. *
  286. * @return array
  287. */
  288. public function collectDataProvider()
  289. {
  290. // 1. When the Weee is not taxable, this collector does not change the item, but it will update the address
  291. // data based on the weee totals accumulated in the previous 'weee' collector
  292. // 2. If the Weee amount is included in the subtotal, then it is not included in the 'weee_amount' field
  293. $data = [];
  294. $data['price_incl_tax_weee_taxable_unit_included_in_subtotal'] = [
  295. 'tax_config' => [
  296. 'priceIncludesTax' => true,
  297. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  298. ],
  299. 'weee_config' => [
  300. 'isEnabled' => true,
  301. 'includeInSubtotal' => true,
  302. 'isTaxable' => true,
  303. 'getApplied' => [],
  304. ],
  305. 'item_weee_tax_details' => [
  306. [
  307. 'weee_tax_applied_amount' => 9.24,
  308. 'base_weee_tax_applied_amount' => 9.24,
  309. 'weee_tax_applied_row_amount' => 18.48,
  310. 'base_weee_tax_applied_row_amnt' => 18.48,
  311. 'weee_tax_applied_amount_incl_tax' => 10,
  312. 'base_weee_tax_applied_amount_incl_tax' => 10,
  313. 'weee_tax_applied_row_amount_incl_tax' => 20,
  314. 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
  315. ],
  316. ],
  317. 'item_qty' => 2,
  318. 'address_data' => [
  319. 'subtotal' => 18.48,
  320. 'base_subtotal' => 18.48,
  321. 'subtotal_incl_tax' => 20,
  322. 'base_subtotal_incl_tax' => 20,
  323. 'weee_amount' => 0,
  324. 'base_weee_amount' => 0,
  325. ],
  326. ];
  327. $data['price_incl_tax_weee_taxable_unit_not_included_in_subtotal'] = [
  328. 'tax_config' => [
  329. 'priceIncludesTax' => true,
  330. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  331. ],
  332. 'weee_config' => [
  333. 'isEnabled' => true,
  334. 'includeInSubtotal' => false,
  335. 'isTaxable' => true,
  336. 'getApplied' => [],
  337. ],
  338. 'item_weee_tax_details' => [
  339. [
  340. 'weee_tax_applied_amount' => 9.24,
  341. 'base_weee_tax_applied_amount' => 9.24,
  342. 'weee_tax_applied_row_amount' => 18.48,
  343. 'base_weee_tax_applied_row_amnt' => 18.48,
  344. 'weee_tax_applied_amount_incl_tax' => 10,
  345. 'base_weee_tax_applied_amount_incl_tax' => 10,
  346. 'weee_tax_applied_row_amount_incl_tax' => 20,
  347. 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
  348. ],
  349. ],
  350. 'item_qty' => 2,
  351. 'address_data' => [
  352. 'subtotal' => 0,
  353. 'base_subtotal' => 0,
  354. 'subtotal_incl_tax' => 20,
  355. 'base_subtotal_incl_tax' => 20,
  356. 'weee_amount' => 18.48,
  357. 'base_weee_amount' => 18.48,
  358. ],
  359. ];
  360. $data['price_excl_tax_weee_taxable_unit_included_in_subtotal'] = [
  361. 'tax_config' => [
  362. 'priceIncludesTax' => false,
  363. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  364. ],
  365. 'weee_config' => [
  366. 'isEnabled' => true,
  367. 'includeInSubtotal' => true,
  368. 'isTaxable' => true,
  369. 'getApplied' => [],
  370. ],
  371. 'item_weee_tax_details' => [
  372. [
  373. 'weee_tax_applied_amount' => 10,
  374. 'base_weee_tax_applied_amount' => 10,
  375. 'weee_tax_applied_row_amount' => 20,
  376. 'base_weee_tax_applied_row_amnt' => 20,
  377. 'weee_tax_applied_amount_incl_tax' => 10.83,
  378. 'base_weee_tax_applied_amount_incl_tax' => 10.83,
  379. 'weee_tax_applied_row_amount_incl_tax' => 21.66,
  380. 'base_weee_tax_applied_row_amnt_incl_tax' => 21.66,
  381. ],
  382. ],
  383. 'item_qty' => 2,
  384. 'address_data' => [
  385. 'subtotal' => 20,
  386. 'base_subtotal' => 20,
  387. 'subtotal_incl_tax' => 21.66,
  388. 'base_subtotal_incl_tax' => 21.66,
  389. 'weee_amount' => 0,
  390. 'base_weee_amount' => 0,
  391. ],
  392. ];
  393. $data['price_incl_tax_weee_non_taxable_unit_included_in_subtotal'] = [
  394. 'tax_config' => [
  395. 'priceIncludesTax' => true,
  396. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  397. ],
  398. 'weee_config' => [
  399. 'isEnabled' => true,
  400. 'includeInSubtotal' => true,
  401. 'isTaxable' => false,
  402. 'getApplied' => [],
  403. ],
  404. 'item_weee_tax_details' => [
  405. ],
  406. 'item_qty' => 2,
  407. 'address_data' => [
  408. self::KEY_WEEE_TOTALS => 20,
  409. self::KEY_WEEE_BASE_TOTALS => 20,
  410. 'subtotal' => 20,
  411. 'base_subtotal' => 20,
  412. 'subtotal_incl_tax' => 20,
  413. 'base_subtotal_incl_tax' => 20,
  414. 'weee_amount' => 0,
  415. 'base_weee_amount' => 0,
  416. ],
  417. ];
  418. $data['price_excl_tax_weee_non_taxable_unit_include_in_subtotal'] = [
  419. 'tax_config' => [
  420. 'priceIncludesTax' => false,
  421. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  422. ],
  423. 'weee_config' => [
  424. 'isEnabled' => true,
  425. 'includeInSubtotal' => true,
  426. 'isTaxable' => false,
  427. 'getApplied' => [],
  428. ],
  429. 'item_weee_tax_details' => [
  430. ],
  431. 'item_qty' => 2,
  432. 'address_data' => [
  433. self::KEY_WEEE_TOTALS => 20,
  434. self::KEY_WEEE_BASE_TOTALS => 20,
  435. 'subtotal' => 20,
  436. 'base_subtotal' => 20,
  437. 'subtotal_incl_tax' => 20,
  438. 'base_subtotal_incl_tax' => 20,
  439. 'weee_amount' => 0,
  440. 'base_weee_amount' => 0,
  441. ],
  442. ];
  443. $data['price_incl_tax_weee_taxable_row_include_in_subtotal'] = [
  444. 'tax_config' => [
  445. 'priceIncludesTax' => true,
  446. 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
  447. ],
  448. 'weee_config' => [
  449. 'isEnabled' => true,
  450. 'includeInSubtotal' => true,
  451. 'isTaxable' => true,
  452. 'getApplied' => [],
  453. ],
  454. 'item_weee_tax_details' => [
  455. [
  456. 'weee_tax_applied_amount' => 9.24,
  457. 'base_weee_tax_applied_amount' => 9.24,
  458. 'weee_tax_applied_row_amount' => 18.48,
  459. 'base_weee_tax_applied_row_amnt' => 18.48,
  460. 'weee_tax_applied_amount_incl_tax' => 10,
  461. 'base_weee_tax_applied_amount_incl_tax' => 10,
  462. 'weee_tax_applied_row_amount_incl_tax' => 20,
  463. 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
  464. ],
  465. ],
  466. 'item_qty' => 2,
  467. 'address_data' => [
  468. 'subtotal' => 18.48,
  469. 'base_subtotal' => 18.48,
  470. 'subtotal_incl_tax' => 20,
  471. 'base_subtotal_incl_tax' => 20,
  472. 'weee_amount' => 0,
  473. 'base_weee_amount' => 0,
  474. ],
  475. ];
  476. $data['price_excl_tax_weee_taxable_row_include_in_subtotal'] = [
  477. 'tax_config' => [
  478. 'priceIncludesTax' => false,
  479. 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
  480. ],
  481. 'weee_config' => [
  482. 'isEnabled' => true,
  483. 'includeInSubtotal' => true,
  484. 'isTaxable' => true,
  485. 'getApplied' => [],
  486. ],
  487. 'item_weee_tax_details' => [
  488. [
  489. 'weee_tax_applied_amount' => 10,
  490. 'base_weee_tax_applied_amount' => 10,
  491. 'weee_tax_applied_row_amount' => 20,
  492. 'base_weee_tax_applied_row_amnt' => 20,
  493. 'weee_tax_applied_amount_incl_tax' => 10.83,
  494. 'base_weee_tax_applied_amount_incl_tax' => 10.83,
  495. 'weee_tax_applied_row_amount_incl_tax' => 21.65,
  496. 'base_weee_tax_applied_row_amnt_incl_tax' => 21.65,
  497. ],
  498. ],
  499. 'item_qty' => 2,
  500. 'address_data' => [
  501. 'subtotal' => 20,
  502. 'base_subtotal' => 20,
  503. 'subtotal_incl_tax' => 21.65,
  504. 'base_subtotal_incl_tax' => 21.65,
  505. 'weee_amount' => 0,
  506. 'base_weee_amount' => 0,
  507. ],
  508. ];
  509. $data['price_incl_tax_weee_non_taxable_row_include_in_subtotal'] = [
  510. 'tax_config' => [
  511. 'priceIncludesTax' => true,
  512. 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
  513. ],
  514. 'weee_config' => [
  515. 'isEnabled' => true,
  516. 'includeInSubtotal' => true,
  517. 'isTaxable' => false,
  518. 'getApplied' => [],
  519. ],
  520. 'item_weee_tax_details' => [
  521. ],
  522. 'item_qty' => 2,
  523. 'address_data' => [
  524. self::KEY_WEEE_TOTALS => 20,
  525. self::KEY_WEEE_BASE_TOTALS => 20,
  526. 'subtotal' => 20,
  527. 'base_subtotal' => 20,
  528. 'subtotal_incl_tax' => 20,
  529. 'base_subtotal_incl_tax' => 20,
  530. 'weee_amount' => 0,
  531. 'base_weee_amount' => 0,
  532. ],
  533. ];
  534. $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal'] = [
  535. 'tax_config' => [
  536. 'priceIncludesTax' => false,
  537. 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
  538. ],
  539. 'weee_config' => [
  540. 'isEnabled' => true,
  541. 'includeInSubtotal' => false,
  542. 'isTaxable' => false,
  543. 'getApplied' => [],
  544. ],
  545. 'item_weee_tax_details' => [
  546. ],
  547. 'item_qty' => 2,
  548. 'address_data' => [
  549. self::KEY_WEEE_TOTALS => 20,
  550. self::KEY_WEEE_BASE_TOTALS => 20,
  551. 'subtotal' => 0,
  552. 'base_subtotal' => 0,
  553. 'subtotal_incl_tax' => 20,
  554. 'base_subtotal_incl_tax' => 20,
  555. 'weee_amount' => 20,
  556. 'base_weee_amount' => 20,
  557. ],
  558. ];
  559. $data['price_excl_tax_weee_taxable_unit_not_included_in_subtotal'] = [
  560. 'tax_config' => [
  561. 'priceIncludesTax' => false,
  562. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  563. ],
  564. 'weee_config' => [
  565. 'isEnabled' => true,
  566. 'includeInSubtotal' => false,
  567. 'isTaxable' => true,
  568. 'getApplied' => [],
  569. ],
  570. 'item_weee_tax_details' => [
  571. [
  572. 'weee_tax_applied_amount' => 10,
  573. 'base_weee_tax_applied_amount' => 10,
  574. 'weee_tax_applied_row_amount' => 20,
  575. 'base_weee_tax_applied_row_amnt' => 20,
  576. 'weee_tax_applied_amount_incl_tax' => 11.00,
  577. 'base_weee_tax_applied_amount_incl_tax' => 11.00,
  578. 'weee_tax_applied_row_amount_incl_tax' => 22.00,
  579. 'base_weee_tax_applied_row_amnt_incl_tax' => 22.00,
  580. ],
  581. [
  582. 'weee_tax_applied_amount' => 2,
  583. 'base_weee_tax_applied_amount' => 2,
  584. 'weee_tax_applied_row_amount' => 4,
  585. 'base_weee_tax_applied_row_amnt' => 4,
  586. 'weee_tax_applied_amount_incl_tax' => 2.20,
  587. 'base_weee_tax_applied_amount_incl_tax' => 2.20,
  588. 'weee_tax_applied_row_amount_incl_tax' => 4.40,
  589. 'base_weee_tax_applied_row_amnt_incl_tax' => 4.40,
  590. ],
  591. ],
  592. 'item_qty' => 2,
  593. 'address_data' => [
  594. 'subtotal' => 0,
  595. 'base_subtotal' => 0,
  596. 'subtotal_incl_tax' => 26.40,
  597. 'base_subtotal_incl_tax' => 26.40,
  598. 'weee_amount' => 24,
  599. 'base_weee_amount' => 24,
  600. ],
  601. ];
  602. $data['weee_disabled'] = [
  603. 'tax_config' => [
  604. 'priceIncludesTax' => false,
  605. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  606. ],
  607. 'weee_config' => [
  608. 'isEnabled' => false,
  609. 'includeInSubtotal' => false,
  610. 'isTaxable' => true,
  611. 'getApplied' => [],
  612. ],
  613. 'item_weee_tax_details' => [
  614. [
  615. 'weee_tax_applied_amount' => null,
  616. 'base_weee_tax_applied_amount' => null,
  617. 'weee_tax_applied_row_amount' => null,
  618. 'base_weee_tax_applied_row_amnt' => null,
  619. 'weee_tax_applied_amount_incl_tax' => null,
  620. 'base_weee_tax_applied_amount_incl_tax' => null,
  621. 'weee_tax_applied_row_amount_incl_tax' => null,
  622. 'base_weee_tax_applied_row_amnt_incl_tax' => null,
  623. ],
  624. [
  625. 'weee_tax_applied_amount' => null,
  626. 'base_weee_tax_applied_amount' => null,
  627. 'weee_tax_applied_row_amount' => null,
  628. 'base_weee_tax_applied_row_amnt' => null,
  629. 'weee_tax_applied_amount_incl_tax' => null,
  630. 'base_weee_tax_applied_amount_incl_tax' => null,
  631. 'weee_tax_applied_row_amount_incl_tax' => null,
  632. 'base_weee_tax_applied_row_amnt_incl_tax' => null,
  633. ],
  634. ],
  635. 'item_qty' => 1,
  636. 'address_data' => [
  637. 'subtotal' => null,
  638. 'base_subtotal' => null,
  639. 'subtotal_incl_tax' => null,
  640. 'base_subtotal_incl_tax' => null,
  641. 'weee_amount' => null,
  642. 'base_weee_amount' => null,
  643. ],
  644. ];
  645. $data['zero_items'] = [
  646. 'tax_config' => [
  647. 'priceIncludesTax' => false,
  648. 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
  649. ],
  650. 'weee_config' => [
  651. 'isEnabled' => true,
  652. 'includeInSubtotal' => false,
  653. 'isTaxable' => true,
  654. 'getApplied' => [],
  655. ],
  656. 'item_weee_tax_details' => [
  657. [
  658. 'weee_tax_applied_amount' => null,
  659. 'base_weee_tax_applied_amount' => null,
  660. 'weee_tax_applied_row_amount' => null,
  661. 'base_weee_tax_applied_row_amnt' => null,
  662. 'weee_tax_applied_amount_incl_tax' => null,
  663. 'base_weee_tax_applied_amount_incl_tax' => null,
  664. 'weee_tax_applied_row_amount_incl_tax' => null,
  665. 'base_weee_tax_applied_row_amnt_incl_tax' => null,
  666. ],
  667. [
  668. 'weee_tax_applied_amount' => null,
  669. 'base_weee_tax_applied_amount' => null,
  670. 'weee_tax_applied_row_amount' => null,
  671. 'base_weee_tax_applied_row_amnt' => null,
  672. 'weee_tax_applied_amount_incl_tax' => null,
  673. 'base_weee_tax_applied_amount_incl_tax' => null,
  674. 'weee_tax_applied_row_amount_incl_tax' => null,
  675. 'base_weee_tax_applied_row_amnt_incl_tax' => null,
  676. ],
  677. ],
  678. 'item_qty' => 0,
  679. 'address_data' => [
  680. 'subtotal' => null,
  681. 'base_subtotal' => null,
  682. 'subtotal_incl_tax' => null,
  683. 'base_subtotal_incl_tax' => null,
  684. 'weee_amount' => null,
  685. 'base_weee_amount' => null,
  686. ],
  687. ];
  688. return $data;
  689. }
  690. }