<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
/**
* @ORM\Table("TaxNumber")
*
* @ORM\HasLifecycleCallbacks()
*
* @ORM\Entity(repositoryClass="App\Repository\TaxNumberRepository")
*/
class TaxNumber
{
public const TAXNUMBER_TYPE_VAT_ID = 1;
public const TAXNUMBER_TYPE_DE_STNR = 2;
public const TAXNUMBER_TYPE_ES_NIE = 3;
public const TAXNUMBER_TYPE_ES_NIF = 4;
public const TAXNUMBER_TYPE_ES_CIF = 5;
public const TAXNUMBER_TYPE_DE_IDNR = 6;
/**
* @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
*
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
*
* @ORM\Column(type="string", length=255)
*/
private $tax_number;
/**
* @Groups({"taxnumbers", "taxindex", "accountindex", "personindex"})
*
* @ORM\Column(type="smallint")
*/
private $type;
/**
* @Groups({"taxindex"})
*
* @ORM\ManyToOne(targetEntity="App\Entity\Account")
*
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $account;
/**
* @Groups({"taxindex", "accountindex"})
*
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @Groups({"taxindex", "accountindex"})
*
* @ORM\ManyToMany(targetEntity="App\Entity\Person", inversedBy="taxNumbers")
*
* @ORM\JoinTable(name="PersonTaxNumbers",
* joinColumns={@ORM\JoinColumn(name="taxnumber_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")}
* )
*/
private $person;
public function __construct()
{
$this->person = new ArrayCollection();
}
/**
* @ORM\PrePersist()
*/
public function prePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @return int[]
*/
public function getAvailableTypes(): array
{
return [
self::TAXNUMBER_TYPE_VAT_ID,
self::TAXNUMBER_TYPE_DE_STNR,
self::TAXNUMBER_TYPE_ES_NIE,
self::TAXNUMBER_TYPE_ES_NIF,
self::TAXNUMBER_TYPE_ES_CIF,
self::TAXNUMBER_TYPE_DE_IDNR,
];
}
public function getId(): ?int
{
return $this->id;
}
public function getTaxNumber(): ?string
{
return $this->tax_number;
}
public function setTaxNumber(string $tax_number): self
{
$this->tax_number = $tax_number;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getAccount(): ?Account
{
return $this->account;
}
public function setAccount(?Account $account): self
{
$this->account = $account;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* @return Collection|Person[]
*/
public function getPerson(): Collection
{
return $this->person;
}
public function addPerson(Person $person): self
{
if (!$this->person->contains($person)) {
$this->person[] = $person;
}
return $this;
}
public function removePerson(Person $person): self
{
if ($this->person->contains($person)) {
$this->person->removeElement($person);
}
return $this;
}
}