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(name="comercial_name", type="string", length=128, nullable=true)
  143. */
  144. private $commercialName;
  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. /**
  220. * @ORM\OneToOne(targetEntity="App\Entity\System\CustomerInvoiceAddressEncrypted", cascade={"persist", "remove"})
  221. *
  222. * @ORM\JoinColumn(name="customer_invoice_address_encrypted", referencedColumnName="id")
  223. */
  224. private ?CustomerInvoiceAddressEncrypted $customerInvoiceAddressEncrypted = null;
  225. private ?string $plainEmail = null;
  226. private ?string $plainName = null;
  227. private ?string $plainSurnames = null;
  228. private ?string $plainPhone = null;
  229. private ?string $plainPhoneMobile = null;
  230. private ?string $plainAddress1 = null;
  231. private ?string $plainAddress2 = null;
  232. private ?string $plainPostcode = null;
  233. private ?string $plainCity = null;
  234. private ?string $plainVatNumber = null;
  235. public function __construct()
  236. {
  237. $this->dateUpd = new \DateTime();
  238. $this->vise = false;
  239. $this->re = false;
  240. $this->typeCustomer = 1;
  241. $this->contactName = '1';
  242. $this->phonePrefix = 0;
  243. $this->phoneMobilePrefix = 0;
  244. $this->address1 = '';
  245. $this->city = '';
  246. $this->dateAdd = new \DateTime();
  247. }
  248. public function getId(): int
  249. {
  250. return $this->id;
  251. }
  252. public function setId(int $id): CustomerInvoiceAddress
  253. {
  254. $this->id = $id;
  255. return $this;
  256. }
  257. /**
  258. * @return Country
  259. */
  260. public function getCountry(): Country
  261. {
  262. return $this->country;
  263. }
  264. public function setCountry(Country $country): CustomerInvoiceAddress
  265. {
  266. $this->country = $country;
  267. return $this;
  268. }
  269. public function getState(): ?State
  270. {
  271. if ($this->state && $this->state->getId() === 0) {
  272. return null;
  273. }
  274. return $this->state;
  275. }
  276. public function setState(?State $state): CustomerInvoiceAddress
  277. {
  278. $this->state = $state;
  279. return $this;
  280. }
  281. public function getStateName(): ?string
  282. {
  283. return $this->stateName;
  284. }
  285. public function setStateName(?string $stateName): CustomerInvoiceAddress
  286. {
  287. $this->stateName = $stateName;
  288. return $this;
  289. }
  290. public function getCompany(): ?string
  291. {
  292. return $this->company;
  293. }
  294. public function setCompany(?string $company): CustomerInvoiceAddress
  295. {
  296. $this->company = $company;
  297. return $this;
  298. }
  299. public function getName(): ?string
  300. {
  301. return $this->name;
  302. }
  303. public function setName(?string $name): CustomerInvoiceAddress
  304. {
  305. $this->name = $name;
  306. return $this;
  307. }
  308. public function getPlainName(): ?string
  309. {
  310. return $this->plainName;
  311. }
  312. public function setPlainName(?string $plainName): CustomerInvoiceAddress
  313. {
  314. $this->plainName = $plainName;
  315. return $this;
  316. }
  317. public function getEmail(): string
  318. {
  319. return $this->email;
  320. }
  321. public function setEmail(string $email): CustomerInvoiceAddress
  322. {
  323. $this->email = $email;
  324. return $this;
  325. }
  326. public function getPlainEmail(): ?string
  327. {
  328. return $this->plainEmail;
  329. }
  330. public function setPlainEmail(?string $plainEmail): CustomerInvoiceAddress
  331. {
  332. $this->plainEmail = $plainEmail;
  333. return $this;
  334. }
  335. public function getSurnames(): ?string
  336. {
  337. return $this->surnames;
  338. }
  339. public function setSurnames(?string $surnames): CustomerInvoiceAddress
  340. {
  341. $this->surnames = $surnames;
  342. return $this;
  343. }
  344. public function getPlainSurnames(): ?string
  345. {
  346. return $this->plainSurnames;
  347. }
  348. public function setPlainSurnames(?string $plainSurnames): CustomerInvoiceAddress
  349. {
  350. $this->plainSurnames = $plainSurnames;
  351. return $this;
  352. }
  353. public function getAddress1(): string
  354. {
  355. return $this->address1;
  356. }
  357. public function setAddress1(string $address1): CustomerInvoiceAddress
  358. {
  359. $this->address1 = $address1;
  360. return $this;
  361. }
  362. public function getPlainAddress1(): ?string
  363. {
  364. return $this->plainAddress1;
  365. }
  366. public function setPlainAddress1(?string $plainAddress1): CustomerInvoiceAddress
  367. {
  368. $this->plainAddress1 = $plainAddress1;
  369. return $this;
  370. }
  371. public function getAddress2(): ?string
  372. {
  373. return $this->address2;
  374. }
  375. public function setAddress2(?string $address2): CustomerInvoiceAddress
  376. {
  377. $this->address2 = $address2;
  378. return $this;
  379. }
  380. public function getPlainAddress2(): ?string
  381. {
  382. return $this->plainAddress2;
  383. }
  384. public function setPlainAddress2(?string $plainAddress2): CustomerInvoiceAddress
  385. {
  386. $this->plainAddress2 = $plainAddress2;
  387. return $this;
  388. }
  389. public function getPostcode(): ?string
  390. {
  391. return $this->postcode;
  392. }
  393. public function setPostcode(?string $postcode): CustomerInvoiceAddress
  394. {
  395. $this->postcode = $postcode;
  396. return $this;
  397. }
  398. public function getPlainPostcode(): ?string
  399. {
  400. return $this->plainPostcode;
  401. }
  402. public function setPlainPostcode(?string $plainPostcode): CustomerInvoiceAddress
  403. {
  404. $this->plainPostcode = $plainPostcode;
  405. return $this;
  406. }
  407. public function getCity(): string
  408. {
  409. return $this->city;
  410. }
  411. public function setCity(string $city): CustomerInvoiceAddress
  412. {
  413. $this->city = $city;
  414. return $this;
  415. }
  416. public function getPlainCity(): ?string
  417. {
  418. return $this->plainCity;
  419. }
  420. public function setPlainCity(?string $plainCity): CustomerInvoiceAddress
  421. {
  422. $this->plainCity = $plainCity;
  423. return $this;
  424. }
  425. public function getPhone(): ?string
  426. {
  427. return $this->phone;
  428. }
  429. public function setPhone(?string $phone): CustomerInvoiceAddress
  430. {
  431. $this->phone = $phone;
  432. return $this;
  433. }
  434. public function getPlainPhone(): ?string
  435. {
  436. return $this->plainPhone;
  437. }
  438. public function setPlainPhone(?string $plainPhone): CustomerInvoiceAddress
  439. {
  440. $this->plainPhone = $plainPhone;
  441. return $this;
  442. }
  443. public function getPhoneMobile(): ?string
  444. {
  445. return $this->phoneMobile;
  446. }
  447. public function setPhoneMobile(?string $phoneMobile): CustomerInvoiceAddress
  448. {
  449. $this->phoneMobile = $phoneMobile;
  450. return $this;
  451. }
  452. public function getPlainPhoneMobile(): ?string
  453. {
  454. return $this->plainPhoneMobile;
  455. }
  456. public function setPlainPhoneMobile(?string $plainPhoneMobile): CustomerInvoiceAddress
  457. {
  458. $this->plainPhoneMobile = $plainPhoneMobile;
  459. return $this;
  460. }
  461. public function getVatNumber(): ?string
  462. {
  463. return $this->vatNumber;
  464. }
  465. public function setVatNumber(?string $vatNumber): CustomerInvoiceAddress
  466. {
  467. $this->vatNumber = preg_replace('/[^A-Za-z0-9]/i', '', $vatNumber);
  468. return $this;
  469. }
  470. public function getPlainVatNumber(): ?string
  471. {
  472. return $this->plainVatNumber;
  473. }
  474. public function setPlainVatNumber(?string $plainVatNumber): CustomerInvoiceAddress
  475. {
  476. $this->plainVatNumber = $plainVatNumber;
  477. return $this;
  478. }
  479. /**
  480. * @return \DateTime
  481. */
  482. public function getDateAdd(): \DateTime
  483. {
  484. return $this->dateAdd;
  485. }
  486. public function setDateAdd(\DateTime $dateAdd): CustomerInvoiceAddress
  487. {
  488. $this->dateAdd = $dateAdd;
  489. return $this;
  490. }
  491. public function getDateUpd(): \DateTime
  492. {
  493. return $this->dateUpd;
  494. }
  495. public function setDateUpd(\DateTime $dateUpd): CustomerInvoiceAddress
  496. {
  497. $this->dateUpd = $dateUpd;
  498. return $this;
  499. }
  500. public function getVise(): ?bool
  501. {
  502. return $this->vise;
  503. }
  504. public function setVise(?bool $vise): CustomerInvoiceAddress
  505. {
  506. $this->vise = $vise;
  507. return $this;
  508. }
  509. public function getRe(): ?bool
  510. {
  511. return $this->re;
  512. }
  513. public function setRe(?bool $re): CustomerInvoiceAddress
  514. {
  515. $this->re = $re;
  516. return $this;
  517. }
  518. public function getCommercialName(): ?string
  519. {
  520. return $this->commercialName;
  521. }
  522. public function setCommercialName(?string $commercialName): CustomerInvoiceAddress
  523. {
  524. $this->commercialName = $commercialName;
  525. return $this;
  526. }
  527. public function getTypeCustomer(): ?int
  528. {
  529. return $this->typeCustomer;
  530. }
  531. public function setTypeCustomer(int $typeCustomer): CustomerInvoiceAddress
  532. {
  533. $this->typeCustomer = $typeCustomer;
  534. return $this;
  535. }
  536. public function getContactName(): ?string
  537. {
  538. return $this->contactName;
  539. }
  540. public function setContactName(?string $contactName): CustomerInvoiceAddress
  541. {
  542. $this->contactName = $contactName;
  543. return $this;
  544. }
  545. public function getUrl(): ?string
  546. {
  547. return $this->url;
  548. }
  549. public function setUrl(?string $url): CustomerInvoiceAddress
  550. {
  551. $this->url = $url;
  552. return $this;
  553. }
  554. public function getPhonePrefix(): int
  555. {
  556. return $this->phonePrefix;
  557. }
  558. public function setPhonePrefix(int $phonePrefix): CustomerInvoiceAddress
  559. {
  560. $this->phonePrefix = $phonePrefix;
  561. return $this;
  562. }
  563. public function getPhoneMobilePrefix(): int
  564. {
  565. return $this->phoneMobilePrefix;
  566. }
  567. public function setPhoneMobilePrefix(int $phoneMobilePrefix): CustomerInvoiceAddress
  568. {
  569. $this->phoneMobilePrefix = $phoneMobilePrefix;
  570. return $this;
  571. }
  572. public function getCompanyName(): ?string
  573. {
  574. return $this->companyName;
  575. }
  576. public function setCompanyName(?string $companyName): CustomerInvoiceAddress
  577. {
  578. $this->companyName = $companyName;
  579. return $this;
  580. }
  581. public function getCustomer(): Customer
  582. {
  583. return $this->customer;
  584. }
  585. public function setCustomer(Customer $customer): self
  586. {
  587. $this->customer = $customer;
  588. return $this;
  589. }
  590. public function getIsoVatNumber(): ?string
  591. {
  592. return $this->isoVatNumber;
  593. }
  594. public function setIsoVatNumber(?string $isoVatNumber): self
  595. {
  596. $this->isoVatNumber = $isoVatNumber;
  597. return $this;
  598. }
  599. public function isCompanyVerified(): bool
  600. {
  601. return $this->companyVerified;
  602. }
  603. public function setCompanyVerified(bool $companyVerified): CustomerInvoiceAddress
  604. {
  605. $this->companyVerified = $companyVerified;
  606. return $this;
  607. }
  608. public function getEori(): ?string
  609. {
  610. return $this->eori;
  611. }
  612. public function setEori(?string $eori): CustomerInvoiceAddress
  613. {
  614. $this->eori = $eori;
  615. return $this;
  616. }
  617. public function getVoec(): ?string
  618. {
  619. return $this->voec;
  620. }
  621. public function setVoec(?string $voec): CustomerInvoiceAddress
  622. {
  623. $this->voec = $voec;
  624. return $this;
  625. }
  626. public function getDeliveryAddress(): Address
  627. {
  628. return $this->deliveryAddress;
  629. }
  630. public function setDeliveryAddress(Address $deliveryAddress): CustomerInvoiceAddress
  631. {
  632. $this->deliveryAddress = $deliveryAddress;
  633. return $this;
  634. }
  635. public function isB2C(): bool
  636. {
  637. return $this->typeCustomer === self::TYPE_INDIVIDUAL;
  638. }
  639. public function getCustomerInvoiceAddressEncrypted(): ?CustomerInvoiceAddressEncrypted
  640. {
  641. return $this->customerInvoiceAddressEncrypted;
  642. }
  643. public function setCustomerInvoiceAddressEncrypted(?CustomerInvoiceAddressEncrypted $customerInvoiceAddressEncrypted): self
  644. {
  645. $this->customerInvoiceAddressEncrypted = $customerInvoiceAddressEncrypted;
  646. return $this;
  647. }
  648. }