InvoiceItemFactory.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 InvoiceItemFactory extends OrderItemFactory
  28. {
  29. public function createInvoiceProduct(
  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. $invoiceProduct = 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. $invoiceProduct->setFacturiProdNume($this->stripSpecialChars($product_name));
  46. $invoiceProduct->setFacturiProdMoneda($currency_code);
  47. $invoiceProduct->setFacturiProdPretftva($pretFtva);
  48. $invoiceProduct->setFacturiProdPretctva($pretCtva);
  49. $invoiceProduct->setFacturiProdTva($this->getTaxName($taxRate));
  50. $invoiceProduct->setFacturiProdCant($quantity);
  51. $invoiceProduct->setFacturiProdVal($pretFtva * $quantity);
  52. $invoiceProduct->setFacturiProdValTva(($pretCtva - $pretFtva) * $quantity);
  53. $invoiceProduct->setFacturiProdValTot($pretCtva * $quantity);
  54. $invoiceProduct->setFacturiProdUm(self::UM);
  55. $invoiceProduct->setProdCod($ean);
  56. $invoiceProduct->setProdSku($sku);
  57. $invoiceProduct->setProdUpc($upc);
  58. $invoiceProduct->setProdCod1((trim($upc) != '') ? $upc : ($this->getPrefix() . $product_ids));
  59. $invoiceProduct->setProdCodCautare('all');
  60. return $invoiceProduct;
  61. }
  62. }