src/Entity/System/CustomerInvoiceAddress.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * @ORM\Entity(repositoryClass="App\Repository\System\CustomerInvoiceAddressRepository")
  6. *
  7. * @ORM\Table(indexes={
  8. *
  9. * @ORM\Index(name="iso_vat_number", columns={"iso_vat_number"}),
  10. * @ORM\Index(name="vat_number", columns={"vat_number"}),
  11. * },
  12. * uniqueConstraints={
  13. *
  14. * @ORM\UniqueConstraint(name="uk_vat_number", columns={"iso_vat_number", "vat_number"})
  15. * })
  16. */
  17. class CustomerInvoiceAddress implements InvoiceAddressInterface, AddressInterface
  18. {
  19. /**
  20. * @var int
  21. *
  22. * @ORM\Id
  23. *
  24. * @ORM\GeneratedValue(strategy="AUTO")
  25. *
  26. * @ORM\Column(type="integer")
  27. */
  28. private $id;
  29. /**
  30. * @var Country
  31. *
  32. * @ORM\ManyToOne(targetEntity="App\Entity\System\Country")
  33. *
  34. * @ORM\JoinColumn(referencedColumnName="id_country", nullable=false)
  35. */
  36. private $country;
  37. /**
  38. * @var State|null
  39. *
  40. * @ORM\ManyToOne(targetEntity="App\Entity\System\State")
  41. *
  42. * @ORM\JoinColumn(referencedColumnName="id_state", nullable=true)
  43. */
  44. private $state;
  45. /**
  46. * @var string|null
  47. *
  48. * @ORM\Column(type="string", length=50, nullable=true)
  49. */
  50. private $stateName;
  51. /**
  52. * @var string|null
  53. *
  54. * @ORM\Column(type="string", length=64, nullable=true)
  55. */
  56. private $company;
  57. /**
  58. * @var string|null
  59. *
  60. * @ORM\Column(type="string", length=32, nullable=true)
  61. */
  62. private $name;
  63. /**
  64. * @var string
  65. *
  66. * @ORM\Column(type="string", length=128)
  67. */
  68. private $email;
  69. /**
  70. * @var string|null
  71. *
  72. * @ORM\Column(type="string", length=32, nullable=true)
  73. */
  74. private $surnames;
  75. /**
  76. * @var string
  77. *
  78. * @ORM\Column(type="string", length=128)
  79. */
  80. private $address1;
  81. /**
  82. * @var string|null
  83. *
  84. * @ORM\Column(type="string", length=128, nullable=true)
  85. */
  86. private $address2;
  87. /**
  88. * @var string|null
  89. *
  90. * @ORM\Column(type="string", length=12, nullable=true)
  91. */
  92. private $postcode;
  93. /**
  94. * @var string
  95. *
  96. * @ORM\Column(type="string", length=64)
  97. */
  98. private $city;
  99. /**
  100. * @var string|null
  101. *
  102. * @ORM\Column(type="string", length=32, nullable=true)
  103. */
  104. private $phone;
  105. /**
  106. * @var string|null
  107. *
  108. * @ORM\Column(type="string", length=32, nullable=true)
  109. */
  110. private $phoneMobile;
  111. /**
  112. * @var string|null
  113. *
  114. * @ORM\Column(type="string", length=32, nullable=true)
  115. */
  116. private $vatNumber;
  117. /**
  118. * @var \DateTime
  119. *
  120. * @ORM\Column(type="datetime")
  121. */
  122. private $dateAdd;
  123. /**
  124. * @var \DateTime
  125. *
  126. * @ORM\Column(type="datetime")
  127. */
  128. private $dateUpd;
  129. /**
  130. * @ORM\Column(type="boolean", options={"default" : 0})
  131. */
  132. private bool $vise;
  133. /**
  134. * @var bool|null
  135. *
  136. * @ORM\Column(type="boolean", length=4, nullable=true, options={"default" : 0})
  137. */
  138. private $re;
  139. /**
  140. * @var string|null
  141. *
  142. * @ORM\Column(type="string", length=128, nullable=true)
  143. */
  144. private $comercialName;
  145. /**
  146. * @var int|null
  147. *
  148. * @ORM\Column(type="integer",length=1, nullable=true, options={"default" : 1}))
  149. */
  150. private $typeCustomer;
  151. /**
  152. * @var string|null
  153. *
  154. * @ORM\Column(type="string", length=50, nullable=true, options={"default" : "1"})
  155. */
  156. private $contactName;
  157. /**
  158. * @var string|null
  159. *
  160. * @ORM\Column(type="string", length=50, nullable=true, options={"default" : "1"})
  161. */
  162. private $url;
  163. /**
  164. * @var int
  165. *
  166. * @ORM\Column(type="integer", length=10, options={"default" : 0})
  167. */
  168. private $phonePrefix;
  169. /**
  170. * @var int
  171. *
  172. * @ORM\Column(type="integer", length=10, options={"default" : 0})
  173. */
  174. private $phoneMobilePrefix;
  175. /**
  176. * @var string|null
  177. *
  178. * @ORM\Column(type="string", length=64, nullable=true)
  179. */
  180. private $companyName;
  181. /**
  182. * @var string|null
  183. *
  184. * @ORM\Column(type="string", length=3, nullable=true)
  185. */
  186. private $isoVatNumber;
  187. /**
  188. * @var Customer
  189. *
  190. * @ORM\OneToOne(targetEntity="App\Entity\System\Customer", inversedBy="customerInvoiceAddress")
  191. *
  192. * @ORM\JoinColumn(referencedColumnName="id_customer", nullable=false)
  193. */
  194. private $customer;
  195. /**
  196. * @ORM\Column(type="boolean", options={"default" : 0})
  197. */
  198. private bool $companyVerified = false;
  199. /**
  200. * @var string|null
  201. *
  202. * @ORM\Column(type="string", length=64, nullable=true)
  203. */
  204. private $eori;
  205. /**
  206. * @var string|null
  207. *
  208. * @ORM\Column(type="string", length=64, nullable=true)
  209. */
  210. private $voec;
  211. /**
  212. * @var Address
  213. *
  214. * @ORM\OneToOne(targetEntity="App\Entity\System\Address", inversedBy="customerInvoiceAddress")
  215. *
  216. * @ORM\JoinColumn(referencedColumnName="id_address", nullable=false, name="old_address_id")
  217. */
  218. private $deliveryAddress;
  219. public function __construct()
  220. {
  221. $this->dateUpd = new \DateTime();
  222. $this->vise = false;
  223. $this->re = false;
  224. $this->typeCustomer = 1;
  225. $this->contactName = '1';
  226. $this->phonePrefix = 0;
  227. $this->phoneMobilePrefix = 0;
  228. $this->address1 = '';
  229. $this->city = '';
  230. $this->dateAdd = new \DateTime();
  231. }
  232. public function getId(): int
  233. {
  234. return $this->id;
  235. }
  236. public function setId(int $id): CustomerInvoiceAddress
  237. {
  238. $this->id = $id;
  239. return $this;
  240. }
  241. /**
  242. * @return Country
  243. */
  244. public function getCountry(): Country
  245. {
  246. return $this->country;
  247. }
  248. public function setCountry(Country $country): CustomerInvoiceAddress
  249. {
  250. $this->country = $country;
  251. return $this;
  252. }
  253. public function getState(): ?State
  254. {
  255. if ($this->state && $this->state->getId() === 0) {
  256. return null;
  257. }
  258. return $this->state;
  259. }
  260. public function setState(?State $state): CustomerInvoiceAddress
  261. {
  262. $this->state = $state;
  263. return $this;
  264. }
  265. public function getStateName(): ?string
  266. {
  267. return $this->stateName;
  268. }
  269. public function setStateName(?string $stateName): CustomerInvoiceAddress
  270. {
  271. $this->stateName = $stateName;
  272. return $this;
  273. }
  274. public function getCompany(): ?string
  275. {
  276. return $this->company;
  277. }
  278. public function setCompany(?string $company): CustomerInvoiceAddress
  279. {
  280. $this->company = $company;
  281. return $this;
  282. }
  283. public function getName(): ?string
  284. {
  285. return $this->name;
  286. }
  287. public function setName(?string $name): CustomerInvoiceAddress
  288. {
  289. $this->name = $name;
  290. return $this;
  291. }
  292. public function getEmail(): string
  293. {
  294. return $this->email;
  295. }
  296. public function setEmail(string $email): CustomerInvoiceAddress
  297. {
  298. $this->email = $email;
  299. return $this;
  300. }
  301. public function getSurnames(): ?string
  302. {
  303. return $this->surnames;
  304. }
  305. public function setSurnames(?string $surnames): CustomerInvoiceAddress
  306. {
  307. $this->surnames = $surnames;
  308. return $this;
  309. }
  310. public function getAddress1(): string
  311. {
  312. return $this->address1;
  313. }
  314. public function setAddress1(string $address1): CustomerInvoiceAddress
  315. {
  316. $this->address1 = $address1;
  317. return $this;
  318. }
  319. public function getAddress2(): ?string
  320. {
  321. return $this->address2;
  322. }
  323. public function setAddress2(?string $address2): CustomerInvoiceAddress
  324. {
  325. $this->address2 = $address2;
  326. return $this;
  327. }
  328. public function getPostcode(): ?string
  329. {
  330. return $this->postcode;
  331. }
  332. public function setPostcode(?string $postcode): CustomerInvoiceAddress
  333. {
  334. $this->postcode = $postcode;
  335. return $this;
  336. }
  337. public function getCity(): string
  338. {
  339. return $this->city;
  340. }
  341. public function setCity(string $city): CustomerInvoiceAddress
  342. {
  343. $this->city = $city;
  344. return $this;
  345. }
  346. public function getPhone(): ?string
  347. {
  348. return $this->phone;
  349. }
  350. public function setPhone(?string $phone): CustomerInvoiceAddress
  351. {
  352. $this->phone = $phone;
  353. return $this;
  354. }
  355. public function getPhoneMobile(): ?string
  356. {
  357. return $this->phoneMobile;
  358. }
  359. public function setPhoneMobile(?string $phoneMobile): CustomerInvoiceAddress
  360. {
  361. $this->phoneMobile = $phoneMobile;
  362. return $this;
  363. }
  364. public function getVatNumber(): ?string
  365. {
  366. return $this->vatNumber;
  367. }
  368. public function setVatNumber(?string $vatNumber): CustomerInvoiceAddress
  369. {
  370. $this->vatNumber = preg_replace('/[^A-Za-z0-9]/i', '', $vatNumber);
  371. return $this;
  372. }
  373. /**
  374. * @return \DateTime
  375. */
  376. public function getDateAdd(): \DateTime
  377. {
  378. return $this->dateAdd;
  379. }
  380. public function setDateAdd(\DateTime $dateAdd): CustomerInvoiceAddress
  381. {
  382. $this->dateAdd = $dateAdd;
  383. return $this;
  384. }
  385. public function getDateUpd(): \DateTime
  386. {
  387. return $this->dateUpd;
  388. }
  389. public function setDateUpd(\DateTime $dateUpd): CustomerInvoiceAddress
  390. {
  391. $this->dateUpd = $dateUpd;
  392. return $this;
  393. }
  394. public function getVise(): ?bool
  395. {
  396. return $this->vise;
  397. }
  398. public function setVise(?bool $vise): CustomerInvoiceAddress
  399. {
  400. $this->vise = $vise;
  401. return $this;
  402. }
  403. public function getRe(): ?bool
  404. {
  405. return $this->re;
  406. }
  407. public function setRe(?bool $re): CustomerInvoiceAddress
  408. {
  409. $this->re = $re;
  410. return $this;
  411. }
  412. public function getComercialName(): ?string
  413. {
  414. return $this->comercialName;
  415. }
  416. public function setComercialName(?string $comercialName): CustomerInvoiceAddress
  417. {
  418. $this->comercialName = $comercialName;
  419. return $this;
  420. }
  421. public function getTypeCustomer(): ?int
  422. {
  423. return $this->typeCustomer;
  424. }
  425. public function setTypeCustomer(int $typeCustomer): CustomerInvoiceAddress
  426. {
  427. $this->typeCustomer = $typeCustomer;
  428. return $this;
  429. }
  430. public function getContactName(): ?string
  431. {
  432. return $this->contactName;
  433. }
  434. public function setContactName(?string $contactName): CustomerInvoiceAddress
  435. {
  436. $this->contactName = $contactName;
  437. return $this;
  438. }
  439. public function getUrl(): ?string
  440. {
  441. return $this->url;
  442. }
  443. public function setUrl(?string $url): CustomerInvoiceAddress
  444. {
  445. $this->url = $url;
  446. return $this;
  447. }
  448. public function getPhonePrefix(): int
  449. {
  450. return $this->phonePrefix;
  451. }
  452. public function setPhonePrefix(int $phonePrefix): CustomerInvoiceAddress
  453. {
  454. $this->phonePrefix = $phonePrefix;
  455. return $this;
  456. }
  457. public function getPhoneMobilePrefix(): int
  458. {
  459. return $this->phoneMobilePrefix;
  460. }
  461. public function setPhoneMobilePrefix(int $phoneMobilePrefix): CustomerInvoiceAddress
  462. {
  463. $this->phoneMobilePrefix = $phoneMobilePrefix;
  464. return $this;
  465. }
  466. public function getCompanyName(): ?string
  467. {
  468. return $this->companyName;
  469. }
  470. public function setCompanyName(?string $companyName): CustomerInvoiceAddress
  471. {
  472. $this->companyName = $companyName;
  473. return $this;
  474. }
  475. public function getCustomer(): Customer
  476. {
  477. return $this->customer;
  478. }
  479. public function setCustomer(Customer $customer): self
  480. {
  481. $this->customer = $customer;
  482. return $this;
  483. }
  484. public function getIsoVatNumber(): ?string
  485. {
  486. return $this->isoVatNumber;
  487. }
  488. public function setIsoVatNumber(?string $isoVatNumber): self
  489. {
  490. $this->isoVatNumber = $isoVatNumber;
  491. return $this;
  492. }
  493. public function isCompanyVerified(): bool
  494. {
  495. return $this->companyVerified;
  496. }
  497. public function setCompanyVerified(bool $companyVerified): CustomerInvoiceAddress
  498. {
  499. $this->companyVerified = $companyVerified;
  500. return $this;
  501. }
  502. public function getFullName(): ?string
  503. {
  504. return $this->name.' '.$this->surnames;
  505. }
  506. public function getEori(): ?string
  507. {
  508. return $this->eori;
  509. }
  510. public function setEori(?string $eori): CustomerInvoiceAddress
  511. {
  512. $this->eori = $eori;
  513. return $this;
  514. }
  515. public function getVoec(): ?string
  516. {
  517. return $this->voec;
  518. }
  519. public function setVoec(?string $voec): CustomerInvoiceAddress
  520. {
  521. $this->voec = $voec;
  522. return $this;
  523. }
  524. public function getDeliveryAddress(): Address
  525. {
  526. return $this->deliveryAddress;
  527. }
  528. public function setDeliveryAddress(Address $deliveryAddress): CustomerInvoiceAddress
  529. {
  530. $this->deliveryAddress = $deliveryAddress;
  531. return $this;
  532. }
  533. public function isB2C(): bool
  534. {
  535. return $this->typeCustomer === self::TYPE_INDIVIDUAL;
  536. }
  537. }