<?php
namespace App\Entity;
use App\Constants\Typology;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Clientes
*
* @ORM\Table(name="clients")
* @ORM\Entity(repositoryClass="App\Repository\ClientRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Client
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(name="type", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $type = null;
/**
* @ORM\Column(name="name", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $name = null;
/**
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private ?string $title = null;
/**
* @ORM\Column(name="address", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $address = null;
/**
* @ORM\Column(name="address_number", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $addressNumber = null;
/**
* @ORM\Column(name="zip_code", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $zipCode = null;
/**
* @ORM\Column(name="population", type="string", length=255, nullable=true)
*/
private ?string $population = null;
/**
* @ORM\Column(name="province", type="string", length=255, nullable=true)
*/
private ?string $province = null;
/**
* @ORM\Column(name="region", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $region = null;
/**
* @ORM\Column(name="country", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $country = null;
/**
* @ORM\Column(name="telephone", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $telephone = null;
/**
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
*/
private ?string $fax = null;
/**
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private ?string $email = null;
/**
* @ORM\Column(name="gds", type="string", length=255, nullable=true)
*/
private ?string $gds = null;
/**
* @ORM\Column(name="type_document", type="string", length=255, nullable=true)
*/
private ?string $typeDocument = null;
/**
* @ORM\Column(name="id_document", type="string", length=255, nullable=true)
*/
private ?string $idDocument = null;
/**
* @ORM\Column(name="observation", type="text", nullable=true)
*/
private ?string $observation = null;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private ?\DateTime $createdAt = null;
/**
* @ORM\Column(name="created_id", type="integer", nullable=true)
*/
private ?int $createdId = null;
/**
* @ORM\Column(name="updated_at", type="datetime")
*/
private ?\DateTime $updatedAt = null;
/**
* @ORM\Column(name="updated_id", type="integer", nullable=true)
*/
private ?int $updatedId = null;
/**
* @ORM\Column(name="status", type="boolean")
*/
private ?bool $state = null;
/**
* @ORM\Column(name="picture", type="string", length=255, nullable=true)
*/
private ?string $picture = null;
/**
* @ORM\Column(name="competency", type="string", length=255, nullable=true)
*/
private ?string $competency = null;
/**
* @ORM\Column(name="action", type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private ?string $action = null;
/**
* @ORM\Column(name="return_investment", type="string", length=255, nullable=true)
*/
private ?string $returnInvestment = null;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private ?string $typology = null;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private ?string $sageCode = null;
/**
* @ORM\Column(type="string", length=34, nullable=true)
*/
private ?string $iban = null;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private ?string $swift = null;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private ?string $bankName = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $sentToSage = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $syncDate = null;
/**
* @ORM\OneToMany(targetEntity=ClientAccountingAccount::class, mappedBy="client", orphanRemoval=true)
*/
private Collection $clientAccountingAccounts;
/**
* @ORM\OneToMany(targetEntity=DeliveryNote::class, mappedBy="client")
*/
private Collection $deliveryNotes;
/**
* @ORM\ManyToOne(targetEntity=SagePaymentMethod::class)
*/
private ?SagePaymentMethod $sagePaymentMethod = null;
/**
* @ORM\OneToMany(targetEntity=SagePayment::class, mappedBy="client")
*/
private Collection $sagePayments;
/**
* @ORM\ManyToMany(targetEntity=SettingsCompany::class, inversedBy="clients")
*/
private Collection $settingsCompany;
public function __construct()
{
$this->clientAccountingAccounts = new ArrayCollection();
$this->deliveryNotes = new ArrayCollection();
$this->sagePayments = new ArrayCollection();
$this->settingsCompany = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddressNumber(string $addressNumber): self
{
$this->addressNumber = $addressNumber;
return $this;
}
public function getAddressNumber(): ?string
{
return $this->addressNumber;
}
public function setZipCode(string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setPopulation(?string $population): self
{
$this->population = $population;
return $this;
}
public function getPopulation(): ?string
{
return $this->population;
}
public function setProvince(?string $province): self
{
$this->province = $province;
return $this;
}
public function getProvince(): ?string
{
return $this->province;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setFax(?string $fax): self
{
$this->fax = $fax;
return $this;
}
public function getFax(): ?string
{
return $this->fax;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setGds(?string $gds): self
{
$this->gds = $gds;
return $this;
}
public function getGds(): ?string
{
return $this->gds;
}
public function setIdDocument(?string $idDocument): self
{
$this->idDocument = $idDocument;
return $this;
}
public function getIdDocument(): ?string
{
return $this->idDocument;
}
public function setObservation(?string $observation): self
{
$this->observation = $observation;
return $this;
}
public function getObservation(): ?string
{
return $this->observation;
}
public function setCreatedAt(\Datetime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
public function setCreatedId(?int $createdId): self
{
$this->createdId = $createdId;
return $this;
}
public function getCreatedId(): ?int
{
return $this->createdId;
}
public function setUpdatedAt(\Datetime $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
public function setUpdatedId(?int $updatedId): self
{
$this->updatedId = $updatedId;
return $this;
}
public function getUpdatedId(): ?int
{
return $this->updatedId;
}
public function setState(bool $state): self
{
$this->state = $state;
return $this;
}
/**
* Get state
*
* @return bool
*/
public function getState(): ?bool
{
return $this->state;
}
public function setPicture(?string $picture): self
{
$this->picture = $picture;
return $this;
}
public function getPicture(): ?string
{
return $this->picture;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue(): void
{
$this->createdAt = new \Datetime();
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function setUpdatedAtValue(): void
{
$this->updatedAt = new \Datetime();
}
public function setCompetency(?string $competency): self
{
$this->competency = $competency;
return $this;
}
public function getCompetency(): ?string
{
return $this->competency;
}
public function setAction(string $action): self
{
$this->action = $action;
return $this;
}
public function getAction(): ?string
{
return $this->action;
}
public function setTypeDocument(?string $typeDocument): self
{
$this->typeDocument = $typeDocument;
return $this;
}
public function getTypeDocument(): ?string
{
return $this->typeDocument;
}
public function setReturnInvestment(?string $returnInvestment): self
{
$this->returnInvestment = $returnInvestment;
return $this;
}
public function getReturnInvestment(): ?string
{
return $this->returnInvestment;
}
public function setRegion(string $region): self
{
$this->region = $region;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function getTypology(): ?string
{
return $this->typology;
}
public function setTypology(?string $typology): self
{
if (!Typology::isValid($typology) && $typology !== null) {
throw new \InvalidArgumentException("Sector inválido: $typology");
}
$this->typology = $typology;
return $this;
}
public function getSageCode(): ?string
{
return $this->sageCode;
}
public function setSageCode(?string $sageCode): self
{
$this->sageCode = $sageCode;
return $this;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): self
{
$this->iban = $iban;
return $this;
}
public function getSwift(): ?string
{
return $this->swift;
}
public function setSwift(?string $swift): self
{
$this->swift = $swift;
return $this;
}
public function getBankName(): ?string
{
return $this->bankName;
}
public function setBankName(?string $bankName): self
{
$this->bankName = $bankName;
return $this;
}
public function isSentToSage(): ?bool
{
return $this->sentToSage;
}
public function setSentToSage(bool $sentToSage): self
{
$this->sentToSage = $sentToSage;
return $this;
}
public function getSyncDate(): ?\DateTimeInterface
{
return $this->syncDate;
}
public function setSyncDate(?\DateTimeInterface $syncDate): self
{
$this->syncDate = $syncDate;
return $this;
}
/**
* @return Collection<int, ClientAccountingAccount>
*/
public function getClientAccountingAccounts(): Collection
{
return $this->clientAccountingAccounts;
}
public function addClientAccountingAccount(ClientAccountingAccount $clientAccountingAccount): self
{
if (!$this->clientAccountingAccounts->contains($clientAccountingAccount)) {
$this->clientAccountingAccounts[] = $clientAccountingAccount;
$clientAccountingAccount->setClient($this);
}
return $this;
}
public function removeClientAccountingAccount(ClientAccountingAccount $clientAccountingAccount): self
{
if ($this->clientAccountingAccounts->removeElement($clientAccountingAccount)) {
// set the owning side to null (unless already changed)
if ($clientAccountingAccount->getClient() === $this) {
$clientAccountingAccount->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, DeliveryNote>
*/
public function getDeliveryNotes(): Collection
{
return $this->deliveryNotes;
}
public function addDeliveryNote(DeliveryNote $deliveryNote): self
{
if (!$this->deliveryNotes->contains($deliveryNote)) {
$this->deliveryNotes[] = $deliveryNote;
$deliveryNote->setClient($this);
}
return $this;
}
public function removeDeliveryNote(DeliveryNote $deliveryNote): self
{
if ($this->deliveryNotes->removeElement($deliveryNote)) {
// set the owning side to null (unless already changed)
if ($deliveryNote->getClient() === $this) {
$deliveryNote->setClient(null);
}
}
return $this;
}
public function getSagePaymentMethod(): ?SagePaymentMethod
{
return $this->sagePaymentMethod;
}
public function setSagePaymentMethod(?SagePaymentMethod $sagePaymentMethod): self
{
$this->sagePaymentMethod = $sagePaymentMethod;
return $this;
}
/**
* @return Collection<int, SagePayment>
*/
public function getSagePayments(): Collection
{
return $this->sagePayments;
}
public function addSagePayment(SagePayment $payment): self
{
if (!$this->sagePayments->contains($payment)) {
$this->sagePayments[] = $payment;
$payment->setClient($this);
}
return $this;
}
public function removeSagePayment(SagePayment $payment): self
{
if ($this->sagePayments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getClient() === $this) {
$payment->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, SettingsCompany>
*/
public function getSettingsCompany(): Collection
{
return $this->settingsCompany;
}
public function addSettingsCompany(SettingsCompany $settingsCompany): self
{
if (!$this->settingsCompany->contains($settingsCompany)) {
$this->settingsCompany[] = $settingsCompany;
}
return $this;
}
public function removeSettingsCompany(SettingsCompany $settingsCompany): self
{
$this->settingsCompany->removeElement($settingsCompany);
return $this;
}
}