src/Entity/StockMovement.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Historique des mouvements de stock.
  6.  * Chaque enregistrement représente une modification (entrée, sortie, ajustement...).
  7.  *
  8.  * @ORM\Entity(repositoryClass="App\Repository\StockMovementRepository")
  9.  * @ORM\Table(name="stock_movement")
  10.  */
  11. class StockMovement
  12. {
  13.     /** 
  14.      * Identifiant unique du mouvement.
  15.      * Auto-incrémenté par la base.
  16.      * 
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private int $id;
  22.     /** 
  23.      * Identifiant du produit concerné.
  24.      * Permet de regrouper les mouvements par produit.
  25.      * 
  26.      * @ORM\Column(type="integer", nullable=true)
  27.      */
  28.     private ?int $produit_id null;
  29.     /** 
  30.      * Identifiant de la déclinaison du produit.
  31.      * Null si le mouvement concerne un produit sans déclinaison.
  32.      * 
  33.      * @ORM\Column(type="integer", nullable=true)
  34.      */
  35.     private ?int $declination_produit_id null;
  36.     /** 
  37.      * Nom ou code de l'entrepôt concerné.
  38.      * Exemple : "Principal", "Nabeul", "Sous-sol".
  39.      * 
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private ?string $storehouse null;
  43.     /** 
  44.      * Date et heure du mouvement.
  45.      * 
  46.      * @ORM\Column(type="datetime")
  47.      */
  48.     private \DateTimeInterface $created_at;
  49.     /** 
  50.      * Type de source à l’origine du mouvement :
  51.      * - "manual" → modale manuelle
  52.      * - "commande" → commande client
  53.      * - "reception" → entrée fournisseur
  54.      * - "retour" → retour client
  55.      * - "inventaire" → ajustement inventaire
  56.      * - "correction" → correction administrative
  57.      * 
  58.      * @ORM\Column(type="string", length=50, nullable=true)
  59.      */
  60.     private ?string $source_type null;
  61.     /** 
  62.      * Identifiant de la source du mouvement (facultatif).
  63.      * Ex : id du document (commande, réception, retour...).
  64.      * 
  65.      * @ORM\Column(type="integer", nullable=true)
  66.      */
  67.     private ?int $source_id null;
  68.     /** 
  69.      * Variation du stock disponible (qté entrée/sortie).
  70.      * Exemples : +5 pour une entrée, -3 pour une sortie.
  71.      * 
  72.      * @ORM\Column(type="decimal", precision=18, scale=3)
  73.      */
  74.     private string $delta_available;
  75.     /** 
  76.      * Variation du stock réservé (commandes en attente).
  77.      * Exemples : +2 quand une commande réserve du stock, -2 quand elle est annulée.
  78.      * 
  79.      * @ORM\Column(type="decimal", precision=18, scale=3, options={"default":"0.000"})
  80.      */
  81.     private string $delta_reserved '0.000';
  82.     /** 
  83.      * Stock disponible avant le mouvement.
  84.      * 
  85.      * @ORM\Column(type="decimal", precision=18, scale=3)
  86.      */
  87.     private string $qty_before_available;
  88.     /** 
  89.      * Stock disponible après le mouvement.
  90.      * 
  91.      * @ORM\Column(type="decimal", precision=18, scale=3)
  92.      */
  93.     private string $qty_after_available;
  94.     /** 
  95.      * Stock réservé avant le mouvement.
  96.      * 
  97.      * @ORM\Column(type="decimal", precision=18, scale=3)
  98.      */
  99.     private string $qty_before_reserved;
  100.     /** 
  101.      * Stock réservé après le mouvement.
  102.      * 
  103.      * @ORM\Column(type="decimal", precision=18, scale=3)
  104.      */
  105.     private string $qty_after_reserved;
  106.     /** 
  107.      * Motif du mouvement (sélectionné depuis la modale).
  108.      * Exemples : "ajustement", "perte", "retour_client", "transfert".
  109.      * 
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      */
  112.     private ?string $reason null;
  113.     /** 
  114.      * Identifiant de l’utilisateur qui a effectué le mouvement.
  115.      * 
  116.      * @ORM\Column(type="integer", nullable=true)
  117.      */
  118.     private ?int $actor_id null;
  119.     /** 
  120.      * Informations complémentaires stockées en JSON.
  121.      * Peut contenir :
  122.      *  - note ou commentaire
  123.      *  - référence produit / déclinaison
  124.      *  - IP ou origine UI
  125.      * 
  126.      * @ORM\Column(type="text", nullable=true)
  127.      */
  128.     private ?string $note null;
  129.     
  130.     /* ========================== GETTERS / SETTERS ========================== */
  131.     public function getId(): ?int { return $this->id; }
  132.     public function getProduitId(): ?int { return $this->produit_id; }
  133.     public function setProduitId(?int $produit_id): self $this->produit_id $produit_id; return $this; }
  134.     public function getDeclinationProduitId(): ?int { return $this->declination_produit_id; }
  135.     public function setDeclinationProduitId(?int $declination_produit_id): self $this->declination_produit_id $declination_produit_id; return $this; }
  136.     public function getStorehouse(): ?string { return $this->storehouse; }
  137.     public function setStorehouse(?string $storehouse): self $this->storehouse $storehouse; return $this; }
  138.     public function getCreatedAt(): \DateTimeInterface { return $this->created_at; }
  139.     public function setCreatedAt(\DateTimeInterface $created_at): self $this->created_at $created_at; return $this; }
  140.     public function getSourceType(): ?string { return $this->source_type; }
  141.     public function setSourceType(?string $source_type): self $this->source_type $source_type; return $this; }
  142.     public function getSourceId(): ?int { return $this->source_id; }
  143.     public function setSourceId(?int $source_id): self $this->source_id $source_id; return $this; }
  144.     public function getDeltaAvailable(): string { return $this->delta_available; }
  145.     public function setDeltaAvailable(string $delta_available): self $this->delta_available $delta_available; return $this; }
  146.     public function getDeltaReserved(): string { return $this->delta_reserved; }
  147.     public function setDeltaReserved(string $delta_reserved): self $this->delta_reserved $delta_reserved; return $this; }
  148.     public function getQtyBeforeAvailable(): string { return $this->qty_before_available; }
  149.     public function setQtyBeforeAvailable(string $qty_before_available): self $this->qty_before_available $qty_before_available; return $this; }
  150.     public function getQtyAfterAvailable(): string { return $this->qty_after_available; }
  151.     public function setQtyAfterAvailable(string $qty_after_available): self $this->qty_after_available $qty_after_available; return $this; }
  152.     public function getQtyBeforeReserved(): string { return $this->qty_before_reserved; }
  153.     public function setQtyBeforeReserved(string $qty_before_reserved): self $this->qty_before_reserved $qty_before_reserved; return $this; }
  154.     public function getQtyAfterReserved(): string { return $this->qty_after_reserved; }
  155.     public function setQtyAfterReserved(string $qty_after_reserved): self $this->qty_after_reserved $qty_after_reserved; return $this; }
  156.     public function getReason(): ?string { return $this->reason; }
  157.     public function setReason(?string $reason): self $this->reason $reason; return $this; }
  158.     public function getActorId(): ?int { return $this->actor_id; }
  159.     public function setActorId(?int $actor_id): self $this->actor_id $actor_id; return $this; }
  160.     public function getNote(): ?string { return $this->note; }
  161.     public function setNote(?string $note): self $this->note $note; return $this; }
  162. }