<?php

namespace App\Entity;

use App\Repository\FactureRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;

/**
 * @ORM\Entity(repositoryClass=FactureRepository::class)
 * @ORM\Table(schema="sav")
 */
class Facture
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=11, nullable=true)
     */
    private $num_facture;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $num_facture_oracle;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $num_facture_reference;

    /**
     * @ORM\ManyToOne(targetEntity=Equipement::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idequipement")
     */
    private $equipement;

    /**
     * @ORM\ManyToOne(targetEntity=Agence::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idagence")
     */
    private $agence;

    /**
     * @ORM\ManyToOne(targetEntity=Adresse::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idadresse")
     */
    private $adresse;

    /**
     * @ORM\ManyToOne(targetEntity=FactureType::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idfacture_type")
     */
    private $facture_type;

    /**
     * @ORM\ManyToOne(targetEntity=FactureCategorie::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idfacture_categorie")
     */
    private $facture_categorie;

    /**
     * @ORM\Column(type="float", nullable=true)
     */
    private $montant_ht;

    /**
     * @ORM\Column(type="float", nullable=true)
     */
    private $montant_ttc;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $date_facture;

    /**
     * @ORM\ManyToOne(targetEntity=Facture::class, inversedBy="factures_acomptes")
     * @ORM\JoinColumn(name="idfacture_acompte")
     */
    private $facture_acompte;

    /**
     * @ORM\OneToMany(targetEntity=Facture::class, mappedBy="facture_acompte")
     * @Ignore()
     */
    private $factures_acomptes;

    /**
     * @ORM\ManyToOne(targetEntity=Devis::class, inversedBy="factures")
     * @ORM\JoinColumn(name="iddevis")
     */
    private $devis;

    /**
     * @ORM\ManyToOne(targetEntity=Site::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idsite")
     */
    private $site;

    /**
     * @ORM\ManyToOne(targetEntity=Intervention::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idintervention")
     */
    private $intervention;

    /**
     * @ORM\ManyToOne(targetEntity=TypeDevise::class, inversedBy="factures")
     * @ORM\JoinColumn(name="idtype_devise")
     */
    private $type_devise;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $prise_contrat;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $num_devis_papier;

    /**
     * @ORM\OneToMany(targetEntity=Contrat::class, mappedBy="facture")
     * @Ignore()
     */
    private $contrats;

    /**
     * @ORM\OneToMany(targetEntity=Intervention::class, mappedBy="facture")
     * @Ignore()
     */
    private $interventions;

    /**
     * @ORM\OneToMany(targetEntity=FactureLigne::class, mappedBy="facture")
     */
    private $factureLignes;

    /**
     * @ORM\OneToMany(targetEntity=FactureTva::class, mappedBy="facture")
     */
    private $factureTvas;

    /**
     * @ORM\OneToMany(targetEntity=Paiement::class, mappedBy="facture", orphanRemoval=true)
     * @Ignore()
     */
    private $paiements;

    public function __construct()
    {
        $this->factures_acomptes = new ArrayCollection();
        $this->contrats = new ArrayCollection();
        $this->interventions = new ArrayCollection();
        $this->factureLignes = new ArrayCollection();
        $this->factureTvas = new ArrayCollection();
        $this->paiements = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNumFacture(): ?string
    {
        return $this->num_facture;
    }

    public function setNumFacture(?string $num_facture): self
    {
        $this->num_facture = $num_facture;

        return $this;
    }

    public function getNumFactureOracle(): ?int
    {
        return $this->num_facture_oracle;
    }

    public function setNumFactureOracle(?int $num_facture_oracle): self
    {
        $this->num_facture_oracle = $num_facture_oracle;

        return $this;
    }

    public function getNumFactureReference(): ?int
    {
        return $this->num_facture_reference;
    }

    public function setNumFactureReference(?int $num_facture_reference): self
    {
        $this->num_facture_reference = $num_facture_reference;

        return $this;
    }

    public function getEquipement(): ?Equipement
    {
        return $this->equipement;
    }

    public function setEquipement(?Equipement $equipement): self
    {
        $this->equipement = $equipement;

        return $this;
    }

    public function getAgence(): ?Agence
    {
        return $this->agence;
    }

    public function setAgence(?Agence $agence): self
    {
        $this->agence = $agence;

        return $this;
    }

    public function getAdresse(): ?Adresse
    {
        return $this->adresse;
    }

    public function setAdresse(?Adresse $adresse): self
    {
        $this->adresse = $adresse;

        return $this;
    }

    public function getFactureType(): ?FactureType
    {
        return $this->facture_type;
    }

    public function setFactureType(?FactureType $facture_type): self
    {
        $this->facture_type = $facture_type;

        return $this;
    }

    public function getFactureCategorie(): ?FactureCategorie
    {
        return $this->facture_categorie;
    }

    public function setFactureCategorie(?FactureCategorie $facture_categorie): self
    {
        $this->facture_categorie = $facture_categorie;

        return $this;
    }

    public function getMontantHt(): ?float
    {
        return $this->montant_ht;
    }

    public function setMontantHt(?float $montant_ht): self
    {
        $this->montant_ht = $montant_ht;

        return $this;
    }

    public function getMontantTtc(): ?float
    {
        return $this->montant_ttc;
    }

    public function setMontantTtc(?float $montant_ttc): self
    {
        $this->montant_ttc = $montant_ttc;

        return $this;
    }

    public function getDateFacture(): ?\DateTimeInterface
    {
        return $this->date_facture;
    }

    public function setDateFacture(?\DateTimeInterface $date_facture): self
    {
        $this->date_facture = $date_facture;

        return $this;
    }

    public function getFactureAcompte(): ?self
    {
        return $this->facture_acompte;
    }

    public function setFactureAcompte(?self $facture_acompte): self
    {
        $this->facture_acompte = $facture_acompte;

        return $this;
    }

    /**
     * @return Collection<int, self>
     */
    public function getFacturesAcomptes(): Collection
    {
        return $this->factures_acomptes;
    }

    public function addFacturesAcompte(self $facturesAcompte): self
    {
        if (!$this->factures_acomptes->contains($facturesAcompte)) {
            $this->factures_acomptes[] = $facturesAcompte;
            $facturesAcompte->setFactureAcompte($this);
        }

        return $this;
    }

    public function removeFacturesAcompte(self $facturesAcompte): self
    {
        if ($this->factures_acomptes->removeElement($facturesAcompte)) {
            // set the owning side to null (unless already changed)
            if ($facturesAcompte->getFactureAcompte() === $this) {
                $facturesAcompte->setFactureAcompte(null);
            }
        }

        return $this;
    }

    public function getDevis(): ?Devis
    {
        return $this->devis;
    }

    public function setDevis(?Devis $devis): self
    {
        $this->devis = $devis;

        return $this;
    }

    public function getSite(): ?Site
    {
        return $this->site;
    }

    public function setSite(?Site $site): self
    {
        $this->site = $site;

        return $this;
    }

    public function getIntervention(): ?Intervention
    {
        return $this->intervention;
    }

    public function setIntervention(?Intervention $intervention): self
    {
        $this->intervention = $intervention;

        return $this;
    }

    public function getTypeDevise(): ?TypeDevise
    {
        return $this->type_devise;
    }

    public function setTypeDevise(?TypeDevise $type_devise): self
    {
        $this->type_devise = $type_devise;

        return $this;
    }

    public function getPriseContrat(): ?bool
    {
        return $this->prise_contrat;
    }

    public function setPriseContrat(?bool $prise_contrat): self
    {
        $this->prise_contrat = $prise_contrat;

        return $this;
    }

    public function getNumDevisPapier(): ?int
    {
        return $this->num_devis_papier;
    }

    public function setNumDevisPapier(?int $num_devis_papier): self
    {
        $this->num_devis_papier = $num_devis_papier;

        return $this;
    }

    /**
     * @return Collection<int, Contrat>
     */
    public function getContrats(): Collection
    {
        return $this->contrats;
    }

    public function addContrat(Contrat $contrat): self
    {
        if (!$this->contrats->contains($contrat)) {
            $this->contrats[] = $contrat;
            $contrat->setFacture($this);
        }

        return $this;
    }

    public function removeContrat(Contrat $contrat): self
    {
        if ($this->contrats->removeElement($contrat)) {
            // set the owning side to null (unless already changed)
            if ($contrat->getFacture() === $this) {
                $contrat->setFacture(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Intervention>
     */
    public function getInterventions(): Collection
    {
        return $this->interventions;
    }

    public function addIntervention(Intervention $intervention): self
    {
        if (!$this->interventions->contains($intervention)) {
            $this->interventions[] = $intervention;
            $intervention->setFacture($this);
        }

        return $this;
    }

    public function removeIntervention(Intervention $intervention): self
    {
        if ($this->interventions->removeElement($intervention)) {
            // set the owning side to null (unless already changed)
            if ($intervention->getFacture() === $this) {
                $intervention->setFacture(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, FactureLigne>
     */
    public function getFactureLignes(): Collection
    {
        return $this->factureLignes;
    }

    public function addFactureLigne(FactureLigne $factureLigne): self
    {
        if (!$this->factureLignes->contains($factureLigne)) {
            $this->factureLignes[] = $factureLigne;
            $factureLigne->setFacture($this);
        }

        return $this;
    }

    public function removeFactureLigne(FactureLigne $factureLigne): self
    {
        if ($this->factureLignes->removeElement($factureLigne)) {
            // set the owning side to null (unless already changed)
            if ($factureLigne->getFacture() === $this) {
                $factureLigne->setFacture(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, FactureTva>
     */
    public function getFactureTvas(): Collection
    {
        return $this->factureTvas;
    }

    public function addFactureTva(FactureTva $factureTva): self
    {
        if (!$this->factureTvas->contains($factureTva)) {
            $this->factureTvas[] = $factureTva;
            $factureTva->setFacture($this);
        }

        return $this;
    }

    public function removeFactureTva(FactureTva $factureTva): self
    {
        if ($this->factureTvas->removeElement($factureTva)) {
            // set the owning side to null (unless already changed)
            if ($factureTva->getFacture() === $this) {
                $factureTva->setFacture(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Paiement>
     */
    public function getPaiements(): Collection
    {
        return $this->paiements;
    }

    public function addPaiement(Paiement $paiement): self
    {
        if (!$this->paiements->contains($paiement)) {
            $this->paiements[] = $paiement;
            $paiement->setFacture($this);
        }

        return $this;
    }

    public function removePaiement(Paiement $paiement): self
    {
        if ($this->paiements->removeElement($paiement)) {
            // set the owning side to null (unless already changed)
            if ($paiement->getFacture() === $this) {
                $paiement->setFacture(null);
            }
        }

        return $this;
    }
}
