src/Entity/TaxNumber.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation\Groups;
  7. /**
  8.  * @ORM\Table("TaxNumber")
  9.  *
  10.  * @ORM\HasLifecycleCallbacks()
  11.  *
  12.  * @ORM\Entity(repositoryClass="App\Repository\TaxNumberRepository")
  13.  */
  14. class TaxNumber
  15. {
  16.     public const TAXNUMBER_TYPE_VAT_ID 1;
  17.     public const TAXNUMBER_TYPE_DE_STNR 2;
  18.     public const TAXNUMBER_TYPE_ES_NIE 3;
  19.     public const TAXNUMBER_TYPE_ES_NIF 4;
  20.     public const TAXNUMBER_TYPE_ES_CIF 5;
  21.     public const TAXNUMBER_TYPE_DE_IDNR 6;
  22.     /**
  23.      * @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
  24.      *
  25.      * @ORM\Id()
  26.      *
  27.      * @ORM\GeneratedValue()
  28.      *
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
  34.      *
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $tax_number;
  38.     /**
  39.      * @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
  40.      *
  41.      * @ORM\Column(type="smallint")
  42.      */
  43.     private $type;
  44.     /**
  45.      * @Groups({"taxindex"})
  46.      *
  47.      * @ORM\ManyToOne(targetEntity="App\Entity\Account")
  48.      *
  49.      * @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="SET NULL")
  50.      */
  51.     private $account;
  52.     /**
  53.      * @Groups({"taxindex", "accountindex"})
  54.      *
  55.      * @ORM\Column(type="datetime")
  56.      */
  57.     private $created_at;
  58.     /**
  59.      * @Groups({"taxindex", "accountindex"})
  60.      *
  61.      * @ORM\ManyToMany(targetEntity="App\Entity\Person", inversedBy="taxNumbers")
  62.      *
  63.      * @ORM\JoinTable(name="PersonTaxNumbers",
  64.      *     joinColumns={@ORM\JoinColumn(name="taxnumber_id", referencedColumnName="id")},
  65.      *     inverseJoinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")}
  66.      *     )
  67.      */
  68.     private $person;
  69.     public function __construct()
  70.     {
  71.         $this->person = new ArrayCollection();
  72.     }
  73.     /**
  74.      * @ORM\PrePersist()
  75.      */
  76.     public function prePersist()
  77.     {
  78.         $this->setCreatedAt(new \DateTime());
  79.     }
  80.     /**
  81.      * @return int[]
  82.      */
  83.     public function getAvailableTypes(): array
  84.     {
  85.         return [
  86.             self::TAXNUMBER_TYPE_VAT_ID,
  87.             self::TAXNUMBER_TYPE_DE_STNR,
  88.             self::TAXNUMBER_TYPE_ES_NIE,
  89.             self::TAXNUMBER_TYPE_ES_NIF,
  90.             self::TAXNUMBER_TYPE_ES_CIF,
  91.             self::TAXNUMBER_TYPE_DE_IDNR,
  92.         ];
  93.     }
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getTaxNumber(): ?string
  99.     {
  100.         return $this->tax_number;
  101.     }
  102.     public function setTaxNumber(string $tax_number): self
  103.     {
  104.         $this->tax_number $tax_number;
  105.         return $this;
  106.     }
  107.     public function getType(): ?int
  108.     {
  109.         return $this->type;
  110.     }
  111.     public function setType(int $type): self
  112.     {
  113.         $this->type $type;
  114.         return $this;
  115.     }
  116.     public function getAccount(): ?Account
  117.     {
  118.         return $this->account;
  119.     }
  120.     public function setAccount(?Account $account): self
  121.     {
  122.         $this->account $account;
  123.         return $this;
  124.     }
  125.     public function getCreatedAt(): ?\DateTimeInterface
  126.     {
  127.         return $this->created_at;
  128.     }
  129.     public function setCreatedAt(\DateTimeInterface $created_at): self
  130.     {
  131.         $this->created_at $created_at;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return Collection|Person[]
  136.      */
  137.     public function getPerson(): Collection
  138.     {
  139.         return $this->person;
  140.     }
  141.     public function addPerson(Person $person): self
  142.     {
  143.         if (!$this->person->contains($person)) {
  144.             $this->person[] = $person;
  145.         }
  146.         return $this;
  147.     }
  148.     public function removePerson(Person $person): self
  149.     {
  150.         if ($this->person->contains($person)) {
  151.             $this->person->removeElement($person);
  152.         }
  153.         return $this;
  154.     }
  155. }