src/Entity/Forecast.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ForecastRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ForecastRepository::class)
  9.  */
  10. class Forecast
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="date")
  20.      */
  21.     private $createdAt;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $reference;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="forecasts")
  28.      */
  29.     private $user;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=ForecastDetails::class, mappedBy="forecast")
  32.      */
  33.     private $forecastDetails;
  34.     /**
  35.      * @ORM\Column(type="date")
  36.      */
  37.     private $date_envoie;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=EtatPaiement::class, inversedBy="forecasts")
  40.      */
  41.     private $etatpaiement;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $stripeSessionId;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=Typepaiement::class, inversedBy="forecasts")
  48.      */
  49.     private $typepaiement;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity=HistoriquePaiement::class, mappedBy="forecast")
  52.      */
  53.     private $historiquePaiements;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="instances_forecasts")
  56.      */
  57.     private $grossiste;
  58.     /**
  59.      * @ORM\Column(type="float", nullable=true)
  60.      */
  61.     private $montant_paye;
  62.     public function __construct()
  63.     {
  64.         $this->forecastDetails = new ArrayCollection();
  65.         $this->createdAt = new \DateTime();
  66.         $this->historiquePaiements = new ArrayCollection();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getCreatedAt(): ?\DateTimeInterface
  73.     {
  74.         return $this->createdAt;
  75.     }
  76.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  77.     {
  78.         $this->createdAt $createdAt;
  79.         return $this;
  80.     }
  81.     public function getReference(): ?string
  82.     {
  83.         return $this->reference;
  84.     }
  85.     public function setReference(string $reference): self
  86.     {
  87.         $this->reference $reference;
  88.         return $this;
  89.     }
  90.     public function getUser(): ?User
  91.     {
  92.         return $this->user;
  93.     }
  94.     public function setUser(?User $user): self
  95.     {
  96.         $this->user $user;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return Collection<int, ForecastDetails>
  101.      */
  102.     public function getForecastDetails(): Collection
  103.     {
  104.         return $this->forecastDetails;
  105.     }
  106.     public function addForecastDetail(ForecastDetails $forecastDetail): self
  107.     {
  108.         if (!$this->forecastDetails->contains($forecastDetail)) {
  109.             $this->forecastDetails[] = $forecastDetail;
  110.             $forecastDetail->setForecast($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeForecastDetail(ForecastDetails $forecastDetail): self
  115.     {
  116.         if ($this->forecastDetails->removeElement($forecastDetail)) {
  117.             // set the owning side to null (unless already changed)
  118.             if ($forecastDetail->getForecast() === $this) {
  119.                 $forecastDetail->setForecast(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function getDateEnvoie(): ?\DateTimeInterface
  125.     {
  126.         return $this->date_envoie;
  127.     }
  128.     public function setDateEnvoie(\DateTimeInterface $date_envoie): self
  129.     {
  130.         $this->date_envoie $date_envoie;
  131.         return $this;
  132.     }
  133.     public function getEtatpaiement(): ?EtatPaiement
  134.     {
  135.         return $this->etatpaiement;
  136.     }
  137.     public function setEtatpaiement(?EtatPaiement $etatpaiement): self
  138.     {
  139.         $this->etatpaiement $etatpaiement;
  140.         return $this;
  141.     }
  142.     public function getStripeSessionId(): ?string
  143.     {
  144.         return $this->stripeSessionId;
  145.     }
  146.     public function setStripeSessionId(?string $stripeSessionId): self
  147.     {
  148.         $this->stripeSessionId $stripeSessionId;
  149.         return $this;
  150.     }
  151.     
  152.     public function getTotal()
  153.     {
  154.         $total 0;
  155.         foreach($this->getForecastDetails()->getValues() as $product){
  156.             $total += $product->getTotal(); 
  157.         }
  158.         return $total;
  159.     }
  160.     public function getTypepaiement(): ?Typepaiement
  161.     {
  162.         return $this->typepaiement;
  163.     }
  164.     public function setTypepaiement(?Typepaiement $typepaiement): self
  165.     {
  166.         $this->typepaiement $typepaiement;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, HistoriquePaiement>
  171.      */
  172.     public function getHistoriquePaiements(): Collection
  173.     {
  174.         return $this->historiquePaiements;
  175.     }
  176.     public function addHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
  177.     {
  178.         if (!$this->historiquePaiements->contains($historiquePaiement)) {
  179.             $this->historiquePaiements[] = $historiquePaiement;
  180.             $historiquePaiement->setForecast($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
  185.     {
  186.         if ($this->historiquePaiements->removeElement($historiquePaiement)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($historiquePaiement->getForecast() === $this) {
  189.                 $historiquePaiement->setForecast(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     public function getGrossiste(): ?User
  195.     {
  196.         return $this->grossiste;
  197.     }
  198.     public function setGrossiste(?User $grossiste): self
  199.     {
  200.         $this->grossiste $grossiste;
  201.         return $this;
  202.     }
  203.     public function getMontantPaye(): ?float
  204.     {
  205.         return $this->montant_paye;
  206.     }
  207.     public function setMontantPaye(?float $montant_paye): self
  208.     {
  209.         $this->montant_paye $montant_paye;
  210.         return $this;
  211.     }
  212. }