src/Entity/LigneAchat.php line 9

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LigneAchatRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity(repositoryClassLigneAchatRepository::class)]
  6. class LigneAchat
  7. {
  8.     #[ORM\Id]
  9.     #[ORM\GeneratedValue]
  10.     #[ORM\Column]
  11.     private ?int $id null;
  12.     #[ORM\ManyToOne(inversedBy'lignes')]
  13.     #[ORM\JoinColumn(nullablefalse)]
  14.     private ?AchatFournisseur $achat null;
  15.     #[ORM\ManyToOne]
  16.     #[ORM\JoinColumn(nullabletrue)]
  17.     private ?Produit $produit null;
  18.     #[ORM\Column(length255nullabletrue)]
  19.     private ?string $designation null;
  20.     #[ORM\Column]
  21.     private ?int $quantite null;
  22.     #[ORM\Column]
  23.     private ?float $prixUnitaire null;
  24.     #[ORM\Column(nullabletrue)]
  25.     private ?float $remise 0;
  26.     #[ORM\Column]
  27.     private ?float $montantLigne null;
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getAchat(): ?AchatFournisseur
  33.     {
  34.         return $this->achat;
  35.     }
  36.     public function setAchat(?AchatFournisseur $achat): static
  37.     {
  38.         $this->achat $achat;
  39.         return $this;
  40.     }
  41.     public function getProduit(): ?Produit
  42.     {
  43.         return $this->produit;
  44.     }
  45.     public function setProduit(?Produit $produit): static
  46.     {
  47.         $this->produit $produit;
  48.         return $this;
  49.     }
  50.     public function getDesignation(): ?string
  51.     {
  52.         return $this->designation;
  53.     }
  54.     public function setDesignation(?string $designation): static
  55.     {
  56.         $this->designation $designation;
  57.         return $this;
  58.     }
  59.     public function getQuantite(): ?int
  60.     {
  61.         return $this->quantite;
  62.     }
  63.     public function setQuantite(int $quantite): static
  64.     {
  65.         $this->quantite $quantite;
  66.         return $this;
  67.     }
  68.     public function getPrixUnitaire(): ?float
  69.     {
  70.         return $this->prixUnitaire;
  71.     }
  72.     public function setPrixUnitaire(float $prixUnitaire): static
  73.     {
  74.         $this->prixUnitaire $prixUnitaire;
  75.         return $this;
  76.     }
  77.     public function getRemise(): ?float
  78.     {
  79.         return $this->remise ?? 0;
  80.     }
  81.     public function setRemise(?float $remise): static
  82.     {
  83.         $this->remise $remise;
  84.         return $this;
  85.     }
  86.     public function getMontantLigne(): ?float
  87.     {
  88.         return $this->montantLigne;
  89.     }
  90.     public function setMontantLigne(float $montantLigne): static
  91.     {
  92.         $this->montantLigne $montantLigne;
  93.         return $this;
  94.     }
  95.     /**
  96.      * Calcule automatiquement le montant de la ligne
  97.      */
  98.     public function calculerMontant(): void
  99.     {
  100.         $montant = ($this->quantite $this->prixUnitaire) - ($this->remise ?? 0);
  101.         $this->montantLigne max(0$montant);
  102.     }
  103. }