<?php
namespace App\Entity;
use App\Repository\FacturePatientRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FacturePatientRepository::class)
*/
class FacturePatient
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime")
*/
private $date;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isPayer;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isLivrer;
/**
* @ORM\ManyToOne(targetEntity=TypeFacture::class, inversedBy="facturePatients")
* @ORM\JoinColumn(nullable=false)
*/
private $typefacture;
/**
* @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="facturePatients")
* @ORM\JoinColumn(nullable=false)
*/
private $pharmacie;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="facturePatients")
* @ORM\JoinColumn(nullable=false)
*/
private $User;
/**
* @ORM\OneToOne(targetEntity=CommandeSpecial::class, inversedBy="facturePatient", cascade={"persist", "remove"})
*/
private $commandespecial;
/**
* @ORM\OneToMany(targetEntity=DetailFacturePatient::class, mappedBy="facturePatient", orphanRemoval=true)
*/
private $detailFacturePatients;
/**
* @ORM\Column(type="integer")
*/
private $reference;
/**
* @ORM\ManyToOne(targetEntity=IctusCommande::class, inversedBy="facturePatients")
*/
private $commande;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isCanceled;
/**
* @ORM\OneToMany(targetEntity=IctusReclamation::class, mappedBy="facture")
*/
private $ictusReclamations;
public function __construct()
{
$this->detailFacturePatients = new ArrayCollection();
$this->ictusReclamations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function isIsPayer(): ?bool
{
return $this->isPayer;
}
public function setIsPayer(?bool $isPayer): self
{
$this->isPayer = $isPayer;
return $this;
}
public function isIsLivrer(): ?bool
{
return $this->isLivrer;
}
public function setIsLivrer(?bool $isLivrer): self
{
$this->isLivrer = $isLivrer;
return $this;
}
public function getTypefacture(): ?TypeFacture
{
return $this->typefacture;
}
public function setTypefacture(?TypeFacture $typefacture): self
{
$this->typefacture = $typefacture;
return $this;
}
public function getPharmacie(): ?IctusPharmacie
{
return $this->pharmacie;
}
public function setPharmacie(?IctusPharmacie $pharmacie): self
{
$this->pharmacie = $pharmacie;
return $this;
}
public function getUser(): ?User
{
return $this->User;
}
public function setUser(?User $User): self
{
$this->User = $User;
return $this;
}
public function getCommandespecial(): ?CommandeSpecial
{
return $this->commandespecial;
}
public function setCommandespecial(?CommandeSpecial $commandespecial): self
{
$this->commandespecial = $commandespecial;
return $this;
}
/**
* @return Collection<int, DetailFacturePatient>
*/
public function getDetailFacturePatients(): Collection
{
return $this->detailFacturePatients;
}
public function addDetailFacturePatient(DetailFacturePatient $detailFacturePatient): self
{
if (!$this->detailFacturePatients->contains($detailFacturePatient)) {
$this->detailFacturePatients[] = $detailFacturePatient;
$detailFacturePatient->setFacturePatient($this);
}
return $this;
}
public function removeDetailFacturePatient(DetailFacturePatient $detailFacturePatient): self
{
if ($this->detailFacturePatients->removeElement($detailFacturePatient)) {
// set the owning side to null (unless already changed)
if ($detailFacturePatient->getFacturePatient() === $this) {
$detailFacturePatient->setFacturePatient(null);
}
}
return $this;
}
public function getMontantTotal()
{
$total = 0;
foreach ($this->detailFacturePatients as $detail) {
$total += $detail->getPrixUnitaireTTC() * $detail->getQuantite();
}
return $total * $this->typefacture->getValue();
}
public function getReference(): ?int
{
return $this->reference;
}
public function setReference(int $reference): self
{
$this->reference = $reference;
return $this;
}
public function getCommande(): ?IctusCommande
{
return $this->commande;
}
public function setCommande(?IctusCommande $commande): self
{
$this->commande = $commande;
return $this;
}
public function isIsCanceled(): ?bool
{
return $this->isCanceled;
}
public function setIsCanceled(?bool $isCanceled): self
{
$this->isCanceled = $isCanceled;
return $this;
}
/**
* @return Collection<int, IctusReclamation>
*/
public function getIctusReclamations(): Collection
{
return $this->ictusReclamations;
}
public function addIctusReclamation(IctusReclamation $ictusReclamation): self
{
if (!$this->ictusReclamations->contains($ictusReclamation)) {
$this->ictusReclamations[] = $ictusReclamation;
$ictusReclamation->setFacture($this);
}
return $this;
}
public function removeIctusReclamation(IctusReclamation $ictusReclamation): self
{
if ($this->ictusReclamations->removeElement($ictusReclamation)) {
// set the owning side to null (unless already changed)
if ($ictusReclamation->getFacture() === $this) {
$ictusReclamation->setFacture(null);
}
}
return $this;
}
}