<?php

namespace AppBundle\Entity\Billing;

use AppBundle\Entity\AccessAndFunction\Access;
use AppBundle\Entity\Booking\EducationalProject;
use AppBundle\Entity\Core\File;
use AppBundle\Entity\Product\EquipmentLoan;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\Common\Collections\ArrayCollection;


/**
 * Fais le lien entre les Bill concernées par l'export et le File généré
 * NB: BergerLevrault est un format de données demandé par le Trésor Public pour l'export des données comptables
 *
 * @Iri("http://schema.org/BergerLevrault")
 */
#[ORM\Entity]
class BergerLevrault
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['bergerlevrault'])]
    private $id;
    /**
     * @var ArrayCollection<Bill>
     */
    #[ORM\OneToMany(targetEntity: 'Bill', mappedBy: 'bergerLevrault', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['bergerlevrault_bills'])]
    private $bills;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Assert\Date]
    #[Groups(['bergerlevrault', 'bergerlevrault_list'])]
    private $date;
    /**
     * @var File
     */
    #[Assert\Valid]
    #[ORM\OneToOne(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], fetch: 'EAGER')]
    #[ORM\JoinColumn(nullable: true)]
    #[Groups(['bergerlevrault', 'bergerlevrault_list'])]
    private $file;
    /**
     * The constructor
     */
    public function __construct() {
        $this->bills = new ArrayCollection();
    }
    /**
     * Sets id.
     *
     * @param int $id
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set date
     *
     * @param \DateTime $date
     *
     * @return BergerLevrault
     */
    public function setDate($date)
    {
        $this->date = $date;

        return $this;
    }
    /**
     * Get date
     *
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->date;
    }
    /**
     * Add bill
     *
     * @param \AppBundle\Entity\Billing\Bill $bill
     *
     * @return BergerLevrault
     */
    public function addBill(\AppBundle\Entity\Billing\Bill $bill)
    {
        $this->bills[] = $bill;

        return $this;
    }
    /**
     * Remove bill
     *
     * @param \AppBundle\Entity\Billing\Bill $bill
     */
    public function removeBill(\AppBundle\Entity\Billing\Bill $bill)
    {
        $this->bills->removeElement($bill);
    }
    /**
     * Get bills
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getBills()
    {
        return $this->bills;
    }
    /**
     * Set file
     *
     * @param \AppBundle\Entity\Core\File $file
     *
     * @return BergerLevrault
     */
    public function setFile(\AppBundle\Entity\Core\File $file = null)
    {
        $this->file = $file;

        return $this;
    }
    /**
     * Get file
     *
     * @return \AppBundle\Entity\Core\File
     */
    public function getFile()
    {
        return $this->file;
    }
}
