src/Entity/Contrat.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContratRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=ContratRepository::class)
  7.  */
  8. class Contrat
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\Column(type="integer", nullable=true)
  18.      */
  19.     private $duree;
  20.     /**
  21.      * @ORM\Column(type="float", nullable=true)
  22.      */
  23.     private $valeur;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=User::class)
  26.      * @ORM\JoinColumn(nullable=true)
  27.      */
  28.     private $collaborateur;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Entreprise::class, inversedBy="contrats")
  31.      * @ORM\JoinColumn(nullable=true)
  32.      */
  33.     private $entreprise;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $pdl;
  38.     /**
  39.      * @ORM\Column(type="float", nullable=true, options={"default" : 0})
  40.      */
  41.     private $car 0;
  42.     /**
  43.      * @ORM\Column(type="float", nullable=true, options={"default" : 0})
  44.      */
  45.     private $prix_moyen 0;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $fournisseur;
  50.     /**
  51.      * @ORM\Column(type="datetime", nullable=true)
  52.      */
  53.     private $date_debut;
  54.     /**
  55.      * @ORM\Column(type="datetime", nullable=true)
  56.      */
  57.     private $date_fin;
  58.     /**
  59.      * @ORM\Column(type="datetime", nullable=true)
  60.      */
  61.     private $date_signature;
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getDuree(): ?int
  67.     {
  68.         if ($this->date_debut && $this->date_fin) {
  69.             $interval $this->date_debut->diff($this->date_fin);
  70.             return $interval->12 $interval->m;
  71.         }
  72.         return $this->duree;
  73.     }
  74.     public function setDuree(?int $duree): self
  75.     {
  76.         $this->duree $duree;
  77.         return $this;
  78.     }
  79.     public function getValeur(): ?float
  80.     {
  81.         // Note: Actual calculation is now handled by PricingService
  82.         return $this->valeur;
  83.     }
  84.     public function setValeur(?float $valeur): self
  85.     {
  86.         $this->valeur $valeur;
  87.         return $this;
  88.     }
  89.     public function getCollaborateur(): ?User
  90.     {
  91.         return $this->collaborateur;
  92.     }
  93.     public function setCollaborateur(?User $collaborateur): self
  94.     {
  95.         $this->collaborateur $collaborateur;
  96.         return $this;
  97.     }
  98.     public function getEntreprise(): ?Entreprise
  99.     {
  100.         return $this->entreprise;
  101.     }
  102.     public function setEntreprise(?Entreprise $entreprise): self
  103.     {
  104.         $this->entreprise $entreprise;
  105.         return $this;
  106.     }
  107.     public function getPdl(): ?string
  108.     {
  109.         return $this->pdl;
  110.     }
  111.     public function setPdl(?string $pdl): self
  112.     {
  113.         $this->pdl $pdl;
  114.         return $this;
  115.     }
  116.     public function getCar(): ?float
  117.     {
  118.         return $this->car;
  119.     }
  120.     public function setCar($car): self
  121.     {
  122.         if ($car === null) {
  123.             $this->car 0;
  124.             return $this;
  125.         }
  126.         if (is_string($car)) {
  127.             // Replace comma with dot for decimal numbers
  128.             $car str_replace(',''.'$car);
  129.             // Convert to float
  130.             $car = (float)$car;
  131.         }
  132.         $this->car = (float)$car;
  133.         return $this;
  134.     }
  135.     public function getPrixMoyen(): ?float
  136.     {
  137.         return $this->prix_moyen;
  138.     }
  139.     public function setPrixMoyen(?float $prix_moyen): self
  140.     {
  141.         $this->prix_moyen $prix_moyen ?? 0;
  142.         return $this;
  143.     }
  144.     public function getFournisseur(): ?string
  145.     {
  146.         return $this->fournisseur;
  147.     }
  148.     public function setFournisseur(?string $fournisseur): self
  149.     {
  150.         $this->fournisseur $fournisseur;
  151.         return $this;
  152.     }
  153.     public function getDateDebut(): ?\DateTimeInterface
  154.     {
  155.         return $this->date_debut;
  156.     }
  157.     public function setDateDebut(?\DateTimeInterface $date_debut): self
  158.     {
  159.         $this->date_debut $date_debut;
  160.         return $this;
  161.     }
  162.     public function getDateFin(): ?\DateTimeInterface
  163.     {
  164.         return $this->date_fin;
  165.     }
  166.     public function setDateFin(?\DateTimeInterface $date_fin): self
  167.     {
  168.         $this->date_fin $date_fin;
  169.         return $this;
  170.     }
  171.     public function getDateSignature(): ?\DateTimeInterface
  172.     {
  173.         return $this->date_signature;
  174.     }
  175.     public function setDateSignature(?\DateTimeInterface $date_signature): self
  176.     {
  177.         $this->date_signature $date_signature;
  178.         return $this;
  179.     }
  180. }