<?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\Component\Serializer\Annotation\Groups;
/**
* Supplier
*
* @ORM\Table(name="suppliers")
* @ORM\Entity(repositoryClass="App\Repository\SupplierRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Supplier
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"destination", "supplier:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(name="company", type="string", length=255, nullable=true)
*
* @Groups({"destination", "supplier:read"})
*/
private ?string $company = null;
/**
* @ORM\Column(name="group_id", type="integer", nullable=true)
*/
private ?int $groupId = null;
/**
* @ORM\Column(name="contact", type="string", length=255, nullable=true)
*/
private ?string $contact = 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="address", type="string", length=255)
* @Assert\NotBlank()
*
* @Groups({"destination", "supplier:read"})
*/
private ?string $address = null;
/**
* @ORM\Column(name="population", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $population = null;
/**
* @ORM\Column(name="province", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $province = null;
/**
* @ORM\Column(name="region", type="string", length=255)
* @Assert\NotBlank()
*/
private ?string $region = null;
/**
* @ORM\Column(name="zip_code", type="string", length=255, nullable=true)
*/
private ?string $zipCode = 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()
*
* @Groups({"destination"})
*/
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)
*
* @Groups({"destination"})
*/
private ?string $email = null;
/**
* @ORM\Column(name="type", type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private ?string $type = null;
/**
* @ORM\Column(name="tags", type="string", length=255, nullable=true)
*/
private ?string $tags = null;
/**
* @ORM\Column(name="preference", type="string", length=255)
* @Assert\NotBlank()
*
* @Groups({"destination"})
*/
private ?string $preference = null;
/**
* @ORM\Column(name="created_id", type="integer")
*/
private ?int $createdId = null;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private ?\DateTime $createdAt = null;
/**
* @ORM\Column(name="updated_id", type="integer")
*/
private ?int $updatedId = null;
/**
* @ORM\Column(name="updated_at", type="datetime")
*/
private ?\DateTime $updatedAt = null;
/**
* @ORM\Column(name="state", type="boolean")
*/
private ?bool $state = null;
/**
* @ORM\Column(name="picture", type="string", length=255, nullable=true)
*/
private ?string $picture = null;
/**
* @ORM\Column(name="observation", type="text", nullable=true)
*/
private ?string $observation = null;
/**
* @ORM\Column(name="terms", type="text", nullable=true)
*/
private ?string $terms = null;
/**
* @ORM\Column(name="star", type="string", length=255, nullable=true)
*/
private ?string $star = null;
/**
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*
* @Groups({"destination", "supplier:read"})
*/
private ?string $name = null;
/**
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*
* @Groups({"destination"})
*/
private ?string $url = null;
/**
* @ORM\Column(name="commission", type="string", length=255, nullable=true)
*/
private ?string $commission = null;
/**
* @ORM\Column(name="iva", type="string", length=255, nullable=true)
*/
private ?string $iva = null;
/**
* @ORM\Column(name="accommodation", type="integer", nullable=true)
*/
private ?int $accommodation = null;
/**
* @ORM\Column(name="is_supplier_in_out", type="boolean", nullable=true)
*/
private ?bool $isSupplierInOut = null;
/**
* @ORM\Column(name="is_supplier_green_patio", type="boolean", nullable=true)
*/
private ?bool $isSupplierGreenPatio = null;
/**
* @ORM\Column(name="is_supplier_av_express", type="boolean", nullable=true)
*/
private ?bool $isSupplierAvExpress = null;
/**
* @ORM\Column(name="is_supplier_develup", type="boolean", nullable=true)
*/
private ?bool $isSupplierDevelup = 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")
*/
private ?bool $sentToSage = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $syncDate = null;
/**
* @ORM\OneToMany(targetEntity=SupplierAccountingAccount::class, mappedBy="supplier", orphanRemoval=true)
*/
private Collection $supplierAccountingAccounts;
/**
* @ORM\ManyToOne(targetEntity=SagePaymentMethod::class)
*/
private ?SagePaymentMethod $sagePaymentMethod = null;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Supplier")
* @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?Supplier $supplier = null;
/**
* @ORM\ManyToMany(targetEntity=SettingsCompany::class, inversedBy="suppliers")
*/
private Collection $settingsCompany;
public function __construct()
{
$this->supplierAccountingAccounts = new ArrayCollection();
$this->settingsCompany = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setGroupId(?int $groupId): self
{
$this->groupId = $groupId;
return $this;
}
public function getGroupId(): ?int
{
return $this->groupId;
}
public function setCompany(?string $company): self
{
$this->company = $company;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setContact(?string $contact): self
{
$this->contact = $contact;
return $this;
}
public function getContact(): ?string
{
return $this->contact;
}
public function setIdDocument(?string $idDocument): self
{
$this->idDocument = $idDocument;
return $this;
}
public function getIdDocument(): ?string
{
return $this->idDocument;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
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 setZipCode(?string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
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 setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setPreference(string $preference): self
{
$this->preference = $preference;
return $this;
}
public function getPreference(): ?string
{
return $this->preference;
}
public function setCreatedId(int $createdId): self
{
$this->createdId = $createdId;
return $this;
}
public function getCreatedId(): ?int
{
return $this->createdId;
}
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;
}
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;
}
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 setUpdatedAt(\Datetime $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue(): void
{
$this->createdAt = new \Datetime();
$this->sentToSage = false;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function setUpdatedAtValue(): void
{
$this->updatedAt = new \Datetime();
}
public function setStar(?string $star): self
{
$this->star = $star;
return $this;
}
public function getStar(): ?string
{
return $this->star;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setCommission(?string $commission): self
{
$this->commission = $commission;
return $this;
}
public function getCommission(): ?string
{
return $this->commission;
}
public function setIva(?string $iva): self
{
$this->iva = $iva;
return $this;
}
public function getIva(): ?string
{
return $this->iva;
}
public function setTerms(?string $terms): self
{
$this->terms = $terms;
return $this;
}
public function getTerms(): ?string
{
return $this->terms;
}
public function setTypeDocument(?string $typeDocument): self
{
$this->typeDocument = $typeDocument;
return $this;
}
public function getTypeDocument(): ?string
{
return $this->typeDocument;
}
public function setAccommodation(?int $accommodation): self
{
$this->accommodation = $accommodation;
return $this;
}
public function getAccommodation(): ?int
{
return $this->accommodation;
}
public function setTags(?string $tags): self
{
$this->tags = $tags;
return $this;
}
public function getTags(): ?string
{
return $this->tags;
}
public function setRegion(string $region): self
{
$this->region = $region;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setIsSupplierInOut(?bool $isSupplierInOut): self
{
$this->isSupplierInOut = $isSupplierInOut;
return $this;
}
public function getIsSupplierInOut(): ?bool
{
return $this->isSupplierInOut;
}
public function setIsSupplierGreenPatio(?bool $isSupplierGreenPatio): self
{
$this->isSupplierGreenPatio = $isSupplierGreenPatio;
return $this;
}
public function getIsSupplierGreenPatio(): ?bool
{
return $this->isSupplierGreenPatio;
}
public function setIsSupplierAvExpress(?bool $isSupplierAvExpress): self
{
$this->isSupplierAvExpress = $isSupplierAvExpress;
return $this;
}
public function getIsSupplierAvExpress(): ?bool
{
return $this->isSupplierAvExpress;
}
public function setIsSupplierDevelup(?bool $isSupplierDevelup): self
{
$this->isSupplierDevelup = $isSupplierDevelup;
return $this;
}
public function getIsSupplierDevelup(): ?bool
{
return $this->isSupplierDevelup;
}
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, SupplierAccountingAccount>
*/
public function getSupplierAccountingAccounts(): Collection
{
return $this->supplierAccountingAccounts;
}
public function addSupplierAccountingAccount(SupplierAccountingAccount $supplierAccountingAccount): self
{
if (!$this->supplierAccountingAccounts->contains($supplierAccountingAccount)) {
$this->supplierAccountingAccounts[] = $supplierAccountingAccount;
$supplierAccountingAccount->setSupplier($this);
}
return $this;
}
public function removeSupplierAccountingAccount(SupplierAccountingAccount $supplierAccountingAccount): self
{
if ($this->supplierAccountingAccounts->removeElement($supplierAccountingAccount)) {
// set the owning side to null (unless already changed)
if ($supplierAccountingAccount->getSupplier() === $this) {
$supplierAccountingAccount->setSupplier(null);
}
}
return $this;
}
public function getSagePaymentMethod(): ?SagePaymentMethod
{
return $this->sagePaymentMethod;
}
public function setSagePaymentMethod(?SagePaymentMethod $sagePaymentMethod): self
{
$this->sagePaymentMethod = $sagePaymentMethod;
return $this;
}
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): self
{
$this->supplier = $supplier;
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;
}
}