src/Entity/LigneCommandeCaisse.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Article d'une CommandeCaisse.
  6.  *
  7.  * Le prix et la TVA sont une copie de ceux du produit, rafraîchie tant que la
  8.  * commande est ouverte (CaisseService::synchroniserPrix) : la caisse encaisse
  9.  * toujours le prix à jour, et la ligne reste valable si le produit est supprimé.
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table(name="ligne_commande_caisse")
  13.  */
  14. class LigneCommandeCaisse
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=CommandeCaisse::class, inversedBy="lignes")
  24.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  25.      */
  26.     private $commande;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Produit::class)
  29.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  30.      */
  31.     private $produit;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $libelle;
  36.     /**
  37.      * @ORM\Column(type="float")
  38.      */
  39.     private $quantite = 1.0;
  40.     /**
  41.      * Prix unitaire HT avant remise.
  42.      *
  43.      * @ORM\Column(type="float")
  44.      */
  45.     private $prixUnitaireHt = 0.0;
  46.     /**
  47.      * @ORM\Column(type="float")
  48.      */
  49.     private $tauxTva = 0.0;
  50.     /**
  51.      * Remise saisie à la main sur la ligne (%). Null : remise promo du produit.
  52.      *
  53.      * @ORM\Column(type="float", nullable=true)
  54.      */
  55.     private $remiseManuelle;
  56.     /**
  57.      * Remise promo du produit (%) au moment de l'ajout / du dernier rafraîchissement.
  58.      *
  59.      * @ORM\Column(type="float", options={"default": 0})
  60.      */
  61.     private $remiseProduit = 0.0;
  62.     /**
  63.      * Précision pour la cuisine : "sans oignon", "bien cuit"...
  64.      *
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      */
  67.     private $note;
  68.     /**
  69.      * Quantité déjà transmise à la cuisine (bon de cuisine).
  70.      *
  71.      * @ORM\Column(type="float", options={"default": 0})
  72.      */
  73.     private $quantiteEnvoyeeCuisine = 0.0;
  74.     /**
  75.      * @ORM\Column(type="datetime")
  76.      */
  77.     private $createdAt;
  78.     public function __construct()
  79.     {
  80.         $this->createdAt = new \DateTime();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getCommande(): ?CommandeCaisse
  87.     {
  88.         return $this->commande;
  89.     }
  90.     public function setCommande(?CommandeCaisse $commande): self
  91.     {
  92.         $this->commande = $commande;
  93.         return $this;
  94.     }
  95.     public function getProduit(): ?Produit
  96.     {
  97.         return $this->produit;
  98.     }
  99.     public function setProduit(?Produit $produit): self
  100.     {
  101.         $this->produit = $produit;
  102.         return $this;
  103.     }
  104.     public function getLibelle(): string
  105.     {
  106.         return $this->libelle;
  107.     }
  108.     public function setLibelle(string $libelle): self
  109.     {
  110.         $this->libelle = mb_substr($libelle, 0, 255);
  111.         return $this;
  112.     }
  113.     public function getQuantite(): float
  114.     {
  115.         return $this->quantite;
  116.     }
  117.     public function setQuantite(float $quantite): self
  118.     {
  119.         $this->quantite = $quantite;
  120.         return $this;
  121.     }
  122.     public function getPrixUnitaireHt(): float
  123.     {
  124.         return $this->prixUnitaireHt;
  125.     }
  126.     public function setPrixUnitaireHt(float $prixUnitaireHt): self
  127.     {
  128.         $this->prixUnitaireHt = $prixUnitaireHt;
  129.         return $this;
  130.     }
  131.     public function getTauxTva(): float
  132.     {
  133.         return $this->tauxTva;
  134.     }
  135.     public function setTauxTva(float $tauxTva): self
  136.     {
  137.         $this->tauxTva = $tauxTva;
  138.         return $this;
  139.     }
  140.     public function getRemiseManuelle(): ?float
  141.     {
  142.         return $this->remiseManuelle;
  143.     }
  144.     public function setRemiseManuelle(?float $remiseManuelle): self
  145.     {
  146.         $this->remiseManuelle = $remiseManuelle === null ? null : max(0.0, min(100.0, $remiseManuelle));
  147.         return $this;
  148.     }
  149.     public function getRemiseProduit(): float
  150.     {
  151.         return $this->remiseProduit;
  152.     }
  153.     public function setRemiseProduit(float $remiseProduit): self
  154.     {
  155.         $this->remiseProduit = $remiseProduit;
  156.         return $this;
  157.     }
  158.     /**
  159.      * Remise effectivement appliquée (%) : la remise manuelle remplace la promo produit.
  160.      */
  161.     public function getTauxRemise(): float
  162.     {
  163.         return $this->remiseManuelle !== null ? $this->remiseManuelle : $this->remiseProduit;
  164.     }
  165.     public function getNote(): ?string
  166.     {
  167.         return $this->note;
  168.     }
  169.     public function setNote(?string $note): self
  170.     {
  171.         $note = $note !== null ? trim($note) : null;
  172.         $this->note = $note !== '' && $note !== null ? mb_substr($note, 0, 255) : null;
  173.         return $this;
  174.     }
  175.     public function getQuantiteEnvoyeeCuisine(): float
  176.     {
  177.         return $this->quantiteEnvoyeeCuisine;
  178.     }
  179.     public function setQuantiteEnvoyeeCuisine(float $quantiteEnvoyeeCuisine): self
  180.     {
  181.         $this->quantiteEnvoyeeCuisine = $quantiteEnvoyeeCuisine;
  182.         return $this;
  183.     }
  184.     public function getQuantiteAEnvoyer(): float
  185.     {
  186.         return max(0.0, $this->quantite - $this->quantiteEnvoyeeCuisine);
  187.     }
  188.     public function isEnvoyeeCuisine(): bool
  189.     {
  190.         return $this->quantiteEnvoyeeCuisine > 0;
  191.     }
  192.     public function getCreatedAt(): \DateTimeInterface
  193.     {
  194.         return $this->createdAt;
  195.     }
  196. }