src/Entity/Delete/Movement.php line 35
<?php
namespace App\Entity\Delete;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use App\Doctrine\Type\Inventory\MovementType;
use App\Entity\Common as Common;
use App\Entity\Identity\User;
use App\Validator\IsValidEnum\IsValidEnum;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'inventory_x_movement')]
#[ORM\Index(columns: ['batch_id'], name: 'inventory_x_movement_batch_id_idx')]
#[ORM\Index(columns: ['withdrawal_id'], name: 'inventory_x_movement_withdrawal_id_idx')]
#[ORM\Index(columns: ['material_id'], name: 'inventory_x_movement_material_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'inventory_x_movement_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'inventory_x_movement_updated_by_idx')]
#[ORM\Entity]
#[ApiResource(
routePrefix: '/nventory',
)]
#[ApiResource(
uriTemplate: '/nventory/materials/{slug}/movements',
operations: [new GetCollection()],
uriVariables: [
'slug' => new Link(fromProperty: 'movements', fromClass: Material::class),
],
)]
class Movement
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'inventory_x_movement_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private int $id;
#[ORM\ManyToOne(targetEntity: Batch::class, inversedBy: 'movements')]
#[ORM\JoinColumn(name: 'batch_id', nullable: true)]
private ?Batch $batch = null;
#[ORM\ManyToOne(targetEntity: Withdrawal::class, inversedBy: 'movements')]
#[ORM\JoinColumn(name: 'withdrawal_id', nullable: true)]
private ?Withdrawal $withdrawal = null;
#[ORM\ManyToOne(targetEntity: Material::class, cascade: ['persist', 'remove'], inversedBy: 'movements')]
#[ORM\JoinColumn(name: 'material_id')]
private ?Material $material = null;
#[Assert\NotNull]
#[IsValidEnum(enum: MovementType::class)]
#[ORM\Column(type: Types::STRING, enumType: MovementType::class)]
private ?MovementType $type = null;
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $quantity = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 5)]
private ?float $unitPrice = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 5)]
private ?float $value = null;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE, nullable: false)]
private ?DateTimeInterface $completedAt = null;
#[Gedmo\Blameable(on: 'create')]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
protected ?User $createdBy = null;
public function getId(): ?int
{
return $this->id;
}
public function getBatch(): ?Batch
{
return $this->batch;
}
public function setBatch(?Batch $batch): static
{
$this->batch = $batch;
return $this;
}
public function getWithdrawal(): ?Withdrawal
{
return $this->withdrawal;
}
public function setWithdrawal(?Withdrawal $withdrawal): static
{
$this->withdrawal = $withdrawal;
return $this;
}
public function getMaterial(): ?Material
{
return $this->material;
}
public function setMaterial(?Material $material): static
{
$this->material = $material;
return $this;
}
public function getType(): ?MovementType
{
return $this->type;
}
public function setType(MovementType $type): static
{
$this->type = $type;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): static
{
$this->quantity = $quantity;
return $this;
}
public function getUnitPrice(): ?string
{
return $this->unitPrice;
}
public function setUnitPrice(?string $unitPrice): static
{
$this->unitPrice = $unitPrice;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): static
{
$this->value = $value;
return $this;
}
public function getCompletedAt(): ?DateTimeInterface
{
return $this->completedAt;
}
public function setCompletedAt(DateTimeInterface $completedAt): static
{
$this->completedAt = $completedAt;
return $this;
}
}