AvizeItemFactory.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * 2007-2021 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Academic Free License (AFL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/afl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@prestashop.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. * @author PrestaShop SA <contact@prestashop.com>
  22. * @copyright 2007-2021 PrestaShop SA
  23. * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
  24. * International Registered Trademark & Property of PrestaShop SA
  25. */
  26. namespace Core\App\Factory;
  27. class AvizeItemFactory extends OrderItemFactory
  28. {
  29. public function createAvizeProduct(
  30. $product_ids,
  31. $product_name,
  32. $ean,
  33. $sku,
  34. $upc,
  35. $currency_code,
  36. $price,
  37. $taxRate,
  38. $quantity,
  39. $taxIncluded = false
  40. ) {
  41. $proformaProduct = new \Core\App\Entity\OrderItem();
  42. $taxRate = $this->getTaxRate($taxRate);
  43. $pretFtva = $this->getPretftva($price, $taxRate, 0, $taxIncluded);
  44. $pretCtva = $this->getPretctva($price, $taxRate, 0, $taxIncluded);
  45. $proformaProduct->setFacturiProdNume($this->stripSpecialChars($product_name));
  46. $proformaProduct->setFacturiProdMoneda($currency_code);
  47. $proformaProduct->setFacturiProdPretftva($pretFtva);
  48. $proformaProduct->setFacturiProdPretctva($pretCtva);
  49. $proformaProduct->setFacturiProdTva($this->getTaxName($taxRate));
  50. $proformaProduct->setFacturiProdCant($quantity);
  51. $proformaProduct->setFacturiProdVal($pretFtva * $quantity);
  52. $proformaProduct->setFacturiProdValTva(($pretCtva - $pretFtva) * $quantity);
  53. $proformaProduct->setFacturiProdValTot($pretCtva * $quantity);
  54. $proformaProduct->setFacturiProdUm(self::UM);
  55. $proformaProduct->setProdCod($ean);
  56. $proformaProduct->setProdSku($sku);
  57. $proformaProduct->setProdUpc($upc);
  58. $proformaProduct->setProdCod1((trim($upc) != '') ? $upc : ($this->getPrefix() . $product_ids));
  59. $proformaProduct->setProdCodCautare('all');
  60. return $proformaProduct;
  61. }
  62. }