src/Entity/Fournisseur.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FournisseurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassFournisseurRepository::class)]
  9. class Fournisseur
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $nom null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $telephone null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  22.     private ?string $adresse null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $ville null;
  25.     #[ORM\Column(length100nullabletrue)]
  26.     private ?string $codePostal null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $pays null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $numeroIdentification null// SIRET, IFU, etc.
  31.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  32.     private ?string $notes null;
  33.     #[ORM\Column]
  34.     private ?bool $estActif true;
  35.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  36.     private ?\DateTimeInterface $createdAt null;
  37.     #[ORM\OneToMany(mappedBy'fournisseur'targetEntityAchatFournisseur::class)]
  38.     private Collection $achats;
  39.     #[ORM\OneToMany(mappedBy'fournisseur'targetEntityDetteFournisseur::class)]
  40.     private Collection $dettes;
  41.     #[ORM\OneToMany(mappedBy'fournisseur'targetEntityPaiementFournisseur::class)]
  42.     private Collection $paiements;
  43.     #[ORM\OneToMany(mappedBy'fournisseur'targetEntityEntreeStock::class)]
  44.     private Collection $entreesStock;
  45.     #[ORM\OneToMany(mappedBy'fournisseur'targetEntityCommandeFournisseur::class, orphanRemovaltrue)]
  46.     private Collection $commandes;
  47.     public function __construct()
  48.     {
  49.         $this->achats = new ArrayCollection();
  50.         $this->dettes = new ArrayCollection();
  51.         $this->paiements = new ArrayCollection();
  52.         $this->entreesStock = new ArrayCollection();
  53.         $this->commandes = new ArrayCollection();
  54.         $this->createdAt = new \DateTime();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getNom(): ?string
  61.     {
  62.         return $this->nom;
  63.     }
  64.     public function setNom(string $nom): static
  65.     {
  66.         $this->nom $nom;
  67.         return $this;
  68.     }
  69.     public function getTelephone(): ?string
  70.     {
  71.         return $this->telephone;
  72.     }
  73.     public function setTelephone(?string $telephone): static
  74.     {
  75.         $this->telephone $telephone;
  76.         return $this;
  77.     }
  78.     public function getEmail(): ?string
  79.     {
  80.         return $this->email;
  81.     }
  82.     public function setEmail(?string $email): static
  83.     {
  84.         $this->email $email;
  85.         return $this;
  86.     }
  87.     public function getAdresse(): ?string
  88.     {
  89.         return $this->adresse;
  90.     }
  91.     public function setAdresse(?string $adresse): static
  92.     {
  93.         $this->adresse $adresse;
  94.         return $this;
  95.     }
  96.     public function getVille(): ?string
  97.     {
  98.         return $this->ville;
  99.     }
  100.     public function setVille(?string $ville): static
  101.     {
  102.         $this->ville $ville;
  103.         return $this;
  104.     }
  105.     public function getCodePostal(): ?string
  106.     {
  107.         return $this->codePostal;
  108.     }
  109.     public function setCodePostal(?string $codePostal): static
  110.     {
  111.         $this->codePostal $codePostal;
  112.         return $this;
  113.     }
  114.     public function getPays(): ?string
  115.     {
  116.         return $this->pays;
  117.     }
  118.     public function setPays(?string $pays): static
  119.     {
  120.         $this->pays $pays;
  121.         return $this;
  122.     }
  123.     public function getNumeroIdentification(): ?string
  124.     {
  125.         return $this->numeroIdentification;
  126.     }
  127.     public function setNumeroIdentification(?string $numeroIdentification): static
  128.     {
  129.         $this->numeroIdentification $numeroIdentification;
  130.         return $this;
  131.     }
  132.     public function getNotes(): ?string
  133.     {
  134.         return $this->notes;
  135.     }
  136.     public function setNotes(?string $notes): static
  137.     {
  138.         $this->notes $notes;
  139.         return $this;
  140.     }
  141.     public function isEstActif(): ?bool
  142.     {
  143.         return $this->estActif;
  144.     }
  145.     public function setEstActif(bool $estActif): static
  146.     {
  147.         $this->estActif $estActif;
  148.         return $this;
  149.     }
  150.     public function getCreatedAt(): ?\DateTimeInterface
  151.     {
  152.         return $this->createdAt;
  153.     }
  154.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  155.     {
  156.         $this->createdAt $createdAt;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, AchatFournisseur>
  161.      */
  162.     public function getAchats(): Collection
  163.     {
  164.         return $this->achats;
  165.     }
  166.     public function addAchat(AchatFournisseur $achat): static
  167.     {
  168.         if (!$this->achats->contains($achat)) {
  169.             $this->achats->add($achat);
  170.             $achat->setFournisseur($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeAchat(AchatFournisseur $achat): static
  175.     {
  176.         if ($this->achats->removeElement($achat)) {
  177.             if ($achat->getFournisseur() === $this) {
  178.                 $achat->setFournisseur(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection<int, DetteFournisseur>
  185.      */
  186.     public function getDettes(): Collection
  187.     {
  188.         return $this->dettes;
  189.     }
  190.     public function addDette(DetteFournisseur $dette): static
  191.     {
  192.         if (!$this->dettes->contains($dette)) {
  193.             $this->dettes->add($dette);
  194.             $dette->setFournisseur($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeDette(DetteFournisseur $dette): static
  199.     {
  200.         if ($this->dettes->removeElement($dette)) {
  201.             if ($dette->getFournisseur() === $this) {
  202.                 $dette->setFournisseur(null);
  203.             }
  204.         }
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return Collection<int, PaiementFournisseur>
  209.      */
  210.     public function getPaiements(): Collection
  211.     {
  212.         return $this->paiements;
  213.     }
  214.     public function addPaiement(PaiementFournisseur $paiement): static
  215.     {
  216.         if (!$this->paiements->contains($paiement)) {
  217.             $this->paiements->add($paiement);
  218.             $paiement->setFournisseur($this);
  219.         }
  220.         return $this;
  221.     }
  222.     public function removePaiement(PaiementFournisseur $paiement): static
  223.     {
  224.         if ($this->paiements->removeElement($paiement)) {
  225.             if ($paiement->getFournisseur() === $this) {
  226.                 $paiement->setFournisseur(null);
  227.             }
  228.         }
  229.         return $this;
  230.     }
  231.     /**
  232.      * @return Collection<int, EntreeStock>
  233.      */
  234.     public function getEntreesStock(): Collection
  235.     {
  236.         return $this->entreesStock;
  237.     }
  238.     public function addEntreeStock(EntreeStock $entreeStock): static
  239.     {
  240.         if (!$this->entreesStock->contains($entreeStock)) {
  241.             $this->entreesStock->add($entreeStock);
  242.             $entreeStock->setFournisseur($this);
  243.         }
  244.         return $this;
  245.     }
  246.     public function removeEntreeStock(EntreeStock $entreeStock): static
  247.     {
  248.         if ($this->entreesStock->removeElement($entreeStock)) {
  249.             if ($entreeStock->getFournisseur() === $this) {
  250.                 $entreeStock->setFournisseur(null);
  251.             }
  252.         }
  253.         return $this;
  254.     }
  255.     /**
  256.      * Calcule le total des achats chez ce fournisseur
  257.      */
  258.     public function getTotalAchats(): float
  259.     {
  260.         $total 0;
  261.         foreach ($this->achats as $achat) {
  262.             $total += $achat->getMontantTotal();
  263.         }
  264.         return $total;
  265.     }
  266.     /**
  267.      * Calcule le total des dettes envers ce fournisseur
  268.      */
  269.     public function getTotalDettes(): float
  270.     {
  271.         $total 0;
  272.         foreach ($this->dettes as $dette) {
  273.             if (!$dette->isEstPayee()) {
  274.                 $total += $dette->getMontantRestant();
  275.             }
  276.         }
  277.         return $total;
  278.     }
  279.     /**
  280.      * Calcule le total payé à ce fournisseur
  281.      */
  282.     public function getTotalPaye(): float
  283.     {
  284.         $total 0;
  285.         foreach ($this->paiements as $paiement) {
  286.             $total += $paiement->getMontant();
  287.         }
  288.         return $total;
  289.     }
  290.     /**
  291.      * @return Collection<int, CommandeFournisseur>
  292.      */
  293.     public function getCommandes(): Collection
  294.     {
  295.         return $this->commandes;
  296.     }
  297.     public function addCommande(CommandeFournisseur $commande): static
  298.     {
  299.         if (!$this->commandes->contains($commande)) {
  300.             $this->commandes->add($commande);
  301.             $commande->setFournisseur($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeCommande(CommandeFournisseur $commande): static
  306.     {
  307.         if ($this->commandes->removeElement($commande)) {
  308.             if ($commande->getFournisseur() === $this) {
  309.                 $commande->setFournisseur(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     public function __toString(): string
  315.     {
  316.         return $this->nom ?? '';
  317.     }
  318. }