src/Entity/Inventory/PackageStockEntry.php line 14

  1. <?php
  2. namespace App\Entity\Inventory;
  3. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity]
  9. #[GetCollection(uriTemplate'/inventory/at_hub/packages')]
  10. #[ApiResource(routePrefix'inventory')]
  11. class PackageStockEntry extends PackageMovement
  12. {
  13.     #[ORM\OneToOne(inversedBy'stockEntry'targetEntityPackageStockExit::class)]
  14.     #[ORM\JoinColumn(name'exit_id'referencedColumnName'id'nullabletrue)]
  15.     protected ?PackageStockExit $stockExit null;
  16.     public function getConsolidation(): ?string
  17.     {
  18.         $shipments $this->getPackage()->getShipments();
  19.         if (null !== $this->stockExit || empty($shipments)) {
  20.             return null;
  21.         }
  22.         foreach ($shipments as $shipment) {
  23.             if ($shipment->getPlaceOfLoading() === $this->getWarehouse()) {
  24.                 return $shipment->getReference();
  25.             }
  26.         }
  27.         return null;
  28.     }
  29.     public function getStockExit(): ?PackageStockExit
  30.     {
  31.         return $this->stockExit;
  32.     }
  33.     public function setStockExit(?PackageStockExit $stockExit): static
  34.     {
  35.         $this->stockExit $stockExit;
  36.         return $this;
  37.     }
  38. }