<?php

namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass=DevisRepository::class)
 * @ORM\Table(schema="sav")
 */
class Devis
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

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

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

    /**
     * @ORM\Column(type="string", length=11, nullable=true)
     * @Groups({"api"})
     */
    private $num_devis;

    /**
     * @ORM\ManyToOne(targetEntity=DevisStatut::class, inversedBy="devis")
     * @ORM\JoinColumn(name="iddevis_statut")
     * @Groups({"api"})
     */
    private $devis_statut;

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

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

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * @Groups({"api"})
     */
    private $date_emission;

    /**
     * @ORM\ManyToOne(targetEntity=TypeDevise::class, inversedBy="devis")
     * @ORM\JoinColumn(name="idtype_devise")
     * @Groups({"api"})
     */
    private $type_devise;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"api"})
     */
    private $cli_refus_signature;

    /**
     * @ORM\Column(type="string", length=200, nullable=true)
     * @Groups({"api"})
     */
    private $commentaire_refus_signature;

    /**
     * @ORM\ManyToOne(targetEntity=TypeEnvoi::class, inversedBy="devis")
     * @ORM\JoinColumn(name="idtype_envoi")
     * @Groups({"api"})
     */
    private $type_envoi;

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

    /**
     * @ORM\OneToMany(targetEntity=DevisLigne::class, mappedBy="devis", cascade={"persist"})
     * @Groups({"api"})
     */
    private $devisLignes;

    public function __construct()
    {
        $this->factures = new ArrayCollection();
        $this->devisLignes = new ArrayCollection();
    }

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

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

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

        return $this;
    }

    /**
     * @return Collection<int, Facture>
     */
    public function getFactures(): Collection
    {
        return $this->factures;
    }

    public function addFacture(Facture $facture): self
    {
        if (!$this->factures->contains($facture)) {
            $this->factures[] = $facture;
            $facture->setDevis($this);
        }

        return $this;
    }

    public function removeFacture(Facture $facture): self
    {
        if ($this->factures->removeElement($facture)) {
            // set the owning side to null (unless already changed)
            if ($facture->getDevis() === $this) {
                $facture->setDevis(null);
            }
        }

        return $this;
    }

    public function getNumDevis(): ?string
    {
        return $this->num_devis;
    }

    public function setNumDevis(?string $num_devis): self
    {
        $this->num_devis = $num_devis;

        return $this;
    }

    public function getDevisStatut(): ?DevisStatut
    {
        return $this->devis_statut;
    }

    public function setDevisStatut(?DevisStatut $devis_statut): self
    {
        $this->devis_statut = $devis_statut;

        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 getDateEmission(): ?\DateTimeInterface
    {
        return $this->date_emission;
    }

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

        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 getCliRefusSignature(): ?bool
    {
        return $this->cli_refus_signature;
    }

    public function setCliRefusSignature(?bool $cli_refus_signature): self
    {
        $this->cli_refus_signature = $cli_refus_signature;

        return $this;
    }

    public function getCommentaireRefusSignature(): ?string
    {
        return $this->commentaire_refus_signature;
    }

    public function setCommentaireRefusSignature(?string $commentaire_refus_signature): self
    {
        $this->commentaire_refus_signature = $commentaire_refus_signature;

        return $this;
    }

    public function getTypeEnvoi(): ?TypeEnvoi
    {
        return $this->type_envoi;
    }

    public function setTypeEnvoi(?TypeEnvoi $type_envoi): self
    {
        $this->type_envoi = $type_envoi;

        return $this;
    }

    public function getStack()
    {
        return $this->stack;
    }

    public function setStack($stack): self
    {
        $this->stack = $stack;

        return $this;
    }

    /**
     * @return Collection<int, DevisLigne>
     */
    public function getDevisLignes(): Collection
    {
        return $this->devisLignes;
    }

    public function addDevisLigne(DevisLigne $devisLigne): self
    {
        if (!$this->devisLignes->contains($devisLigne)) {
            $this->devisLignes[] = $devisLigne;
            $devisLigne->setDevis($this);
        }

        return $this;
    }

    public function removeDevisLigne(DevisLigne $devisLigne): self
    {
        if ($this->devisLignes->removeElement($devisLigne)) {
            // set the owning side to null (unless already changed)
            if ($devisLigne->getDevis() === $this) {
                $devisLigne->setDevis(null);
            }
        }

        return $this;
    }
}
