src/Entity/LigneCommande.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LigneCommandeRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassLigneCommandeRepository::class)]
  7. class LigneCommande
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\ManyToOne(inversedBy'lignes')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private ?CommandeFournisseur $commande null;
  16.     #[ORM\ManyToOne]
  17.     private ?Produit $produit null;
  18.     #[ORM\Column(length255nullabletrue)]
  19.     private ?string $designation null;
  20.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  21.     private ?string $quantite '1.00';
  22.     #[ORM\Column(typeTypes::DECIMALprecision15scale2)]
  23.     private ?string $prixUnitaire '0.00';
  24.     #[ORM\Column(typeTypes::DECIMALprecision15scale2)]
  25.     private ?string $montantLigne '0.00';
  26.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  27.     private ?string $quantiteRecue '0.00';
  28.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  29.     private ?string $notes null;
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getCommande(): ?CommandeFournisseur
  35.     {
  36.         return $this->commande;
  37.     }
  38.     public function setCommande(?CommandeFournisseur $commande): static
  39.     {
  40.         $this->commande $commande;
  41.         return $this;
  42.     }
  43.     public function getProduit(): ?Produit
  44.     {
  45.         return $this->produit;
  46.     }
  47.     public function setProduit(?Produit $produit): static
  48.     {
  49.         $this->produit $produit;
  50.         return $this;
  51.     }
  52.     public function getDesignation(): ?string
  53.     {
  54.         return $this->designation;
  55.     }
  56.     public function setDesignation(?string $designation): static
  57.     {
  58.         $this->designation $designation;
  59.         return $this;
  60.     }
  61.     public function getQuantite(): ?string
  62.     {
  63.         return $this->quantite;
  64.     }
  65.     public function setQuantite(string $quantite): static
  66.     {
  67.         $this->quantite $quantite;
  68.         return $this;
  69.     }
  70.     public function getPrixUnitaire(): ?string
  71.     {
  72.         return $this->prixUnitaire;
  73.     }
  74.     public function setPrixUnitaire(string $prixUnitaire): static
  75.     {
  76.         $this->prixUnitaire $prixUnitaire;
  77.         return $this;
  78.     }
  79.     public function getMontantLigne(): ?string
  80.     {
  81.         return $this->montantLigne;
  82.     }
  83.     public function setMontantLigne(string $montantLigne): static
  84.     {
  85.         $this->montantLigne $montantLigne;
  86.         return $this;
  87.     }
  88.     public function getQuantiteRecue(): ?string
  89.     {
  90.         return $this->quantiteRecue;
  91.     }
  92.     public function setQuantiteRecue(?string $quantiteRecue): static
  93.     {
  94.         $this->quantiteRecue $quantiteRecue;
  95.         return $this;
  96.     }
  97.     public function getNotes(): ?string
  98.     {
  99.         return $this->notes;
  100.     }
  101.     public function setNotes(?string $notes): static
  102.     {
  103.         $this->notes $notes;
  104.         return $this;
  105.     }
  106.     public function calculerMontant(): void
  107.     {
  108.         $montant floatval($this->quantite) * floatval($this->prixUnitaire);
  109.         $this->montantLigne number_format($montant2'.''');
  110.     }
  111.     public function getQuantiteRestante(): float
  112.     {
  113.         return floatval($this->quantite) - floatval($this->quantiteRecue ?? 0);
  114.     }
  115.     public function estTotalementRecue(): bool
  116.     {
  117.         return floatval($this->quantiteRecue ?? 0) >= floatval($this->quantite);
  118.     }
  119.     public function __toString(): string
  120.     {
  121.         return ($this->designation ?? $this->produit?->getNom() ?? 'Ligne') . ' - ' $this->quantite;
  122.     }
  123. }