<?php
namespace App\Entity;
use App\Repository\ForecastRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ForecastRepository::class)
*/
class Forecast
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="date")
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255)
*/
private $reference;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="forecasts")
*/
private $user;
/**
* @ORM\OneToMany(targetEntity=ForecastDetails::class, mappedBy="forecast")
*/
private $forecastDetails;
/**
* @ORM\Column(type="date")
*/
private $date_envoie;
/**
* @ORM\ManyToOne(targetEntity=EtatPaiement::class, inversedBy="forecasts")
*/
private $etatpaiement;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeSessionId;
/**
* @ORM\ManyToOne(targetEntity=Typepaiement::class, inversedBy="forecasts")
*/
private $typepaiement;
/**
* @ORM\OneToMany(targetEntity=HistoriquePaiement::class, mappedBy="forecast")
*/
private $historiquePaiements;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="instances_forecasts")
*/
private $grossiste;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $montant_paye;
public function __construct()
{
$this->forecastDetails = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->historiquePaiements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, ForecastDetails>
*/
public function getForecastDetails(): Collection
{
return $this->forecastDetails;
}
public function addForecastDetail(ForecastDetails $forecastDetail): self
{
if (!$this->forecastDetails->contains($forecastDetail)) {
$this->forecastDetails[] = $forecastDetail;
$forecastDetail->setForecast($this);
}
return $this;
}
public function removeForecastDetail(ForecastDetails $forecastDetail): self
{
if ($this->forecastDetails->removeElement($forecastDetail)) {
// set the owning side to null (unless already changed)
if ($forecastDetail->getForecast() === $this) {
$forecastDetail->setForecast(null);
}
}
return $this;
}
public function getDateEnvoie(): ?\DateTimeInterface
{
return $this->date_envoie;
}
public function setDateEnvoie(\DateTimeInterface $date_envoie): self
{
$this->date_envoie = $date_envoie;
return $this;
}
public function getEtatpaiement(): ?EtatPaiement
{
return $this->etatpaiement;
}
public function setEtatpaiement(?EtatPaiement $etatpaiement): self
{
$this->etatpaiement = $etatpaiement;
return $this;
}
public function getStripeSessionId(): ?string
{
return $this->stripeSessionId;
}
public function setStripeSessionId(?string $stripeSessionId): self
{
$this->stripeSessionId = $stripeSessionId;
return $this;
}
public function getTotal()
{
$total = 0;
foreach($this->getForecastDetails()->getValues() as $product){
$total += $product->getTotal();
}
return $total;
}
public function getTypepaiement(): ?Typepaiement
{
return $this->typepaiement;
}
public function setTypepaiement(?Typepaiement $typepaiement): self
{
$this->typepaiement = $typepaiement;
return $this;
}
/**
* @return Collection<int, HistoriquePaiement>
*/
public function getHistoriquePaiements(): Collection
{
return $this->historiquePaiements;
}
public function addHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
{
if (!$this->historiquePaiements->contains($historiquePaiement)) {
$this->historiquePaiements[] = $historiquePaiement;
$historiquePaiement->setForecast($this);
}
return $this;
}
public function removeHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
{
if ($this->historiquePaiements->removeElement($historiquePaiement)) {
// set the owning side to null (unless already changed)
if ($historiquePaiement->getForecast() === $this) {
$historiquePaiement->setForecast(null);
}
}
return $this;
}
public function getGrossiste(): ?User
{
return $this->grossiste;
}
public function setGrossiste(?User $grossiste): self
{
$this->grossiste = $grossiste;
return $this;
}
public function getMontantPaye(): ?float
{
return $this->montant_paye;
}
public function setMontantPaye(?float $montant_paye): self
{
$this->montant_paye = $montant_paye;
return $this;
}
}