<?php
namespace App\Entity;
use App\Repository\VenteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: VenteRepository::class)]
class Vente
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $dateVente = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $vendeur = null;
#[ORM\OneToMany(mappedBy: 'vente', targetEntity: DetailsVente::class)]
private Collection $detailsVentes;
#[ORM\OneToMany(mappedBy: 'vente', targetEntity: Echeance::class)]
private Collection $echeances;
#[ORM\ManyToOne(inversedBy: 'ventes')]
private ?Client $client = null;
#[ORM\Column(length: 500, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $type = null;
#[ORM\OneToMany(mappedBy: 'vente', targetEntity: Facture::class)]
private Collection $factures;
#[ORM\ManyToOne(inversedBy: 'ventes')]
private ?Boutique $boutique = null;
#[ORM\OneToMany(mappedBy: 'vente', targetEntity: Recette::class)]
private Collection $recettes;
public function __construct()
{
$this->dateVente = new \DateTime();
$this->detailsVentes = new ArrayCollection();
$this->echeances = new ArrayCollection();
$this->factures = new ArrayCollection();
$this->recettes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDateVente(): ?\DateTimeInterface
{
return $this->dateVente;
}
public function setDateVente(\DateTimeInterface $dateVente): static
{
$this->dateVente = $dateVente;
return $this;
}
public function getVendeur(): ?User
{
return $this->vendeur;
}
public function setVendeur(?User $vendeur): static
{
$this->vendeur = $vendeur;
return $this;
}
/**
* @return Collection<int, DetailsVente>
*/
public function getDetailsVentes(): Collection
{
return $this->detailsVentes;
}
public function addDetailsVente(DetailsVente $detailsVente): static
{
if (!$this->detailsVentes->contains($detailsVente)) {
$this->detailsVentes->add($detailsVente);
$detailsVente->setVente($this);
}
return $this;
}
public function removeDetailsVente(DetailsVente $detailsVente): static
{
if ($this->detailsVentes->removeElement($detailsVente)) {
// set the owning side to null (unless already changed)
if ($detailsVente->getVente() === $this) {
$detailsVente->setVente(null);
}
}
return $this;
}
/**
* @return Collection<int, Echeance>
*/
public function getEcheances(): Collection
{
return $this->echeances;
}
public function addEcheance(Echeance $echeance): static
{
if (!$this->echeances->contains($echeance)) {
$this->echeances->add($echeance);
$echeance->setVente($this);
}
return $this;
}
public function removeEcheance(Echeance $echeance): static
{
if ($this->echeances->removeElement($echeance)) {
// set the owning side to null (unless already changed)
if ($echeance->getVente() === $this) {
$echeance->setVente(null);
}
}
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): static
{
$this->client = $client;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, Facture>
*/
public function getFactures(): Collection
{
return $this->factures;
}
public function addFacture(Facture $facture): static
{
if (!$this->factures->contains($facture)) {
$this->factures->add($facture);
$facture->setVente($this);
}
return $this;
}
public function removeFacture(Facture $facture): static
{
if ($this->factures->removeElement($facture)) {
// set the owning side to null (unless already changed)
if ($facture->getVente() === $this) {
$facture->setVente(null);
}
}
return $this;
}
public function getBoutique(): ?Boutique
{
return $this->boutique;
}
public function setBoutique(?Boutique $boutique): static
{
$this->boutique = $boutique;
return $this;
}
/**
* @return Collection<int, Recette>
*/
public function getRecettes(): Collection
{
return $this->recettes;
}
public function addRecette(Recette $recette): static
{
if (!$this->recettes->contains($recette)) {
$this->recettes->add($recette);
$recette->setVente($this);
}
return $this;
}
public function removeRecette(Recette $recette): static
{
if ($this->recettes->removeElement($recette)) {
// set the owning side to null (unless already changed)
if ($recette->getVente() === $this) {
$recette->setVente(null);
}
}
return $this;
}
}