<?php
namespace App\Entity;
use App\Repository\FacturePharmacieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FacturePharmacieRepository::class)
*/
class FacturePharmacie
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $reference;
/**
* @ORM\Column(type="datetime")
*/
private $createdat;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isDownloadedFinance;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isDownloadedPharmacie;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isDownloadedLogistic;
/**
* @ORM\OneToMany(targetEntity=DetailFacturePharmacie::class, mappedBy="facture", orphanRemoval=true)
*/
private $detailFacturePharmacies;
/**
* @ORM\ManyToOne(targetEntity=IctusEtatPaiement::class, inversedBy="facturePharmacies")
* @ORM\JoinColumn(nullable=false)
*/
private $etatPaiement;
/**
* @ORM\ManyToOne(targetEntity=Typepaiement::class, inversedBy="facturePharmacies")
*/
private $typePaiement;
/**
* @ORM\OneToOne(targetEntity=IctoMouvement::class, mappedBy="facture", cascade={"persist", "remove"})
*/
private $ictoMouvement;
/**
* @ORM\OneToMany(targetEntity=FactPcieHistoriquePaiement::class, mappedBy="facture", orphanRemoval=true)
*/
private $factPcieHistoriquePaiements;
/**
* @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="facturePharmacies")
* @ORM\JoinColumn(nullable=false)
*/
private $pharmacie;
/**
* @ORM\OneToMany(targetEntity=IctoMouvement::class, mappedBy="facture")
*/
private $ictoMouvements;
/**
* @ORM\ManyToOne(targetEntity=TypeFacture::class, inversedBy="facturePharmacies")
* @ORM\JoinColumn(nullable=false)
*/
private $typeFacture;
public function __construct()
{
$this->detailFacturePharmacies = new ArrayCollection();
$this->factPcieHistoriquePaiements = new ArrayCollection();
$this->ictoMouvements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getReference(): ?int
{
return $this->reference;
}
public function setReference(int $reference): self
{
$this->reference = $reference;
return $this;
}
public function getCreatedat(): ?\DateTimeInterface
{
return $this->createdat;
}
public function setCreatedat(\DateTimeInterface $createdat): self
{
$this->createdat = $createdat;
return $this;
}
public function isIsDownloadedFinance(): ?bool
{
return $this->isDownloadedFinance;
}
public function setIsDownloadedFinance(?bool $isDownloadedFinance): self
{
$this->isDownloadedFinance = $isDownloadedFinance;
return $this;
}
public function isIsDownloadedPharmacie(): ?bool
{
return $this->isDownloadedPharmacie;
}
public function setIsDownloadedPharmacie(?bool $isDownloadedPharmacie): self
{
$this->isDownloadedPharmacie = $isDownloadedPharmacie;
return $this;
}
public function isIsDownloadedLogistic(): ?bool
{
return $this->isDownloadedLogistic;
}
public function setIsDownloadedLogistic(?bool $isDownloadedLogistic): self
{
$this->isDownloadedLogistic = $isDownloadedLogistic;
return $this;
}
/**
* @return Collection<int, DetailFacturePharmacie>
*/
public function getDetailFacturePharmacies(): Collection
{
return $this->detailFacturePharmacies;
}
public function addDetailFacturePharmacy(DetailFacturePharmacie $detailFacturePharmacy): self
{
if (!$this->detailFacturePharmacies->contains($detailFacturePharmacy)) {
$this->detailFacturePharmacies[] = $detailFacturePharmacy;
$detailFacturePharmacy->setFacture($this);
}
return $this;
}
public function removeDetailFacturePharmacy(DetailFacturePharmacie $detailFacturePharmacy): self
{
if ($this->detailFacturePharmacies->removeElement($detailFacturePharmacy)) {
// set the owning side to null (unless already changed)
if ($detailFacturePharmacy->getFacture() === $this) {
$detailFacturePharmacy->setFacture(null);
}
}
return $this;
}
public function getEtatPaiement(): ?IctusEtatPaiement
{
return $this->etatPaiement;
}
public function setEtatPaiement(?IctusEtatPaiement $etatPaiement): self
{
$this->etatPaiement = $etatPaiement;
return $this;
}
public function getTypePaiement(): ?Typepaiement
{
return $this->typePaiement;
}
public function setTypePaiement(?Typepaiement $typePaiement): self
{
$this->typePaiement = $typePaiement;
return $this;
}
public function getIctoMouvement(): ?IctoMouvement
{
return $this->ictoMouvement;
}
public function setIctoMouvement(?IctoMouvement $ictoMouvement): self
{
// unset the owning side of the relation if necessary
if ($ictoMouvement === null && $this->ictoMouvement !== null) {
$this->ictoMouvement->setFacture(null);
}
// set the owning side of the relation if necessary
if ($ictoMouvement !== null && $ictoMouvement->getFacture() !== $this) {
$ictoMouvement->setFacture($this);
}
$this->ictoMouvement = $ictoMouvement;
return $this;
}
/**
* @return Collection<int, FactPcieHistoriquePaiement>
*/
public function getFactPcieHistoriquePaiements(): Collection
{
return $this->factPcieHistoriquePaiements;
}
public function addFactPcieHistoriquePaiement(FactPcieHistoriquePaiement $factPcieHistoriquePaiement): self
{
if (!$this->factPcieHistoriquePaiements->contains($factPcieHistoriquePaiement)) {
$this->factPcieHistoriquePaiements[] = $factPcieHistoriquePaiement;
$factPcieHistoriquePaiement->setFacture($this);
}
return $this;
}
public function removeFactPcieHistoriquePaiement(FactPcieHistoriquePaiement $factPcieHistoriquePaiement): self
{
if ($this->factPcieHistoriquePaiements->removeElement($factPcieHistoriquePaiement)) {
// set the owning side to null (unless already changed)
if ($factPcieHistoriquePaiement->getFacture() === $this) {
$factPcieHistoriquePaiement->setFacture(null);
}
}
return $this;
}
public function getPharmacie(): ?IctusPharmacie
{
return $this->pharmacie;
}
public function setPharmacie(?IctusPharmacie $pharmacie): self
{
$this->pharmacie = $pharmacie;
return $this;
}
public function getMontantTotal()
{
$details = $this->getDetailFacturePharmacies();
$montant = 0;
foreach ($details as $detail) {
$montant += $detail->getQuantite() * $detail->getPuttc();
}
return $montant;
}
/**
* @return Collection<int, IctoMouvement>
*/
public function getIctoMouvements(): Collection
{
return $this->ictoMouvements;
}
public function addIctoMouvement(IctoMouvement $ictoMouvement): self
{
if (!$this->ictoMouvements->contains($ictoMouvement)) {
$this->ictoMouvements[] = $ictoMouvement;
$ictoMouvement->setFacture($this);
}
return $this;
}
public function removeIctoMouvement(IctoMouvement $ictoMouvement): self
{
if ($this->ictoMouvements->removeElement($ictoMouvement)) {
// set the owning side to null (unless already changed)
if ($ictoMouvement->getFacture() === $this) {
$ictoMouvement->setFacture(null);
}
}
return $this;
}
public function getTypeFacture(): ?TypeFacture
{
return $this->typeFacture;
}
public function setTypeFacture(?TypeFacture $typeFacture): self
{
$this->typeFacture = $typeFacture;
return $this;
}
}