src/Entity/Expediting/Item.php line 47

  1. <?php
  2. namespace App\Entity\Expediting;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Post;
  9. use ApiPlatform\Metadata\Put;
  10. use App\Doctrine\Type\Expediting\UnitOfMeasurement;
  11. use App\Dto\Expediting\ItemSurveyInput;
  12. use App\Entity\File\File;
  13. use App\Entity\Inventory\ItemMovement;
  14. use App\Entity\Purchasing\Flow;
  15. use App\Entity\Purchasing\LineItem;
  16. use App\Entity\Purchasing\Order;
  17. use App\Processor\Expediting\ItemSurveyInputProcessor;
  18. use App\Validator\IsValidEnum\IsValidEnum;
  19. use DateTimeInterface;
  20. use Doctrine\Common\Collections\ArrayCollection;
  21. use Doctrine\Common\Collections\Collection;
  22. use Doctrine\DBAL\Types\Types;
  23. use Doctrine\ORM\Mapping as ORM;
  24. use Symfony\Component\Serializer\Annotation\Ignore;
  25. use Symfony\Component\Validator\Constraints as Assert;
  26. #[ORM\Entity]
  27. #[ApiResource(
  28.     operations: [
  29.         new Get(),
  30.         new GetCollection(),
  31.         new Post(),
  32.         new Put(),
  33.         new Patch(),
  34.         new Delete(),
  35.         new Post(
  36.             uriTemplate'/items/survey',
  37.             inputFormats: ['json' => ['application/json'], 'multipart' => ['multipart/form-data']],
  38.             inputItemSurveyInput::class,
  39.             processorItemSurveyInputProcessor::class
  40.         ),
  41.     ],
  42.     routePrefix'/expediting'
  43. )]
  44. class Item extends Expeditable
  45. {
  46.     use Shippable;
  47.     #[Assert\NotNull]
  48.     #[ORM\ManyToOne(targetEntityFreight::class, inversedBy'items')]
  49.     #[ORM\JoinColumn(name'freight_id'nullablefalse)]
  50.     private ?Freight $freight null;
  51.     #[ORM\ManyToOne(targetEntityOrder::class)]
  52.     #[ORM\JoinColumn(name'order_id')]
  53.     private ?Order $order null;
  54.     #[ORM\ManyToOne(targetEntityFlow::class)]
  55.     #[ORM\JoinColumn(name'flow_id')]
  56.     private ?Flow $flow null;
  57.     #[ORM\ManyToOne(targetEntityLineItem::class, inversedBy'items')]
  58.     #[ORM\JoinColumn(name'line_item_id')]
  59.     private ?LineItem $lineItem null;
  60.     /** @var Collection<int, Part> */
  61.     #[ORM\OneToMany(mappedBy'item'targetEntityPart::class, cascade: ['remove'])]
  62.     private Collection $parts;
  63.     #[Assert\NotBlank]
  64.     #[Assert\Type(typeTypes::STRING)]
  65.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  66.     private ?string $number null;
  67.     #[Assert\Type(typeTypes::STRING)]
  68.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  69.     private ?string $materialNumber;
  70.     #[Assert\Type(typeTypes::STRING)]
  71.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  72.     private ?string $packageNumber null;
  73.     #[IsValidEnum(enumUnitOfMeasurement::class)]
  74.     #[ORM\Column(typeTypes::STRINGnullabletrueenumTypeUnitOfMeasurement::class)]
  75.     private ?UnitOfMeasurement $unitOfMeasurement null;
  76.     #[Assert\Type(typeTypes::DATE_MUTABLE)]
  77.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  78.     private ?DateTimeInterface $requestedDeliveryOn null;
  79.     #[Assert\Type(typeTypes::INTEGER)]
  80.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  81.     private ?int $quantity null;
  82.     #[Assert\Type(typeTypes::FLOAT)]
  83.     #[ORM\Column(typeTypes::DECIMALprecision18scale5nullabletrue)]
  84.     private ?float $unitPrice null;
  85.     #[Assert\Type(typeTypes::FLOAT)]
  86.     #[ORM\Column(typeTypes::DECIMALprecision18scale5nullabletrue)]
  87.     private ?float $value null;
  88.     #[Assert\Type(typeTypes::BOOLEAN)]
  89.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  90.     private ?bool $packed false;
  91.     #[Assert\Type(typeTypes::BOOLEAN)]
  92.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  93.     private ?bool $certified false;
  94.     #[Assert\Type(typeTypes::BOOLEAN)]
  95.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  96.     private ?bool $fatRequired false;
  97.     #[Assert\Type(typeTypes::BOOLEAN)]
  98.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  99.     private ?bool $listed false;
  100.     #[Assert\Type(typeTypes::BOOLEAN)]
  101.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  102.     private ?bool $retired false;
  103.     #[Assert\Type(typeTypes::BOOLEAN)]
  104.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  105.     private ?bool $uniquePart false;
  106.     #[Assert\Type(typeTypes::BOOLEAN)]
  107.     #[ORM\Column(typeTypes::BOOLEANnullabletrueoptions: ['default' => false])]
  108.     private ?bool $manufactured false;
  109.     /** @var Collection<int, ItemMovement> */
  110.     #[ORM\OneToMany(mappedBy'item'targetEntityItemMovement::class)]
  111.     #[Ignore]
  112.     private Collection $movements;
  113.     public function __construct()
  114.     {
  115.         parent::__construct();
  116.         $this->parts = new ArrayCollection();
  117.         $this->movements = new ArrayCollection();
  118.     }
  119.     public function getFreight(): ?Freight
  120.     {
  121.         return $this->freight;
  122.     }
  123.     public function setFreight(?Freight $freight): self
  124.     {
  125.         $this->freight $freight;
  126.         return $this;
  127.     }
  128.     public function getOrder(): ?Order
  129.     {
  130.         return $this->order;
  131.     }
  132.     public function setOrder(?Order $order): self
  133.     {
  134.         $this->order $order;
  135.         return $this;
  136.     }
  137.     public function getLineItem(): ?LineItem
  138.     {
  139.         return $this->lineItem;
  140.     }
  141.     public function setLineItem(?LineItem $lineItem): self
  142.     {
  143.         $this->lineItem $lineItem;
  144.         // This is important as this is used for indexing items
  145.         $this->lineItem->addItem($this);
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return Collection<int, Part>
  150.      */
  151.     public function getParts(): Collection
  152.     {
  153.         return $this->parts;
  154.     }
  155.     public function addPart(Part $part): self
  156.     {
  157.         if (!$this->parts->contains($part)) {
  158.             $this->parts[] = $part;
  159.             $part->setItem($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removePart(Part $part): self
  164.     {
  165.         if ($this->parts->removeElement($part)) {
  166.             // set the owning side to null (unless already changed)
  167.             if ($part->getItem() === $this) {
  168.                 $part->setItem(null);
  169.             }
  170.         }
  171.         return $this;
  172.     }
  173.     public function getNumber(): ?string
  174.     {
  175.         return $this->number;
  176.     }
  177.     public function setNumber(string $number): self
  178.     {
  179.         $this->number $number;
  180.         return $this;
  181.     }
  182.     public function getMaterialNumber(): ?string
  183.     {
  184.         return $this->materialNumber;
  185.     }
  186.     public function setMaterialNumber(?string $materialNumber): self
  187.     {
  188.         $this->materialNumber $materialNumber;
  189.         return $this;
  190.     }
  191.     public function getPackageNumber(): ?string
  192.     {
  193.         return $this->packageNumber;
  194.     }
  195.     public function setPackageNumber(?string $packageNumber): self
  196.     {
  197.         $this->packageNumber $packageNumber;
  198.         return $this;
  199.     }
  200.     public function getUnitOfMeasurement(): ?UnitOfMeasurement
  201.     {
  202.         return $this->unitOfMeasurement;
  203.     }
  204.     public function setUnitOfMeasurement(?UnitOfMeasurement $unitOfMeasurement): self
  205.     {
  206.         $this->unitOfMeasurement $unitOfMeasurement;
  207.         return $this;
  208.     }
  209.     public function getRequestedDeliveryOn(): ?DateTimeInterface
  210.     {
  211.         return $this->requestedDeliveryOn;
  212.     }
  213.     public function setRequestedDeliveryOn(?DateTimeInterface $requestedDeliveryOn): self
  214.     {
  215.         $this->requestedDeliveryOn $requestedDeliveryOn;
  216.         return $this;
  217.     }
  218.     public function getQuantity(): ?int
  219.     {
  220.         return $this->quantity;
  221.     }
  222.     public function setQuantity(?int $quantity): self
  223.     {
  224.         $this->quantity $quantity;
  225.         return $this;
  226.     }
  227.     public function getUnitPrice(): ?float
  228.     {
  229.         return $this->unitPrice;
  230.     }
  231.     public function setUnitPrice(?float $unitPrice): self
  232.     {
  233.         $this->unitPrice $unitPrice;
  234.         return $this;
  235.     }
  236.     public function getValue(): ?float
  237.     {
  238.         return $this->value;
  239.     }
  240.     public function setValue(?float $value): self
  241.     {
  242.         $this->value $value;
  243.         return $this;
  244.     }
  245.     public function isPacked(): ?bool
  246.     {
  247.         return $this->packed;
  248.     }
  249.     public function setPacked(?bool $packed): self
  250.     {
  251.         $this->packed $packed;
  252.         return $this;
  253.     }
  254.     public function isCertified(): ?bool
  255.     {
  256.         return $this->certified;
  257.     }
  258.     public function setCertified(?bool $certified): self
  259.     {
  260.         $this->certified $certified;
  261.         return $this;
  262.     }
  263.     public function isFatRequired(): ?bool
  264.     {
  265.         return $this->fatRequired;
  266.     }
  267.     public function setFatRequired(?bool $fatRequired): self
  268.     {
  269.         $this->fatRequired $fatRequired;
  270.         return $this;
  271.     }
  272.     public function getFlow(): ?Flow
  273.     {
  274.         return $this->flow;
  275.     }
  276.     public function setFlow(?Flow $flow): self
  277.     {
  278.         $this->flow $flow;
  279.         return $this;
  280.     }
  281.     public function isUniquePart(): ?bool
  282.     {
  283.         return $this->uniquePart;
  284.     }
  285.     public function setUniquePart(?bool $uniquePart): self
  286.     {
  287.         $this->uniquePart $uniquePart;
  288.         return $this;
  289.     }
  290.     public function isManufactured(): ?bool
  291.     {
  292.         return $this->manufactured;
  293.     }
  294.     public function setManufactured(?bool $manufactured): self
  295.     {
  296.         $this->manufactured $manufactured;
  297.         return $this;
  298.     }
  299.     public function isListed(): ?bool
  300.     {
  301.         return $this->listed;
  302.     }
  303.     public function setListed(?bool $listed): self
  304.     {
  305.         $this->listed $listed;
  306.         return $this;
  307.     }
  308.     public function isRetired(): ?bool
  309.     {
  310.         return $this->retired;
  311.     }
  312.     public function setRetired(?bool $retired): self
  313.     {
  314.         $this->retired $retired;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection<int, ItemMovement>
  319.      */
  320.     public function getMovements(): Collection
  321.     {
  322.         return $this->movements;
  323.     }
  324.     public function addMovement(ItemMovement $movement): static
  325.     {
  326.         if (!$this->movements->contains($movement)) {
  327.             $this->movements->add($movement);
  328.             $movement->setItem($this);
  329.         }
  330.         return $this;
  331.     }
  332.     public function removeMovement(ItemMovement $movement): static
  333.     {
  334.         if ($this->movements->removeElement($movement)) {
  335.             // set the owning side to null (unless already changed)
  336.             if ($movement->getItem() === $this) {
  337.                 $movement->setItem(null);
  338.             }
  339.         }
  340.         return $this;
  341.     }
  342. }