src/Entity/Delete/Movement.php line 35

  1. <?php
  2. namespace App\Entity\Delete;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Link;
  6. use App\Doctrine\Type\Inventory\MovementType;
  7. use App\Entity\Common as Common;
  8. use App\Entity\Identity\User;
  9. use App\Validator\IsValidEnum\IsValidEnum;
  10. use DateTimeInterface;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. #[ORM\Table(name'inventory_x_movement')]
  16. #[ORM\Index(columns: ['batch_id'], name'inventory_x_movement_batch_id_idx')]
  17. #[ORM\Index(columns: ['withdrawal_id'], name'inventory_x_movement_withdrawal_id_idx')]
  18. #[ORM\Index(columns: ['material_id'], name'inventory_x_movement_material_id_idx')]
  19. #[ORM\Index(columns: ['created_by'], name'inventory_x_movement_created_by_idx')]
  20. #[ORM\Index(columns: ['updated_by'], name'inventory_x_movement_updated_by_idx')]
  21. #[ORM\Entity]
  22. #[ApiResource(
  23.     routePrefix'/nventory',
  24. )]
  25. #[ApiResource(
  26.     uriTemplate'/nventory/materials/{slug}/movements',
  27.     operations: [new GetCollection()],
  28.     uriVariables: [
  29.         'slug' => new Link(fromProperty'movements'fromClassMaterial::class),
  30.     ],
  31. )]
  32. class Movement
  33. {
  34.     use Common\Blameable;
  35.     use Common\Trackable;
  36.     #[ORM\Id]
  37.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  38.     #[ORM\SequenceGenerator(sequenceName'inventory_x_movement_id_seq')]
  39.     #[ORM\Column(typeTypes::INTEGER)]
  40.     private int $id;
  41.     #[ORM\ManyToOne(targetEntityBatch::class, inversedBy'movements')]
  42.     #[ORM\JoinColumn(name'batch_id'nullabletrue)]
  43.     private ?Batch $batch null;
  44.     #[ORM\ManyToOne(targetEntityWithdrawal::class, inversedBy'movements')]
  45.     #[ORM\JoinColumn(name'withdrawal_id'nullabletrue)]
  46.     private ?Withdrawal $withdrawal null;
  47.     #[ORM\ManyToOne(targetEntityMaterial::class, cascade: ['persist''remove'], inversedBy'movements')]
  48.     #[ORM\JoinColumn(name'material_id')]
  49.     private ?Material $material null;
  50.     #[Assert\NotNull]
  51.     #[IsValidEnum(enumMovementType::class)]
  52.     #[ORM\Column(typeTypes::STRINGenumTypeMovementType::class)]
  53.     private ?MovementType $type null;
  54.     #[Assert\Type(typeTypes::INTEGER)]
  55.     #[ORM\Column(typeTypes::INTEGER)]
  56.     private ?int $quantity null;
  57.     #[Assert\Type(typeTypes::FLOAT)]
  58.     #[ORM\Column(typeTypes::DECIMALprecision18scale5)]
  59.     private ?float $unitPrice null;
  60.     #[Assert\Type(typeTypes::FLOAT)]
  61.     #[ORM\Column(typeTypes::DECIMALprecision18scale5)]
  62.     private ?float $value null;
  63.     #[Assert\Type(typeDateTimeInterface::class)]
  64.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullablefalse)]
  65.     private ?DateTimeInterface $completedAt null;
  66.     #[Gedmo\Blameable(on'create')]
  67.     #[ORM\ManyToOne(targetEntityUser::class)]
  68.     #[ORM\JoinColumn(name'created_by'nullabletrue)]
  69.     protected ?User $createdBy null;
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getBatch(): ?Batch
  75.     {
  76.         return $this->batch;
  77.     }
  78.     public function setBatch(?Batch $batch): static
  79.     {
  80.         $this->batch $batch;
  81.         return $this;
  82.     }
  83.     public function getWithdrawal(): ?Withdrawal
  84.     {
  85.         return $this->withdrawal;
  86.     }
  87.     public function setWithdrawal(?Withdrawal $withdrawal): static
  88.     {
  89.         $this->withdrawal $withdrawal;
  90.         return $this;
  91.     }
  92.     public function getMaterial(): ?Material
  93.     {
  94.         return $this->material;
  95.     }
  96.     public function setMaterial(?Material $material): static
  97.     {
  98.         $this->material $material;
  99.         return $this;
  100.     }
  101.     public function getType(): ?MovementType
  102.     {
  103.         return $this->type;
  104.     }
  105.     public function setType(MovementType $type): static
  106.     {
  107.         $this->type $type;
  108.         return $this;
  109.     }
  110.     public function getQuantity(): ?int
  111.     {
  112.         return $this->quantity;
  113.     }
  114.     public function setQuantity(int $quantity): static
  115.     {
  116.         $this->quantity $quantity;
  117.         return $this;
  118.     }
  119.     public function getUnitPrice(): ?string
  120.     {
  121.         return $this->unitPrice;
  122.     }
  123.     public function setUnitPrice(?string $unitPrice): static
  124.     {
  125.         $this->unitPrice $unitPrice;
  126.         return $this;
  127.     }
  128.     public function getValue(): ?string
  129.     {
  130.         return $this->value;
  131.     }
  132.     public function setValue(string $value): static
  133.     {
  134.         $this->value $value;
  135.         return $this;
  136.     }
  137.     public function getCompletedAt(): ?DateTimeInterface
  138.     {
  139.         return $this->completedAt;
  140.     }
  141.     public function setCompletedAt(DateTimeInterface $completedAt): static
  142.     {
  143.         $this->completedAt $completedAt;
  144.         return $this;
  145.     }
  146. }