<?php

declare(strict_types=1);

namespace App\Entity;

use App\Repository\LignePaiementRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: LignePaiementRepository::class)]
#[ORM\Table(name: 'ligne_paiement')]
#[ORM\HasLifecycleCallbacks]
class LignePaiement
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToOne(inversedBy: 'lignes')]
    #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
    private ?Paiement $paiement = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
    private ?Ecole $ecole = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(onDelete: 'SET NULL')]
    private ?EcheancePaiement $echeancePaiement = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(onDelete: 'SET NULL')]
    private ?ParcoursEtudiant $parcoursEtudiant = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(onDelete: 'SET NULL')]
    private ?TypeFrais $typeFrais = null;

    #[ORM\Column(length: 180)]
    private ?string $libelle = null;

    #[ORM\Column(type: Types::DECIMAL, precision: 12, scale: 2)]
    private ?string $montant = null;

    #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
    private ?\DateTimeImmutable $createdAt = null;

    public function getId(): ?int { return $this->id; }
    public function getPaiement(): ?Paiement { return $this->paiement; }
    public function setPaiement(?Paiement $paiement): static { $this->paiement = $paiement; return $this; }
    public function getEcole(): ?Ecole { return $this->ecole; }
    public function setEcole(?Ecole $ecole): static { $this->ecole = $ecole; return $this; }
    public function getEcheancePaiement(): ?EcheancePaiement { return $this->echeancePaiement; }
    public function setEcheancePaiement(?EcheancePaiement $echeancePaiement): static { $this->echeancePaiement = $echeancePaiement; return $this; }
    public function getParcoursEtudiant(): ?ParcoursEtudiant { return $this->parcoursEtudiant; }
    public function setParcoursEtudiant(?ParcoursEtudiant $parcoursEtudiant): static { $this->parcoursEtudiant = $parcoursEtudiant; return $this; }
    public function getTypeFrais(): ?TypeFrais { return $this->typeFrais; }
    public function setTypeFrais(?TypeFrais $typeFrais): static { $this->typeFrais = $typeFrais; return $this; }
    public function getLibelle(): ?string { return $this->libelle; }
    public function setLibelle(string $libelle): static { $this->libelle = trim($libelle); return $this; }
    public function getMontant(): ?string { return $this->montant; }
    public function setMontant(string|int|float $montant): static { $this->montant = (string) $montant; return $this; }
    public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; }

    #[ORM\PrePersist]
    public function initializeCreatedAt(): void { $this->createdAt ??= new \DateTimeImmutable(); }
}
