src/Entity/BCData.php line 10

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BCDataRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassBCDataRepository::class)]
  7. class BCData
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\ManyToOne(inversedBy'BCData')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private ?BCFacteur $facteur null;
  16.     #[ORM\ManyToOne(inversedBy'BCData')]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private ?BCCompany $BCCompany null;
  19.     #[ORM\Column]
  20.     private ?int $depreciation null;
  21.     #[ORM\ManyToOne]
  22.     private ?BCMix $mix null;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?float $consommation null;
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?int $quantityNew null;
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?int $quantityOccasion null;
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     private ?string $comment null;
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getFacteur(): ?BCFacteur
  36.     {
  37.         return $this->facteur;
  38.     }
  39.     public function setFacteur(?BCFacteur $facteur): self
  40.     {
  41.         $this->facteur $facteur;
  42.         return $this;
  43.     }
  44.     public function getBCCompany(): ?BCCompany
  45.     {
  46.         return $this->BCCompany;
  47.     }
  48.     public function setBCCompany(?BCCompany $BCCompany): self
  49.     {
  50.         $this->BCCompany $BCCompany;
  51.         return $this;
  52.     }
  53.     public function getDepreciation(): ?int
  54.     {
  55.         return $this->depreciation;
  56.     }
  57.     public function setDepreciation(int $depreciation): self
  58.     {
  59.         $this->depreciation $depreciation;
  60.         return $this;
  61.     }
  62.     public function getMix(): ?BCMix
  63.     {
  64.         return $this->mix;
  65.     }
  66.     public function setMix(?BCMix $mix): self
  67.     {
  68.         $this->mix $mix;
  69.         return $this;
  70.     }
  71.     public function getConsommation(): ?float
  72.     {
  73.         return $this->consommation;
  74.     }
  75.     public function setConsommation(?float $consommation): self
  76.     {
  77.         $this->consommation $consommation;
  78.         return $this;
  79.     }
  80.     public function getQuantityNew(): ?int
  81.     {
  82.         return $this->quantityNew;
  83.     }
  84.     public function setQuantityNew(?int $quantityNew): self
  85.     {
  86.         $this->quantityNew $quantityNew;
  87.         return $this;
  88.     }
  89.     public function getQuantityOccasion(): ?int
  90.     {
  91.         return $this->quantityOccasion;
  92.     }
  93.     public function setQuantityOccasion(?int $quantityOccasion): self
  94.     {
  95.         $this->quantityOccasion $quantityOccasion;
  96.         return $this;
  97.     }
  98.     // Assurez-vous que les propriétés comme $quantityNew, $quantityOccasion, $facteur, etc. existent bien.
  99.     /**
  100.      * Calcul de l'impact d'usage
  101.      *
  102.      * @return float|null
  103.      */
  104.     public function getUsageImpact(): ?float
  105.     {
  106.         $quantity $this->getQuantityNew() + $this->getQuantityOccasion();
  107.         if ($this->getConsommation() && $this->getMix()) {
  108.             return $this->getConsommation() * $this->getMix()->getCoefficient() * $quantity;
  109.         }
  110.         return null;
  111.     }
  112.     /**
  113.      * Calcul de l'impact de fabrication pour le neuf
  114.      *
  115.      * @return float|null
  116.      */
  117.     public function getImpactFabricationNeuf(): ?float
  118.     {
  119.         return $this->getQuantityNew() ? $this->getFacteur()->getImpactGlobal() * $this->getQuantityNew() : null;
  120.     }
  121.     /**
  122.      * Calcul de l'impact de fabrication pour l'occasion
  123.      *
  124.      * @return float|null
  125.      */
  126.     public function getImpactFabricationOccasion(): ?float
  127.     {
  128.         return $this->getQuantityOccasion() ? $this->getFacteur()->getImpactGlobal() * $this->getQuantityOccasion() * 0.4 null;
  129.     }
  130.     /**
  131.      * Calcul de l'impact total (fabrication + usage)
  132.      *
  133.      * @return float|null
  134.      */
  135.     public function getTotalImpact(): ?float
  136.     {
  137.         $impactFabrication $this->getImpactFabricationNeuf() + $this->getImpactFabricationOccasion();
  138.         $impactUsage $this->getUsageImpact();
  139.         if ($impactUsage !== null) {
  140.             return ($impactFabrication $this->getDepreciation()) + $impactUsage;
  141.         }
  142.         return $impactFabrication $this->getDepreciation();
  143.     }
  144.     /**
  145.      * Calcul de l'impact de fabrication minimum (avec incertitude)
  146.      *
  147.      * @return float|null
  148.      */
  149.     public function getImpactFabricationMin(): ?float
  150.     {
  151.         $impactFabrication $this->getImpactFabricationNeuf() + $this->getImpactFabricationOccasion();
  152.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  153.         return $impactFabrication * ($incertitude);
  154.     }
  155.     /**
  156.      * Calcul de l'impact de fabrication maximum (avec incertitude)
  157.      *
  158.      * @return float|null
  159.      */
  160.     public function getImpactFabricationMax(): ?float
  161.     {
  162.         $impactFabrication $this->getImpactFabricationNeuf() + $this->getImpactFabricationOccasion();
  163.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  164.         return $impactFabrication * ($incertitude);
  165.     }
  166.     /**
  167.      * Calcul de l'impact d'usage minimum (avec incertitude)
  168.      *
  169.      * @return float|null
  170.      */
  171.     public function getImpactUsageMin(): ?float
  172.     {
  173.         $impactUsage $this->getUsageImpact();
  174.         if ($impactUsage === null) {
  175.             return null;
  176.         }
  177.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  178.         return $impactUsage * ($incertitude);
  179.     }
  180.     /**
  181.      * Calcul de l'impact d'usage maximum (avec incertitude)
  182.      *
  183.      * @return float|null
  184.      */
  185.     public function getImpactUsageMax(): ?float
  186.     {
  187.         $impactUsage $this->getUsageImpact();
  188.         if ($impactUsage === null) {
  189.             return null;
  190.         }
  191.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  192.         return $impactUsage * ($incertitude);
  193.     }
  194.     /**
  195.      * Calcul de l'impact total minimum (fabrication + usage avec incertitude)
  196.      *
  197.      * @return float|null
  198.      */
  199.     public function getTotalImpactMin(): ?float
  200.     {
  201.         $totalImpact $this->getTotalImpact();
  202.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  203.         return $totalImpact * ($incertitude);
  204.     }
  205.     /**
  206.      * Calcul de l'impact total maximum (fabrication + usage avec incertitude)
  207.      *
  208.      * @return float|null
  209.      */
  210.     public function getTotalImpactMax(): ?float
  211.     {
  212.         $totalImpact $this->getTotalImpact();
  213.         $incertitude $this->getFacteur()->getIncertitude() / 100;
  214.         return $totalImpact * ($incertitude);
  215.     }
  216.     public function getComment(): ?string
  217.     {
  218.         return $this->comment;
  219.     }
  220.     public function setComment(?string $comment): self
  221.     {
  222.         $this->comment $comment;
  223.         return $this;
  224.     }
  225. }