ProformaFactory.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Core\App\Factory;
  3. class ProformaFactory extends OrderFactory
  4. {
  5. public function createProforma(
  6. $facturi_serie,
  7. $order_id,
  8. $created_date,
  9. $currency,
  10. $customer_id,
  11. $customer_first_name,
  12. $customer_last_name,
  13. $billing_company,
  14. $email,
  15. $billing_address_first_name,
  16. $billing_address_last_name,
  17. $billing_address_address1,
  18. $billing_address_address2,
  19. $billing_address_zip,
  20. $billing_address_city,
  21. $billing_address_province,
  22. $billing_address_phone,
  23. $shipping_address_first_name,
  24. $shipping_address_last_name,
  25. $shipping_address_address1,
  26. $shipping_address_address2,
  27. $shipping_address_zip,
  28. $shipping_address_city,
  29. $shipping_address_province,
  30. $shipping_address_phone,
  31. $payment_method,
  32. $comments,
  33. $fiscal_code,
  34. $company,
  35. $nr_inreg,
  36. $facturi_cont_client,
  37. $facturi_banca_client,
  38. $taxRate
  39. )
  40. {
  41. $proforma = new \Core\App\Entity\Proforma();
  42. $proforma->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date)));
  43. $proforma->setFacturiDataScadenta(date('Y-m-d H:i:s', strtotime($created_date)));
  44. $proforma->setFacturiCotaTva($this->getTaxName($taxRate));
  45. $proforma->setFacturiMoneda($currency);
  46. $proforma->setFacturiSerie($facturi_serie);
  47. $proforma->setFacturiObsUp($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments));
  48. $proforma->setFacturiModPlata($payment_method);
  49. $proforma->setFacturiStatus('Emisa');
  50. $proforma->setFacturiClientId($customer_id);
  51. $proforma->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company));
  52. $proforma->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica');
  53. $proforma->setFacturiCodfClient($fiscal_code);
  54. $proforma->setFacturiNrregClient($nr_inreg);
  55. $proforma->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip));
  56. $proforma->setFacturiJudetClient($this->stripSpecialChars($billing_address_province));
  57. $proforma->setFacturiOrasClient($this->stripSpecialChars($billing_address_city));
  58. $proforma->setFacturiClientiTel($billing_address_phone);
  59. $proforma->setFacturiEmailClient($email);
  60. $proforma->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip));
  61. $proforma->setFacturiContClient($facturi_cont_client);
  62. $proforma->setFacturiBancaClient($facturi_banca_client);
  63. $proforma->setFacturiObsClient('Id extern client: ' . $customer_id);
  64. $proforma->setFacturiClientiOrasLivrare($this->stripSpecialChars($shipping_address_city));
  65. $proforma->setFacturiClientiJudetLivrare($this->stripSpecialChars($shipping_address_province));
  66. $proforma->setUniqueIdInsert($this->getPrefix() . $facturi_serie . '_' . $customer_id . '_' . $order_id . '_' . strtotime($created_date));
  67. return $proforma;
  68. }
  69. }