<?php
namespace App\Entity;
use App\Repository\GiftProductRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: GiftProductRepository::class)]
#[ORM\Table(name: 'gift_product')]
#[ORM\HasLifecycleCallbacks]
class GiftProduct extends BaseEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Sales::class, inversedBy: 'giftProducts')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Sales $sale = null;
#[ORM\ManyToOne(targetEntity: SalesReturn::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?SalesReturn $relatedReturn = null;
#[ORM\ManyToOne(targetEntity: Product::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Product $product = null;
#[ORM\Column(type: Types::DECIMAL, precision: 15, scale: 4)]
private string $quantity;
#[ORM\Column(type: Types::DECIMAL, precision: 15, scale: 4)]
private string $baseQuantity;
#[ORM\Column(type: Types::TEXT)]
private string $reason;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $notes = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?User $givenBy = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private \DateTimeImmutable $givenAt;
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $stockDeducted = false;
public function __construct()
{
$this->givenAt = new \DateTimeImmutable('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getSale(): ?Sales
{
return $this->sale;
}
public function setSale(?Sales $sale): self
{
$this->sale = $sale;
return $this;
}
public function getRelatedReturn(): ?SalesReturn
{
return $this->relatedReturn;
}
public function setRelatedReturn(?SalesReturn $relatedReturn): self
{
$this->relatedReturn = $relatedReturn;
return $this;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(Product $product): self
{
$this->product = $product;
return $this;
}
public function getQuantity(): float
{
return (float) $this->quantity;
}
public function setQuantity(float $quantity): self
{
$this->quantity = (string) $quantity;
return $this;
}
public function getBaseQuantity(): float
{
return (float) $this->baseQuantity;
}
public function setBaseQuantity(float $baseQuantity): self
{
$this->baseQuantity = (string) $baseQuantity;
return $this;
}
public function getReason(): string
{
return $this->reason;
}
public function setReason(string $reason): self
{
$this->reason = $reason;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
public function getGivenBy(): ?User
{
return $this->givenBy;
}
public function setGivenBy(?User $givenBy): self
{
$this->givenBy = $givenBy;
return $this;
}
public function getGivenAt(): \DateTimeImmutable
{
return $this->givenAt;
}
public function setGivenAt(\DateTimeImmutable $givenAt): self
{
$this->givenAt = $givenAt;
return $this;
}
public function isStockDeducted(): bool
{
return $this->stockDeducted;
}
public function setStockDeducted(bool $stockDeducted): self
{
$this->stockDeducted = $stockDeducted;
return $this;
}
}