src/Entity/SettingsCompany.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\BusinessTypeSettingsCompanyConstants;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10. * SettingsCompany
  11. */
  12. #[ORM\Entity(repositoryClass: \App\Repository\SettingsCompanyRepository::class)]
  13. #[ORM\HasLifecycleCallbacks]
  14. #[ORM\Table(name: 'settings_company')]
  15. class SettingsCompany
  16. {
  17. /**
  18. * @var int
  19. */
  20. #[ORM\Column(name: 'id', type: 'integer')]
  21. #[ORM\Id]
  22. #[ORM\GeneratedValue(strategy: 'AUTO')]
  23. private $id;
  24. /**
  25. * @var string
  26. */
  27. #[ORM\Column(name: 'company', type: 'string', length: 255)]
  28. private $company;
  29. /**
  30. * @var string
  31. */
  32. #[ORM\Column(name: 'id_document', type: 'string', length: 255, nullable: true)]
  33. private $idDocument;
  34. /**
  35. * @var string
  36. */
  37. #[ORM\Column(name: 'registry', type: 'string', length: 255, nullable: true)]
  38. private $registry;
  39. /**
  40. * @var string
  41. */
  42. #[ORM\Column(name: 'address', type: 'string', length: 255, nullable: true)]
  43. private $address;
  44. /**
  45. * @var string
  46. */
  47. #[ORM\Column(name: 'zip_code', type: 'string', length: 255, nullable: true)]
  48. private $zipCode;
  49. /**
  50. * @var string
  51. */
  52. #[ORM\Column(name: 'telephone', type: 'string', length: 255, nullable: true)]
  53. private $telephone;
  54. /**
  55. * @var string
  56. */
  57. #[ORM\Column(name: 'fax', type: 'string', length: 255, nullable: true)]
  58. private $fax;
  59. /**
  60. * @var string
  61. */
  62. #[ORM\Column(name: 'email', type: 'string', length: 255, nullable: true)]
  63. private $email;
  64. /**
  65. * @var string
  66. */
  67. #[ORM\Column(name: 'note', type: 'text', nullable: true)]
  68. private $note;
  69. /**
  70. * @var \DateTime
  71. */
  72. #[ORM\Column(name: 'created_at', type: 'datetime')]
  73. private $createdAt;
  74. /**
  75. * @var int
  76. */
  77. #[ORM\Column(name: 'created_id', type: 'integer', nullable: true)]
  78. private $createdId;
  79. /**
  80. * @var \DateTime
  81. */
  82. #[ORM\Column(name: 'updated_at', type: 'datetime')]
  83. private $updatedAt;
  84. /**
  85. * @var int
  86. */
  87. #[ORM\Column(name: 'updated_id', type: 'integer', nullable: true)]
  88. private $updatedId;
  89. /**
  90. * @var string
  91. */
  92. #[ORM\Column(name: 'picture', type: 'string', length: 255, nullable: true)]
  93. private $picture;
  94. /**
  95. * @var string
  96. */
  97. #[ORM\Column(name: 'token', type: 'string', nullable: true)]
  98. private $token;
  99. #[ORM\Column(type: 'string', length: 10, nullable: true)]
  100. private $sageCompany;
  101. #[ORM\Column(type: 'string', length: 10, nullable: true)]
  102. private $sageGroup;
  103. #[ORM\OneToMany(targetEntity: DeliveryNote::class, mappedBy: 'sageCompany')]
  104. private $deliveryNotes;
  105. #[ORM\Column(name: 'comision', type: 'decimal', precision: 10, scale: 2, nullable: true)]
  106. private $comision;
  107. #[ORM\OneToOne(targetEntity: Supplier::class, cascade: ['persist', 'merge'])]
  108. #[ORM\JoinColumn(nullable: true)]
  109. private ?Supplier $supplier = null;
  110. #[ORM\Column(type: 'integer', nullable: true)]
  111. private $priority;
  112. #[ORM\Column(type: 'string', length: 50)]
  113. private $businessType;
  114. #[ORM\ManyToMany(targetEntity: Client::class, mappedBy: 'settingsCompany')]
  115. private $clients;
  116. #[ORM\ManyToMany(targetEntity: Supplier::class, mappedBy: 'settingsCompany')]
  117. private $suppliers;
  118. /**
  119. * @var string
  120. */
  121. #[ORM\Column(name: 'state', type: 'string', length: 255, nullable: true)]
  122. private $state;
  123. public function __construct()
  124. {
  125. $this->deliveryNotes = new ArrayCollection();
  126. $this->clients = new ArrayCollection();
  127. $this->suppliers = new ArrayCollection();
  128. }
  129. /**
  130. * Get id
  131. *
  132. * @return int
  133. */
  134. public function getId()
  135. {
  136. return $this->id;
  137. }
  138. /**
  139. * Set company
  140. *
  141. * @param string $company
  142. *
  143. * @return SettingsCompany
  144. */
  145. public function setCompany($company)
  146. {
  147. $this->company = $company;
  148. return $this;
  149. }
  150. /**
  151. * Get company
  152. *
  153. * @return string
  154. */
  155. public function getCompany()
  156. {
  157. return $this->company;
  158. }
  159. /**
  160. * Set idDocument
  161. *
  162. * @param string $idDocument
  163. *
  164. * @return SettingsCompany
  165. */
  166. public function setIdDocument($idDocument)
  167. {
  168. $this->idDocument = $idDocument;
  169. return $this;
  170. }
  171. /**
  172. * Get idDocument
  173. *
  174. * @return string
  175. */
  176. public function getIdDocument()
  177. {
  178. return $this->idDocument;
  179. }
  180. /**
  181. * Set registry
  182. *
  183. * @param string $registry
  184. *
  185. * @return SettingsCompany
  186. */
  187. public function setRegistry($registry)
  188. {
  189. $this->registry = $registry;
  190. return $this;
  191. }
  192. /**
  193. * Get registry
  194. *
  195. * @return string
  196. */
  197. public function getRegistry()
  198. {
  199. return $this->registry;
  200. }
  201. /**
  202. * Set address
  203. *
  204. * @param string $address
  205. *
  206. * @return SettingsCompany
  207. */
  208. public function setAddress($address)
  209. {
  210. $this->address = $address;
  211. return $this;
  212. }
  213. /**
  214. * Get address
  215. *
  216. * @return string
  217. */
  218. public function getAddress()
  219. {
  220. return $this->address;
  221. }
  222. /**
  223. * Set zipCode
  224. *
  225. * @param string $zipCode
  226. *
  227. * @return SettingsCompany
  228. */
  229. public function setZipCode($zipCode)
  230. {
  231. $this->zipCode = $zipCode;
  232. return $this;
  233. }
  234. /**
  235. * Get zipCode
  236. *
  237. * @return string
  238. */
  239. public function getZipCode()
  240. {
  241. return $this->zipCode;
  242. }
  243. /**
  244. * Set telephone
  245. *
  246. * @param string $telephone
  247. *
  248. * @return SettingsCompany
  249. */
  250. public function setTelephone($telephone)
  251. {
  252. $this->telephone = $telephone;
  253. return $this;
  254. }
  255. /**
  256. * Get telephone
  257. *
  258. * @return string
  259. */
  260. public function getTelephone()
  261. {
  262. return $this->telephone;
  263. }
  264. /**
  265. * Set fax
  266. *
  267. * @param string $fax
  268. *
  269. * @return SettingsCompany
  270. */
  271. public function setFax($fax)
  272. {
  273. $this->fax = $fax;
  274. return $this;
  275. }
  276. /**
  277. * Get fax
  278. *
  279. * @return string
  280. */
  281. public function getFax()
  282. {
  283. return $this->fax;
  284. }
  285. /**
  286. * Set email
  287. *
  288. * @param string $email
  289. *
  290. * @return SettingsCompany
  291. */
  292. public function setEmail($email)
  293. {
  294. $this->email = $email;
  295. return $this;
  296. }
  297. /**
  298. * Get email
  299. *
  300. * @return string
  301. */
  302. public function getEmail()
  303. {
  304. return $this->email;
  305. }
  306. /**
  307. * Set note
  308. *
  309. * @param string $note
  310. *
  311. * @return SettingsCompany
  312. */
  313. public function setNote($note)
  314. {
  315. $this->note = $note;
  316. return $this;
  317. }
  318. /**
  319. * Get note
  320. *
  321. * @return string
  322. */
  323. public function getNote()
  324. {
  325. return $this->note;
  326. }
  327. /**
  328. * Set createdAt
  329. *
  330. * @param \DateTime $createdAt
  331. *
  332. * @return SettingsCompany
  333. */
  334. public function setCreatedAt(\Datetime $createdAt)
  335. {
  336. $this->createdAt = $createdAt;
  337. return $this;
  338. }
  339. /**
  340. * Get createdAt
  341. *
  342. * @return \DateTime
  343. */
  344. public function getCreatedAt()
  345. {
  346. return $this->createdAt;
  347. }
  348. /**
  349. * Set createdId
  350. *
  351. * @param integer $createdId
  352. *
  353. * @return SettingsCompany
  354. */
  355. public function setCreatedId($createdId)
  356. {
  357. $this->createdId = $createdId;
  358. return $this;
  359. }
  360. /**
  361. * Get createdId
  362. *
  363. * @return integer
  364. */
  365. public function getCreatedId()
  366. {
  367. return $this->createdId;
  368. }
  369. /**
  370. * Set updatedAt
  371. *
  372. * @param \DateTime $updatedAt
  373. *
  374. * @return SettingsCompany
  375. */
  376. public function setUpdatedAt(\Datetime $updatedAt)
  377. {
  378. $this->updatedAt = $updatedAt;
  379. return $this;
  380. }
  381. /**
  382. * Get updatedAt
  383. *
  384. * @return \DateTime
  385. */
  386. public function getUpdatedAt()
  387. {
  388. return $this->updatedAt;
  389. }
  390. /**
  391. * Set updatedId
  392. *
  393. * @param integer $updatedId
  394. *
  395. * @return SettingsCompany
  396. */
  397. public function setUpdatedId($updatedId)
  398. {
  399. $this->updatedId = $updatedId;
  400. return $this;
  401. }
  402. /**
  403. * Get updatedId
  404. *
  405. * @return integer
  406. */
  407. public function getUpdatedId()
  408. {
  409. return $this->updatedId;
  410. }
  411. #[ORM\PrePersist]
  412. public function setCreatedAtValue()
  413. {
  414. $this->createdAt = new \Datetime();
  415. }
  416. #[ORM\PrePersist]
  417. #[ORM\PreUpdate]
  418. public function setUpdatedAtValue()
  419. {
  420. $this->updatedAt = new \Datetime();
  421. }
  422. /**
  423. * Set picture
  424. *
  425. * @param string $picture
  426. *
  427. * @return SettingsCompany
  428. */
  429. public function setPicture($picture)
  430. {
  431. $this->picture = $picture;
  432. return $this;
  433. }
  434. /**
  435. * Get picture
  436. *
  437. * @return string
  438. */
  439. public function getPicture()
  440. {
  441. return $this->picture;
  442. }
  443. /**
  444. * @return string
  445. */
  446. public function getToken()
  447. {
  448. return $this->token;
  449. }
  450. /**
  451. * @param string $token
  452. */
  453. public function setToken($token)
  454. {
  455. $this->token = $token;
  456. }
  457. public function getSageCompany(): ?string
  458. {
  459. return $this->sageCompany;
  460. }
  461. public function setSageCompany(?string $sageCompany): self
  462. {
  463. $this->sageCompany = $sageCompany;
  464. return $this;
  465. }
  466. public function getSageGroup(): ?string
  467. {
  468. return $this->sageGroup;
  469. }
  470. public function setSageGroup(?string $sageGroup): self
  471. {
  472. $this->sageGroup = $sageGroup;
  473. return $this;
  474. }
  475. /**
  476. * @return Collection<int, DeliveryNote>
  477. */
  478. public function getDeliveryNotes(): Collection
  479. {
  480. return $this->deliveryNotes;
  481. }
  482. public function addDeliveryNote(DeliveryNote $deliveryNote): self
  483. {
  484. if (!$this->deliveryNotes->contains($deliveryNote)) {
  485. $this->deliveryNotes[] = $deliveryNote;
  486. $deliveryNote->setSageCompany($this);
  487. }
  488. return $this;
  489. }
  490. public function removeDeliveryNote(DeliveryNote $deliveryNote): self
  491. {
  492. if ($this->deliveryNotes->removeElement($deliveryNote)) {
  493. // set the owning side to null (unless already changed)
  494. if ($deliveryNote->getSageCompany() === $this) {
  495. $deliveryNote->setSageCompany(null);
  496. }
  497. }
  498. return $this;
  499. }
  500. public function getBusinessType(): ?string
  501. {
  502. return $this->businessType;
  503. }
  504. public function setBusinessType(string $businessType): self
  505. {
  506. if (!BusinessTypeSettingsCompanyConstants::isValid($businessType)) {
  507. throw new \InvalidArgumentException("Invalid business type");
  508. }
  509. $this->businessType = $businessType;
  510. return $this;
  511. }
  512. public function getComision(): ?string
  513. {
  514. return $this->comision;
  515. }
  516. /** @param string|float|null $comision */
  517. public function setComision($comision): self
  518. {
  519. if ($comision === null || $comision === '') {
  520. $this->comision = null;
  521. return $this;
  522. }
  523. $norm = str_replace(',', '.', (string)$comision);
  524. $this->comision = number_format((float)$norm, 2, '.', '');
  525. return $this;
  526. }
  527. public function getSupplier(): ?Supplier {
  528. return $this->supplier;
  529. }
  530. public function setSupplier(?Supplier $supplier): self {
  531. $this->supplier = $supplier; return $this;
  532. }
  533. /**
  534. * @return Collection<int, Client>
  535. */
  536. public function getClients(): Collection
  537. {
  538. return $this->clients;
  539. }
  540. public function addClient(Client $client): self
  541. {
  542. if (!$this->clients->contains($client)) {
  543. $this->clients[] = $client;
  544. $client->addSettingsCompany($this);
  545. }
  546. return $this;
  547. }
  548. public function removeClient(Client $client): self
  549. {
  550. if ($this->clients->removeElement($client)) {
  551. $client->removeSettingsCompany($this);
  552. }
  553. return $this;
  554. }
  555. /**
  556. * @return Collection<int, Supplier>
  557. */
  558. public function getSuppliers(): Collection
  559. {
  560. return $this->suppliers;
  561. }
  562. public function addSupplier(Supplier $supplier): self
  563. {
  564. if (!$this->suppliers->contains($supplier)) {
  565. $this->suppliers[] = $supplier;
  566. $supplier->addSettingsCompany($this);
  567. }
  568. return $this;
  569. }
  570. public function removeSupplier(Supplier $supplier): self
  571. {
  572. if ($this->suppliers->removeElement($supplier)) {
  573. $supplier->removeSettingsCompany($this);
  574. }
  575. return $this;
  576. }
  577. public function getPriority(): ?int
  578. {
  579. return $this->priority;
  580. }
  581. public function setPriority(?int $priority): self
  582. {
  583. $this->priority = $priority;
  584. return $this;
  585. }
  586. public function getState(): ?string
  587. {
  588. return $this->state;
  589. }
  590. public function setState(?string $state): self
  591. {
  592. $this->state = $state;
  593. return $this;
  594. }
  595. }