CotisationInfos.php 4 KB
Newer Older
Julien Jorry committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * ApiResource(
 *     attributes={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_VIEW') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
 *     collectionOperations={
 *         "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_LIST') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_LIST')"},
 *         "post"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"}
 *     },
 *     itemOperations={
 *         "get"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_LIST') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_VIEW')"},
 *         "put"={"security"="is_granted('ROLE_ADMIN_ADHERENT_COTISATIONS_GERER_EDIT') or is_granted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_GERER_EDIT')"},
 *     },
 *     normalizationContext={"groups"={"read"}},
 *     denormalizationContext={"groups"={"write"}}
 * )
 * Cotisation d'un utilisateur.
 *
 * @ORM\Entity
 * @ORM\Table(name="cotisationinfos")
 */
class CotisationInfos
{
    /**
     * @var \Ramsey\Uuid\UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     * @Groups({"read"})
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="Cotisation", cascade={"all"}, mappedBy="cotisationInfos")
     */
    protected $cotisation;

    /**
     * @var string
     *
     * @ORM\Column(name="annee", type="string", length=20)
     */
    private $annee;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="debut", type="date")
     */
    private $debut;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="fin", type="date")
     */
    private $fin;

    /**
     * RECU.
     *
     * @var bool
     *
     * @ORM\Column(name="recu", type="boolean", nullable=false)
     */
    private $recu;

    /**
     * Constructeur.
     */
    public function __construct()
    {
        $now = new \DateTime();
        $this->annee = (string) $now->format('Y');
        $this->debut = $now;
        $this->fin = new \DateTime('+1 year');
        $this->recu = false;
    }

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

    /**
     * @return Cotisation
     */
    public function getCotisation(): ?Cotisation
    {
        return $this->cotisation;
    }

    /**
     * @param Cotisation $cotisation
     *
     * @return Cotisation
     */
    public function setCotisation(Cotisation $cotisation)
    {
        $this->cotisation = $cotisation;

        return $this;
    }

    /**
     * @return string
     */
    public function getAnnee(): ?string
    {
        return $this->annee;
    }

    /**
     * @param string $annee
     *
     * @return Cotisation
     */
    public function setAnnee(string $annee)
    {
        $this->annee = $annee;

        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getDebut(): ?\DateTime
    {
        return $this->debut;
    }

    /**
     * @param \DateTime $debut
     *
     * @return Cotisation
     */
    public function setDebut(\DateTime $debut)
    {
        $this->debut = $debut;

        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getFin(): ?\DateTime
    {
        return $this->fin;
    }

    /**
     * @param \DateTime $fin
     *
     * @return Cotisation
     */
    public function setFin(\DateTime $fin)
    {
        $this->fin = $fin;

        return $this;
    }

    /**
     * @return bool
     */
    public function isRecu(): ?bool
    {
        return $this->recu;
    }

    /**
     * @param bool $recu
     *
     * @return Cotisation
     */
    public function setRecu(bool $recu)
    {
        $this->recu = $recu;

        return $this;
    }
}