src/Entity/Client.php line 37
<?php/** @author Guerby Duval <info@tranzaksyon.com>* @link https://tranzaksyon.com* @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.*/namespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Delete;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Post;use ApiPlatform\Metadata\Put;use App\Enums\NaturalezaClient;use App\Enums\TipoOperacionEnum;use App\Interfaces\OwnerCompanyInterface;use App\Repository\ClientRepository;use App\Validator\EmailMultiple;use App\Validator\RazonSocial;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints\Length;use Symfony\Component\Validator\Constraints\NotBlank;use Symfony\Component\Validator\Constraints\NotNull;use Symfony\Component\Validator\Constraints\When;#[ORM\Entity(repositoryClass: ClientRepository::class)]#[ORM\UniqueConstraint(fields: ['idClient', 'typeId', 'sriInfo'])]#[RazonSocial()]class Client implements OwnerCompanyInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['client_out'])]private ?int $id = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]#[Groups(['client_out'])]private ?\DateTimeInterface $dateCreated;#[ORM\Column(length: 255)]#[NotBlank(groups: ['NewClient', 'Default'])]#[Groups(['client_out', 'client_in'])]private ?string $razonSocial = null;#[ORM\Column(length: 20)]#[NotBlank(groups: ['NewClient', 'Default', 'Manual'])]#[Length(min: 5, groups: ['NewClient', 'Default', 'Manual'])]#[Groups(['client_out', 'client_in'])]private ?string $idClient = null;#[ORM\Column(length: 5)]#[NotBlank(groups: ['NewClient', 'Default', 'Manual'])]#[Length(exactly: 1, groups: ['NewClient', 'Default', 'Manual'])]#[Groups(['client_out', 'client_in'])]private ?string $typeId = null;#[ORM\Column(length: 255, nullable: true)]// #[NotBlank(groups: ['NewClient', 'Default', 'Manual'])]#[Length(min: 3, groups: ['NewClient', 'Default', 'Manual'])]#[Groups(['client_out', 'client_in'])]private ?string $location = null;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Invoice::class)]private Collection $invoices;#[ORM\ManyToOne(inversedBy: 'clients')]#[ORM\JoinColumn(nullable: false)]private ?SriInfo $sriInfo = null;#[ORM\Column(length: 80, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $name = null;#[ORM\Column(length: 80, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $lastname = null;#[ORM\Column(length: 500, nullable: true)]#[NotBlank(groups: ['NewClient', 'Default', 'Manual'])]#[EmailMultiple(groups: ['NewClient', 'Default', 'Manual'])]#[Groups(['client_out', 'client_in'])]private ?string $email = null;#[ORM\Column(length: 20, nullable: true)]#[Groups(['client_out', 'client_in'])]#[Length(max: 20)]private ?string $phone = null;#[ORM\Column(length: 50, nullable: true)]private ?string $externalId = null;#[ORM\Column(nullable: true)]#[When('!this.getId() && this.getPhone() !== null and this.getPhone() !== ""', [new NotNull(groups: ['NewClient', 'Default', 'Manual'])])]private ?int $phoneAreaCode = 595;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $birthDate = null;#[ORM\Column(enumType: NaturalezaClient::class)]#[NotBlank]#[Groups(['client_out', 'client_in'])]private ?NaturalezaClient $naturaleza = null;#[ORM\Column(enumType: TipoOperacionEnum::class)]#[Groups(['client_out', 'client_in'])]#[NotBlank]private ?TipoOperacionEnum $tipoOperacion = null;#[ORM\Column(length: 3)]#[NotBlank]#[Groups(['client_out', 'client_in'])]private ?string $codigoPais = null;#[ORM\Column(length: 30)]#[Groups(['client_out', 'client_in'])]private ?string $nombrePais = null;#[ORM\Column(nullable: true)]#[Groups(['client_out', 'client_in'])]private ?int $tipoContribuyente = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $nombreFantasia = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $numeroCasa = null;#[ORM\Column(nullable: true)]#[Groups(['client_out', 'client_in'])]private ?int $codigoDepartamento = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $departamento = null;#[ORM\Column(nullable: true)]#[Groups(['client_out', 'client_in'])]private ?int $codigoDistrito = null;#[ORM\Column(length: 30, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $distrito = null;#[ORM\Column(nullable: true)]#[Groups(['client_out', 'client_in'])]private ?int $codigoCiudad = null;#[ORM\Column(length: 30, nullable: true)]#[Groups(['client_out', 'client_in'])]private ?string $ciudad = null;public function __construct(){$this->invoices = new ArrayCollection();$this->dateCreated = new \DateTime();}public function getId(): ?int{return $this->id;}public function getDateCreated(): ?\DateTimeInterface{return $this->dateCreated;}public function setDateCreated(\DateTimeInterface $dateCreated): self{$this->dateCreated = $dateCreated;return $this;}public function getRazonSocial(): ?string{return $this->razonSocial;}public function setRazonSocial(?string $razonSocial): self{$this->razonSocial = $razonSocial;return $this;}public function getIdClient(): ?string{return $this->idClient;}public function setIdClient(string $idClient): self{$this->idClient = $idClient;return $this;}public function getTypeId(): ?string{return $this->typeId;}public function setTypeId(string $typeId): self{$this->typeId = $typeId;return $this;}public function getLocation(): ?string{return $this->location;}public function setLocation(?string $location): self{$this->location = $location;return $this;}/*** @return Collection<int, Invoice>*/public function getInvoices(): Collection{return $this->invoices;}public function addInvoice(Invoice $invoice): self{if (!$this->invoices->contains($invoice)) {$this->invoices->add($invoice);$invoice->setClient($this);}return $this;}public function removeInvoice(Invoice $invoice): self{if ($this->invoices->removeElement($invoice)) {// set the owning side to null (unless already changed)if ($invoice->getClient() === $this) {$invoice->setClient(null);}}return $this;}public function getSriInfo(): ?SriInfo{return $this->sriInfo;}public function setSriInfo(?SriInfo $sriInfo): self{$this->sriInfo = $sriInfo;return $this;}public function getName(): ?string{return $this->name;}public function setName(?string $name): self{$this->name = $name;return $this;}public function getLastname(): ?string{return $this->lastname;}public function setLastname(?string $lastname): self{$this->lastname = $lastname;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): self{$this->phone = $phone;return $this;}public function getFormName(): string{return $this->razonSocial . ' (' . $this->idClient . ')';}public function getExternalId(): ?string{return $this->externalId;}public function setExternalId(?string $externalId): static{$this->externalId = $externalId;return $this;}public function getPhoneAreaCode(): ?int{return $this->phoneAreaCode;}public function setPhoneAreaCode(?int $phoneAreaCode): static{$this->phoneAreaCode = $phoneAreaCode;return $this;}public function getBirthDate(): ?\DateTimeInterface{return $this->birthDate;}public function setBirthDate(?\DateTimeInterface $birthDate): static{$this->birthDate = $birthDate;return $this;}public function getNaturaleza(): ?NaturalezaClient{return $this->naturaleza;}public function setNaturaleza(?NaturalezaClient $naturaleza): static{$this->naturaleza = $naturaleza;return $this;}public function getTipoOperacion(): ?TipoOperacionEnum{return $this->tipoOperacion;}public function setTipoOperacion(?TipoOperacionEnum $tipoOperacion): static{$this->tipoOperacion = $tipoOperacion;return $this;}public function getCodigoPais(): ?string{return $this->codigoPais;}public function setCodigoPais(string $codigoPais): static{$this->codigoPais = $codigoPais;return $this;}public function getNombrePais(): ?string{return $this->nombrePais;}public function setNombrePais(string $nombrePais): static{$this->nombrePais = $nombrePais;return $this;}public function getTipoContribuyente(): ?int{return $this->tipoContribuyente;}public function setTipoContribuyente(?int $tipoContribuyente): static{$this->tipoContribuyente = $tipoContribuyente;return $this;}public function getNombreFantasia(): ?string{return $this->nombreFantasia;}public function setNombreFantasia(?string $nombreFantasia): static{$this->nombreFantasia = $nombreFantasia;return $this;}public function getNumeroCasa(): ?string{return $this->numeroCasa;}public function setNumeroCasa(?string $numeroCasa): static{$this->numeroCasa = $numeroCasa;return $this;}public function getCodigoDepartamento(): ?int{return $this->codigoDepartamento;}public function setCodigoDepartamento(?int $codigoDepartamento): static{$this->codigoDepartamento = $codigoDepartamento;return $this;}public function getDepartamento(): ?string{return $this->departamento;}public function setDepartamento(?string $departamento): static{$this->departamento = $departamento;return $this;}public function getCodigoDistrito(): ?int{return $this->codigoDistrito;}public function setCodigoDistrito(?int $codigoDistrito): static{$this->codigoDistrito = $codigoDistrito;return $this;}public function getDistrito(): ?string{return $this->distrito;}public function setDistrito(?string $distrito): static{$this->distrito = $distrito;return $this;}public function getCodigoCiudad(): ?int{return $this->codigoCiudad;}public function setCodigoCiudad(?int $codigoCiudad): static{$this->codigoCiudad = $codigoCiudad;return $this;}public function getCiudad(): ?string{return $this->ciudad;}public function setCiudad(?string $ciudad): static{$this->ciudad = $ciudad;return $this;}public function copy(Client $client){// $propertyAccessor = PropertyAccess::createPropertyAccessor();//// foreach (get_class_methods($client) as $method) {// if (strpos($method, 'get') === 0 && $method !== 'getId') {// $property = lcfirst(substr($method, 3));// if ($propertyAccessor->isWritable($this, $property)) {// $value = $propertyAccessor->getValue($client, $property);// $propertyAccessor->setValue($this, $property, $value);// }// }// }$this->setNumeroCasa($client->getNumeroCasa())->setLocation($client->getLocation())->setCodigoPais($client->getCodigoPais())->setName($client->getName())->setPhone($client->getPhone())->setRazonSocial($client->getRazonSocial())->setIdClient($client->getIdClient())->setTypeId($client->getTypeId())->setTipoContribuyente($client->getTipoContribuyente())->setNaturaleza($client->getNaturaleza())->setTipoOperacion($client->getTipoOperacion())->setDepartamento($client->getDepartamento())->setDistrito($client->getDistrito())->setNombreFantasia($client->getNombreFantasia())->setCodigoCiudad($client->getCodigoCiudad())->setCodigoDepartamento($client->getCodigoDepartamento())->setCodigoDistrito($client->getCodigoDistrito());}}