src/Entity/Inventory/PackageStockEntry.php line 14
<?php
namespace App\Entity\Inventory;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[GetCollection(uriTemplate: '/inventory/at_hub/packages')]
#[ApiResource(routePrefix: 'inventory')]
class PackageStockEntry extends PackageMovement
{
#[ORM\OneToOne(inversedBy: 'stockEntry', targetEntity: PackageStockExit::class)]
#[ORM\JoinColumn(name: 'exit_id', referencedColumnName: 'id', nullable: true)]
protected ?PackageStockExit $stockExit = null;
public function getConsolidation(): ?string
{
$shipments = $this->getPackage()->getShipments();
if (null !== $this->stockExit || empty($shipments)) {
return null;
}
foreach ($shipments as $shipment) {
if ($shipment->getPlaceOfLoading() === $this->getWarehouse()) {
return $shipment->getReference();
}
}
return null;
}
public function getStockExit(): ?PackageStockExit
{
return $this->stockExit;
}
public function setStockExit(?PackageStockExit $stockExit): static
{
$this->stockExit = $stockExit;
return $this;
}
}