<?php

namespace App\Entity;

use App\Repository\OptionTarifRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ORM\Entity(repositoryClass=OptionTarifRepository::class)
 * @ORM\Table(schema="sav")
 */
class OptionTarif
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=Option::class, inversedBy="optionTarifs")
     * @ORM\JoinColumn(name="idoption")
     */
    private $option;

    /**
     * @ORM\Column(type="float", nullable=true)
     * @Groups({"api"})
     */
    private $tarif_ht;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $date_debut;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $date_fin;

    /**
     * @ORM\ManyToOne(targetEntity=ContratPlage::class, inversedBy="optionTarifs")
     * @ORM\JoinColumn(name="idcontrat_plage")
     */
    private $contrat_plage;

    /**
     * @ORM\ManyToOne(targetEntity=EquipementType::class, inversedBy="optionTarifs")
     * @ORM\JoinColumn(name="idequipement_type")
     */
    private $equipement_type;

    /**
     * @ORM\ManyToOne(targetEntity=ContratType::class, inversedBy="optionTarifs")
     * @ORM\JoinColumn(name="idcontrat_type")
     * @Groups({"api"})
     */
    private $contrat_type;

    public static function create($date_debut, ContratType $contratType, Option $option, EquipementType $equipementType,  ContratPlage $contratPlage = null, $tarif) {
        $optionTarif = new OptionTarif();

        $optionTarif
            ->setDateDebut($date_debut)
            ->setTarifHt($tarif)
            ->setOption($option)
            ->setContratType($contratType)
            ->setEquipementType($equipementType)
            ->setContratPlage($contratPlage)
        ;
        return $optionTarif;
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getOption(): ?Option
    {
        return $this->option;
    }

    public function setOption(?Option $option): self
    {
        $this->option = $option;

        return $this;
    }

    public function getEquipementType(): ?EquipementType
    {
        return $this->equipement_type;
    }

    public function setEquipementType(?EquipementType $equipement_type): self
    {
        $this->equipement_type = $equipement_type;

        return $this;
    }


    public function getTarifHt(): ?float
    {
        return $this->tarif_ht;
    }

    public function setTarifHt(?float $tarif_ht): self
    {
        $this->tarif_ht = $tarif_ht;

        return $this;
    }

    public function getDateDebut(): ?\DateTimeInterface
    {
        return $this->date_debut;
    }

    public function setDateDebut(?\DateTimeInterface $date_debut): self
    {
        $this->date_debut = $date_debut;

        return $this;
    }

    public function getDateFin(): ?\DateTimeInterface
    {
        return $this->date_fin;
    }

    public function setDateFin(?\DateTimeInterface $date_fin): self
    {
        $this->date_fin = $date_fin;

        return $this;
    }

    public function getContratPlage(): ?ContratPlage
    {
        return $this->contrat_plage;
    }

    public function setContratPlage(?ContratPlage $contrat_plage): self
    {
        $this->contrat_plage = $contrat_plage;

        return $this;
    }

    public function getContratType(): ?ContratType
    {
        return $this->contrat_type;
    }

    public function setContratType(?ContratType $contrat_type): self
    {
        $this->contrat_type = $contrat_type;

        return $this;
    }
}
