InvoiceFactory.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 InvoiceFactory extends OrderFactory
  28. {
  29. public function createInvoice(
  30. $facturi_serie,
  31. $order_id,
  32. $created_date,
  33. $currency,
  34. $customer_id,
  35. $customer_first_name,
  36. $customer_last_name,
  37. $billing_company,
  38. $email,
  39. $billing_address_first_name,
  40. $billing_address_last_name,
  41. $billing_address_address1,
  42. $billing_address_address2,
  43. $billing_address_zip,
  44. $billing_address_city,
  45. $billing_address_province,
  46. $billing_address_phone,
  47. $shipping_address_first_name,
  48. $shipping_address_last_name,
  49. $shipping_address_address1,
  50. $shipping_address_address2,
  51. $shipping_address_zip,
  52. $shipping_address_city,
  53. $shipping_address_province,
  54. $shipping_address_phone,
  55. $payment_method,
  56. $comments,
  57. $fiscal_code,
  58. $company,
  59. $nr_inreg,
  60. $facturi_cont_client,
  61. $facturi_banca_client,
  62. $taxRate
  63. ) {
  64. $proforma = new \Core\App\Entity\Invoice();
  65. $proforma->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date)));
  66. $proforma->setFacturiDataScadenta(date('Y-m-d H:i:s', strtotime($created_date)));
  67. $proforma->setFacturiCotaTva($this->getTaxName($taxRate));
  68. $proforma->setFacturiMoneda($currency);
  69. $proforma->setFacturiSerie($facturi_serie);
  70. $proforma->setFacturiObsUp($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments));
  71. $proforma->setFacturiModPlata($payment_method);
  72. $proforma->setFacturiStatus('Emisa');
  73. $proforma->setFacturiClientId($customer_id);
  74. $proforma->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company));
  75. $proforma->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica');
  76. $proforma->setFacturiCodfClient($fiscal_code);
  77. $proforma->setFacturiNrregClient($nr_inreg);
  78. $proforma->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip));
  79. $proforma->setFacturiJudetClient($this->stripSpecialChars($billing_address_province));
  80. $proforma->setFacturiOrasClient($this->stripSpecialChars($billing_address_city));
  81. $proforma->setFacturiClientiTel($billing_address_phone);
  82. $proforma->setFacturiEmailClient($email);
  83. $proforma->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip));
  84. $proforma->setFacturiContClient($facturi_cont_client);
  85. $proforma->setFacturiBancaClient($facturi_banca_client);
  86. $proforma->setFacturiObsClient('Id extern client: ' . $customer_id);
  87. $proforma->setFacturiClientiOrasLivrare($this->stripSpecialChars($shipping_address_city));
  88. $proforma->setFacturiClientiJudetLivrare($this->stripSpecialChars($shipping_address_province));
  89. $proforma->setUniqueIdInsert($this->getPrefix() . $facturi_serie . '_' . $customer_id . '_' . $order_id . '_' . strtotime($created_date));
  90. return $proforma;
  91. }
  92. }