src/Entity/Supplier.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\Typology;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * Supplier
  11.  *
  12.  * @ORM\Table(name="suppliers")
  13.  * @ORM\Entity(repositoryClass="App\Repository\SupplierRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class Supplier
  17. {
  18.     /**
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      * 
  23.      * @Groups({"destination", "supplier:read"})
  24.      */
  25.     private ?int $id null;
  26.     /**
  27.      * @ORM\Column(name="company", type="string", length=255, nullable=true)
  28.      * 
  29.      * @Groups({"destination", "supplier:read"})
  30.      */
  31.     private ?string $company null;
  32.     /**
  33.      * @ORM\Column(name="group_id", type="integer", nullable=true)
  34.      */
  35.     private ?int $groupId null;
  36.     /**
  37.      * @ORM\Column(name="contact", type="string", length=255, nullable=true)
  38.      */
  39.     private ?string $contact null;
  40.     /**
  41.      * @ORM\Column(name="type_document", type="string", length=255, nullable=true)
  42.      */
  43.     private ?string $typeDocument null;
  44.     /**
  45.      * @ORM\Column(name="id_document", type="string", length=255, nullable=true)
  46.      */
  47.     private ?string $idDocument null;
  48.     /**
  49.      * @ORM\Column(name="address", type="string", length=255)
  50.      * @Assert\NotBlank()
  51.      * 
  52.      * @Groups({"destination", "supplier:read"})
  53.      */
  54.     private ?string $address null;
  55.     /**
  56.      * @ORM\Column(name="population", type="string", length=255)
  57.      * @Assert\NotBlank()
  58.      */
  59.     private ?string $population null;
  60.     /**
  61.      * @ORM\Column(name="province", type="string", length=255)
  62.      * @Assert\NotBlank()
  63.      */
  64.     private ?string $province null;
  65.     /**
  66.      * @ORM\Column(name="region", type="string", length=255)
  67.      * @Assert\NotBlank()
  68.      */
  69.     private ?string $region null;
  70.     /**
  71.      * @ORM\Column(name="zip_code", type="string", length=255, nullable=true)
  72.      */
  73.     private ?string $zipCode null;
  74.     /**
  75.      * @ORM\Column(name="country", type="string", length=255)
  76.      * @Assert\NotBlank()
  77.      */
  78.     private ?string $country null;
  79.     /**
  80.      * @ORM\Column(name="telephone", type="string", length=255)
  81.      * @Assert\NotBlank()
  82.      * 
  83.      * @Groups({"destination"})
  84.      */
  85.     private ?string $telephone null;
  86.     /**
  87.      * @ORM\Column(name="fax", type="string", length=255, nullable=true)
  88.      */
  89.     private ?string $fax null;
  90.     /**
  91.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  92.      * 
  93.      * @Groups({"destination"})
  94.      */
  95.     private ?string $email null;
  96.     /**
  97.      * @ORM\Column(name="type", type="string", length=255, nullable=true)
  98.      * @Assert\NotBlank()
  99.      */
  100.     private ?string $type null;
  101.     /**
  102.      * @ORM\Column(name="tags", type="string", length=255, nullable=true)
  103.      */
  104.     private ?string $tags null;
  105.     /**
  106.      * @ORM\Column(name="preference", type="string", length=255)
  107.      * @Assert\NotBlank()
  108.      * 
  109.      * @Groups({"destination"})
  110.      */
  111.     private ?string $preference null;
  112.     /**
  113.      * @ORM\Column(name="created_id", type="integer")
  114.      */
  115.     private ?int $createdId null;
  116.     /**
  117.      * @ORM\Column(name="created_at", type="datetime")
  118.      */
  119.     private ?\DateTime $createdAt null;
  120.     /**
  121.      * @ORM\Column(name="updated_id", type="integer")
  122.      */
  123.     private ?int $updatedId null;
  124.     /**
  125.      * @ORM\Column(name="updated_at", type="datetime")
  126.      */
  127.     private ?\DateTime $updatedAt null;
  128.     /**
  129.      * @ORM\Column(name="state", type="boolean")
  130.      */
  131.     private ?bool $state null;
  132.     /**
  133.      * @ORM\Column(name="picture", type="string", length=255, nullable=true)
  134.      */
  135.     private ?string $picture null;
  136.     /**
  137.      * @ORM\Column(name="observation", type="text", nullable=true)
  138.      */
  139.     private ?string $observation null;
  140.     /**
  141.      * @ORM\Column(name="terms", type="text", nullable=true)
  142.      */
  143.     private ?string $terms null;
  144.     /**
  145.      * @ORM\Column(name="star", type="string", length=255, nullable=true)
  146.      */
  147.     private ?string $star null;
  148.     /**
  149.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  150.      * 
  151.      * @Groups({"destination", "supplier:read"})
  152.      */
  153.     private ?string $name null;
  154.     /**
  155.      * @ORM\Column(name="url", type="string", length=255, nullable=true)
  156.      * 
  157.      * @Groups({"destination"})
  158.      */
  159.     private ?string $url null;
  160.     /**
  161.      * @ORM\Column(name="commission", type="string", length=255, nullable=true)
  162.      */
  163.     private ?string $commission null;
  164.     /**
  165.      * @ORM\Column(name="iva", type="string", length=255, nullable=true)
  166.      */
  167.     private ?string $iva null;
  168.     /**
  169.      * @ORM\Column(name="accommodation", type="integer", nullable=true)
  170.      */
  171.     private ?int $accommodation null;
  172.     /**
  173.      * @ORM\Column(name="is_supplier_in_out", type="boolean", nullable=true)
  174.      */
  175.     private ?bool $isSupplierInOut null;
  176.     /**
  177.      * @ORM\Column(name="is_supplier_green_patio", type="boolean", nullable=true)
  178.      */
  179.     private ?bool $isSupplierGreenPatio null;
  180.     /**
  181.      * @ORM\Column(name="is_supplier_av_express", type="boolean", nullable=true)
  182.      */
  183.     private ?bool $isSupplierAvExpress null;
  184.     /**
  185.      * @ORM\Column(name="is_supplier_develup", type="boolean", nullable=true)
  186.      */
  187.     private ?bool $isSupplierDevelup null;
  188.     /**
  189.      * @ORM\Column(type="string", length=100, nullable=true)
  190.      */
  191.     private ?string $typology null;
  192.     /**
  193.      * @ORM\Column(type="string", length=20, nullable=true)
  194.      */
  195.     private ?string $sageCode null;
  196.     /**
  197.      * @ORM\Column(type="string", length=34, nullable=true)
  198.      */
  199.     private ?string $iban null;
  200.     /**
  201.      * @ORM\Column(type="string", length=20, nullable=true)
  202.      */
  203.     private ?string $swift null;
  204.     /**
  205.      * @ORM\Column(type="string", length=100, nullable=true)
  206.      */
  207.     private ?string $bankName null;
  208.     /**
  209.      * @ORM\Column(type="boolean")
  210.      */
  211.     private ?bool $sentToSage null;
  212.     /**
  213.      * @ORM\Column(type="datetime", nullable=true)
  214.      */
  215.     private ?\DateTime $syncDate null;
  216.     /**
  217.      * @ORM\OneToMany(targetEntity=SupplierAccountingAccount::class, mappedBy="supplier", orphanRemoval=true)
  218.      */
  219.     private Collection $supplierAccountingAccounts;
  220.     /**
  221.      * @ORM\ManyToOne(targetEntity=SagePaymentMethod::class)
  222.      */
  223.     private ?SagePaymentMethod $sagePaymentMethod null;
  224.     /**
  225.      * @ORM\OneToOne(targetEntity="App\Entity\Supplier")
  226.      * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  227.      */
  228.     private ?Supplier $supplier null;
  229.     /**
  230.      * @ORM\ManyToMany(targetEntity=SettingsCompany::class, inversedBy="suppliers")
  231.      */
  232.     private Collection $settingsCompany;
  233.     public function __construct()
  234.     {
  235.         $this->supplierAccountingAccounts = new ArrayCollection();
  236.         $this->settingsCompany = new ArrayCollection();
  237.     }
  238.     public function getId(): ?int
  239.     {
  240.         return $this->id;
  241.     }
  242.     public function setGroupId(?int $groupId): self
  243.     {
  244.         $this->groupId $groupId;
  245.         return $this;
  246.     }
  247.     public function getGroupId(): ?int
  248.     {
  249.         return $this->groupId;
  250.     }
  251.     public function setCompany(?string $company): self
  252.     {
  253.         $this->company $company;
  254.         return $this;
  255.     }
  256.     public function getCompany(): ?string
  257.     {
  258.         return $this->company;
  259.     }
  260.     public function setContact(?string $contact): self
  261.     {
  262.         $this->contact $contact;
  263.         return $this;
  264.     }
  265.     public function getContact(): ?string
  266.     {
  267.         return $this->contact;
  268.     }
  269.     public function setIdDocument(?string $idDocument): self
  270.     {
  271.         $this->idDocument $idDocument;
  272.         return $this;
  273.     }
  274.     public function getIdDocument(): ?string
  275.     {
  276.         return $this->idDocument;
  277.     }
  278.     public function setAddress(string $address): self
  279.     {
  280.         $this->address $address;
  281.         return $this;
  282.     }
  283.     public function getAddress(): ?string
  284.     {
  285.         return $this->address;
  286.     }
  287.     public function setPopulation(string $population): self
  288.     {
  289.         $this->population $population;
  290.         return $this;
  291.     }
  292.     public function getPopulation(): ?string
  293.     {
  294.         return $this->population;
  295.     }
  296.     public function setProvince(string $province): self
  297.     {
  298.         $this->province $province;
  299.         return $this;
  300.     }
  301.     public function getProvince(): ?string
  302.     {
  303.         return $this->province;
  304.     }
  305.     public function setZipCode(?string $zipCode): self
  306.     {
  307.         $this->zipCode $zipCode;
  308.         return $this;
  309.     }
  310.     public function getZipCode(): ?string
  311.     {
  312.         return $this->zipCode;
  313.     }
  314.     public function setCountry(string $country): self
  315.     {
  316.         $this->country $country;
  317.         return $this;
  318.     }
  319.     public function getCountry(): ?string
  320.     {
  321.         return $this->country;
  322.     }
  323.     public function setTelephone(string $telephone): self
  324.     {
  325.         $this->telephone $telephone;
  326.         return $this;
  327.     }
  328.     public function getTelephone(): ?string
  329.     {
  330.         return $this->telephone;
  331.     }
  332.     public function setFax(?string $fax): self
  333.     {
  334.         $this->fax $fax;
  335.         return $this;
  336.     }
  337.     public function getFax(): ?string
  338.     {
  339.         return $this->fax;
  340.     }
  341.     public function setEmail(?string $email): self
  342.     {
  343.         $this->email $email;
  344.         return $this;
  345.     }
  346.     public function getEmail(): ?string
  347.     {
  348.         return $this->email;
  349.     }
  350.     public function setType(?string $type): self
  351.     {
  352.         $this->type $type;
  353.         return $this;
  354.     }
  355.     public function getType(): ?string
  356.     {
  357.         return $this->type;
  358.     }
  359.     public function setPreference(string $preference): self
  360.     {
  361.         $this->preference $preference;
  362.         return $this;
  363.     }
  364.     public function getPreference(): ?string
  365.     {
  366.         return $this->preference;
  367.     }
  368.     public function setCreatedId(int $createdId): self
  369.     {
  370.         $this->createdId $createdId;
  371.         return $this;
  372.     }
  373.     public function getCreatedId(): ?int
  374.     {
  375.         return $this->createdId;
  376.     }
  377.     public function setUpdatedId(int $updatedId): self
  378.     {
  379.         $this->updatedId $updatedId;
  380.         return $this;
  381.     }
  382.     public function getUpdatedId(): ?int
  383.     {
  384.         return $this->updatedId;
  385.     }
  386.     public function setState(bool $state): self
  387.     {
  388.         $this->state $state;
  389.         return $this;
  390.     }
  391.     public function getState(): ?bool
  392.     {
  393.         return $this->state;
  394.     }
  395.     public function setPicture(?string $picture): self
  396.     {
  397.         $this->picture $picture;
  398.         return $this;
  399.     }
  400.     public function getPicture(): ?string
  401.     {
  402.         return $this->picture;
  403.     }
  404.     public function setObservation(?string $observation): self
  405.     {
  406.         $this->observation $observation;
  407.         return $this;
  408.     }
  409.     public function getObservation(): ?string
  410.     {
  411.         return $this->observation;
  412.     }
  413.     public function setCreatedAt(\Datetime $createdAt): self
  414.     {
  415.         $this->createdAt $createdAt;
  416.         return $this;
  417.     }
  418.     public function getCreatedAt(): ?\DateTime
  419.     {
  420.         return $this->createdAt;
  421.     }
  422.     public function setUpdatedAt(\Datetime $updatedAt): self
  423.     {
  424.         $this->updatedAt $updatedAt;
  425.         return $this;
  426.     }
  427.     public function getUpdatedAt(): ?\DateTime
  428.     {
  429.         return $this->updatedAt;
  430.     }
  431.     /**
  432.      * @ORM\PrePersist
  433.      */
  434.     public function setCreatedAtValue(): void
  435.     {
  436.         $this->createdAt = new \Datetime();
  437.         $this->sentToSage false;
  438.     }
  439.     /**
  440.      * @ORM\PrePersist
  441.      * @ORM\PreUpdate
  442.      */
  443.     public function setUpdatedAtValue(): void
  444.     {
  445.         $this->updatedAt = new \Datetime();
  446.     }
  447.     public function setStar(?string $star): self
  448.     {
  449.         $this->star $star;
  450.         return $this;
  451.     }
  452.     public function getStar(): ?string
  453.     {
  454.         return $this->star;
  455.     }
  456.     public function setName(?string $name): self
  457.     {
  458.         $this->name $name;
  459.         return $this;
  460.     }
  461.     public function getName(): ?string
  462.     {
  463.         return $this->name;
  464.     }
  465.     public function setUrl(?string $url): self
  466.     {
  467.         $this->url $url;
  468.         return $this;
  469.     }
  470.     public function getUrl(): ?string
  471.     {
  472.         return $this->url;
  473.     }
  474.     public function setCommission(?string $commission): self
  475.     {
  476.         $this->commission $commission;
  477.         return $this;
  478.     }
  479.     public function getCommission(): ?string
  480.     {
  481.         return $this->commission;
  482.     }
  483.     public function setIva(?string $iva): self
  484.     {
  485.         $this->iva $iva;
  486.         return $this;
  487.     }
  488.     public function getIva(): ?string
  489.     {
  490.         return $this->iva;
  491.     }
  492.     public function setTerms(?string $terms): self
  493.     {
  494.         $this->terms $terms;
  495.         return $this;
  496.     }
  497.     public function getTerms(): ?string
  498.     {
  499.         return $this->terms;
  500.     }
  501.     public function setTypeDocument(?string $typeDocument): self
  502.     {
  503.         $this->typeDocument $typeDocument;
  504.         return $this;
  505.     }
  506.     public function getTypeDocument(): ?string
  507.     {
  508.         return $this->typeDocument;
  509.     }
  510.     public function setAccommodation(?int $accommodation): self
  511.     {
  512.         $this->accommodation $accommodation;
  513.         return $this;
  514.     }
  515.     public function getAccommodation(): ?int
  516.     {
  517.         return $this->accommodation;
  518.     }
  519.     public function setTags(?string $tags): self
  520.     {
  521.         $this->tags $tags;
  522.         return $this;
  523.     }
  524.     public function getTags(): ?string
  525.     {
  526.         return $this->tags;
  527.     }
  528.     public function setRegion(string $region): self
  529.     {
  530.         $this->region $region;
  531.         return $this;
  532.     }
  533.     public function getRegion(): ?string
  534.     {
  535.         return $this->region;
  536.     }
  537.     public function setIsSupplierInOut(?bool $isSupplierInOut): self
  538.     {
  539.         $this->isSupplierInOut $isSupplierInOut;
  540.         return $this;
  541.     }
  542.     public function getIsSupplierInOut(): ?bool
  543.     {
  544.         return $this->isSupplierInOut;
  545.     }
  546.     public function setIsSupplierGreenPatio(?bool $isSupplierGreenPatio): self
  547.     {
  548.         $this->isSupplierGreenPatio $isSupplierGreenPatio;
  549.         return $this;
  550.     }
  551.     public function getIsSupplierGreenPatio(): ?bool
  552.     {
  553.         return $this->isSupplierGreenPatio;
  554.     }
  555.     public function setIsSupplierAvExpress(?bool $isSupplierAvExpress): self
  556.     {
  557.         $this->isSupplierAvExpress $isSupplierAvExpress;
  558.         return $this;
  559.     }
  560.     public function getIsSupplierAvExpress(): ?bool
  561.     {
  562.         return $this->isSupplierAvExpress;
  563.     }
  564.     public function setIsSupplierDevelup(?bool $isSupplierDevelup): self
  565.     {
  566.         $this->isSupplierDevelup $isSupplierDevelup;
  567.         return $this;
  568.     }
  569.     public function getIsSupplierDevelup(): ?bool
  570.     {
  571.         return $this->isSupplierDevelup;
  572.     }
  573.     public function getTypology(): ?string
  574.     {
  575.         return $this->typology;
  576.     }
  577.     public function setTypology(?string $typology): self
  578.     {
  579.         if (!Typology::isValid($typology) && $typology !== null) {
  580.             throw new \InvalidArgumentException("Sector inválido: $typology");
  581.         }
  582.         $this->typology $typology;
  583.         return $this;
  584.     }
  585.     public function getSageCode(): ?string
  586.     {
  587.         return $this->sageCode;
  588.     }
  589.     public function setSageCode(string $sageCode): self
  590.     {
  591.         $this->sageCode $sageCode;
  592.         return $this;
  593.     }
  594.     public function getIban(): ?string
  595.     {
  596.         return $this->iban;
  597.     }
  598.     public function setIban(?string $iban): self
  599.     {
  600.         $this->iban $iban;
  601.         return $this;
  602.     }
  603.     public function getSwift(): ?string
  604.     {
  605.         return $this->swift;
  606.     }
  607.     public function setSwift(?string $swift): self
  608.     {
  609.         $this->swift $swift;
  610.         return $this;
  611.     }
  612.     public function getBankName(): ?string
  613.     {
  614.         return $this->bankName;
  615.     }
  616.     public function setBankName(?string $bankName): self
  617.     {
  618.         $this->bankName $bankName;
  619.         return $this;
  620.     }
  621.     public function isSentToSage(): ?bool
  622.     {
  623.         return $this->sentToSage;
  624.     }
  625.     public function setSentToSage(bool $sentToSage): self
  626.     {
  627.         $this->sentToSage $sentToSage;
  628.         return $this;
  629.     }
  630.     public function getSyncDate(): ?\DateTimeInterface
  631.     {
  632.         return $this->syncDate;
  633.     }
  634.     public function setSyncDate(?\DateTimeInterface $syncDate): self
  635.     {
  636.         $this->syncDate $syncDate;
  637.         return $this;
  638.     }
  639.     /**
  640.      * @return Collection<int, SupplierAccountingAccount>
  641.      */
  642.     public function getSupplierAccountingAccounts(): Collection
  643.     {
  644.         return $this->supplierAccountingAccounts;
  645.     }
  646.     public function addSupplierAccountingAccount(SupplierAccountingAccount $supplierAccountingAccount): self
  647.     {
  648.         if (!$this->supplierAccountingAccounts->contains($supplierAccountingAccount)) {
  649.             $this->supplierAccountingAccounts[] = $supplierAccountingAccount;
  650.             $supplierAccountingAccount->setSupplier($this);
  651.         }
  652.         return $this;
  653.     }
  654.     public function removeSupplierAccountingAccount(SupplierAccountingAccount $supplierAccountingAccount): self
  655.     {
  656.         if ($this->supplierAccountingAccounts->removeElement($supplierAccountingAccount)) {
  657.             // set the owning side to null (unless already changed)
  658.             if ($supplierAccountingAccount->getSupplier() === $this) {
  659.                 $supplierAccountingAccount->setSupplier(null);
  660.             }
  661.         }
  662.         return $this;
  663.     }
  664.     public function getSagePaymentMethod(): ?SagePaymentMethod
  665.     {
  666.         return $this->sagePaymentMethod;
  667.     }
  668.     public function setSagePaymentMethod(?SagePaymentMethod $sagePaymentMethod): self
  669.     {
  670.         $this->sagePaymentMethod $sagePaymentMethod;
  671.         return $this;
  672.     }
  673.     public function getSupplier(): ?Supplier
  674.     {
  675.         return $this->supplier;
  676.     }
  677.     public function setSupplier(?Supplier $supplier): self
  678.     {
  679.         $this->supplier $supplier;
  680.         return $this;
  681.     }
  682.     /**
  683.      * @return Collection<int, SettingsCompany>
  684.      */
  685.     public function getSettingsCompany(): Collection
  686.     {
  687.         return $this->settingsCompany;
  688.     }
  689.     public function addSettingsCompany(SettingsCompany $settingsCompany): self
  690.     {
  691.         if (!$this->settingsCompany->contains($settingsCompany)) {
  692.             $this->settingsCompany[] = $settingsCompany;
  693.         }
  694.         return $this;
  695.     }
  696.     public function removeSettingsCompany(SettingsCompany $settingsCompany): self
  697.     {
  698.         $this->settingsCompany->removeElement($settingsCompany);
  699.         return $this;
  700.     }
  701. }