diff --git a/src/Entity/Reception.php b/src/Entity/Reception.php index a6a1c91..b08ebf5 100644 --- a/src/Entity/Reception.php +++ b/src/Entity/Reception.php @@ -31,13 +31,14 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; #[ORM\Entity] #[ORM\HasLifecycleCallbacks] #[ORM\Table(name: 'reception')] -#[ApiFilter(BooleanFilter::class, properties: ['isValid'])] +#[ApiFilter(BooleanFilter::class, properties: ['isValid', 'entryCompleted'])] #[ApiFilter(SearchFilter::class, properties: [ 'identificationNumber' => 'ipartial', 'supplier.name' => 'ipartial', 'carrier.name' => 'ipartial', 'licensePlate' => 'ipartial', 'receptionType.id' => 'exact', + 'receptionType.code' => 'exact', ])] #[ApiFilter(DateFilter::class, properties: ['receptionDate'])] #[ApiResource( @@ -110,6 +111,10 @@ class Reception #[Groups(['reception:read', 'reception:write', 'reception-bovine:read'])] private bool $isValid = false; + #[ORM\Column(options: ['default' => false])] + #[Groups(['reception:read', 'reception:write', 'reception-bovine:read'])] + private bool $entryCompleted = false; + #[ORM\Column(name: 'date_reception', type: 'datetime_immutable')] #[Groups(['reception:read', 'reception:write', 'reception-bovine:read'])] #[Context( @@ -204,6 +209,12 @@ class Reception #[Groups(['reception:read', 'reception:write'])] private ?string $bovineDetail = null; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Bovine::class, mappedBy: 'reception')] + private Collection $bovines; + public function __construct( ?DateTimeImmutable $receptionDate = null, ) { @@ -212,6 +223,7 @@ class Reception $this->buildings = new ArrayCollection(); $this->pelletBuildings = new ArrayCollection(); $this->bovines_types = new ArrayCollection(); + $this->bovines = new ArrayCollection(); } public function getId(): ?int @@ -270,6 +282,25 @@ class Reception return $this; } + #[Groups(['reception:read'])] + public function isEntryCompleted(): bool + { + return $this->entryCompleted; + } + + public function setEntryCompleted(bool $entryCompleted): self + { + $this->entryCompleted = $entryCompleted; + + return $this; + } + + #[Groups(['reception:read'])] + public function getRegisteredBovineCount(): int + { + return $this->bovines->count(); + } + #[Groups(['reception:read'])] public function getReceptionDate(): ?DateTimeImmutable {