<?php
namespace App\Entity;
use App\Repository\StockTransactionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StockTransactionRepository::class)]
#[ORM\HasLifecycleCallbacks]
class StockTransaction extends BaseEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'text')]
private $description;
#[ORM\OneToMany(mappedBy: 'transaction', targetEntity: StockTransfer::class)]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private $stockTransfers;
#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]
private $quantity;
#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]
private $beforeQuantity;
#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]
private $afterQuantity;
#[ORM\Column(type: 'string', nullable: true)]
private $action;
#[ORM\Column(type: 'text', nullable: true)]
private $objectOfAction;
#[ORM\ManyToOne(targetEntity: Product::class, inversedBy: 'stockTransactions')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private $productId;
#[ORM\ManyToOne(targetEntity: Sales::class, inversedBy: 'stockTransactions')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private $sale;
#[ORM\ManyToOne(targetEntity: SalesReturn::class)]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private ?SalesReturn $salesReturn = null;
#[ORM\ManyToOne(targetEntity: Warehouse::class, inversedBy: 'stockTransactions')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private $warehouse;
#[ORM\ManyToOne(targetEntity: Invoice::class, inversedBy: 'stockTransactions')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private $invoice;
#[ORM\ManyToOne]
private ?MeasurementUnits $baseUnit = null;
#[ORM\ManyToOne]
private ?MeasurementUnits $soldedUnit = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true)]
private ?string $soldQuantity = null;
public function __construct()
{
$this->stockTransfers = new ArrayCollection();
}
public function __toString(): string
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description ?? '';
return $this;
}
/**
* @return Collection<int, StockTransfer>
*/
public function getStockTransfers(): Collection
{
return $this->stockTransfers;
}
public function addStockTransfer(StockTransfer $stockTransfer): self
{
if (!$this->stockTransfers->contains($stockTransfer)) {
$this->stockTransfers[] = $stockTransfer;
$stockTransfer->setTransaction($this);
}
return $this;
}
public function removeStockTransfer(StockTransfer $stockTransfer): self
{
if ($this->stockTransfers->removeElement($stockTransfer)) {
// set the owning side to null (unless already changed)
if ($stockTransfer->getTransaction() === $this) {
$stockTransfer->setTransaction(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param mixed $quantity
*/
public function setQuantity($quantity): self
{
$this->quantity = $quantity;
return $this;
}
/**
* @return mixed
*/
public function getBeforeQuantity()
{
return $this->beforeQuantity;
}
/**
* @param mixed $beforeQuantity
*/
public function setBeforeQuantity($beforeQuantity): self
{
$this->beforeQuantity = $beforeQuantity;
return $this;
}
/**
* @return mixed
*/
public function getAfterQuantity()
{
return $this->afterQuantity;
}
/**
* @param mixed $afterQuantity
*/
public function setAfterQuantity($afterQuantity): self
{
$this->afterQuantity = $afterQuantity;
return $this;
}
/**
* @return mixed
*/
public function getAction()
{
return $this->action;
}
/**
* @param mixed $action
*/
public function setAction($action): self
{
$this->action = $action;
return $this;
}
/**
* @return mixed
*/
public function getObjectOfAction()
{
return $this->objectOfAction;
}
/**
* @param mixed $objectOfAction
*/
public function setObjectOfAction($objectOfAction): self
{
$this->objectOfAction = $objectOfAction;
return $this;
}
public function getProductId(): ?Product
{
return $this->productId;
}
public function setProductId(?Product $productId): self
{
$this->productId = $productId;
return $this;
}
public function getSale(): ?Sales
{
return $this->sale;
}
public function setSale(?Sales $sale): self
{
$this->sale = $sale;
return $this;
}
public function getSalesReturn(): ?SalesReturn
{
return $this->salesReturn;
}
public function setSalesReturn(?SalesReturn $salesReturn): self
{
$this->salesReturn = $salesReturn;
return $this;
}
public function getWarehouse(): ?Warehouse
{
return $this->warehouse;
}
public function setWarehouse(?Warehouse $warehouse): self
{
$this->warehouse = $warehouse;
return $this;
}
/**
* @return mixed
*/
public function getInvoice()
{
return $this->invoice;
}
/**
* @param mixed $invoice
*/
public function setInvoice($invoice): self
{
$this->invoice = $invoice;
return $this;
}
public function getBaseUnit(): ?MeasurementUnits
{
return $this->baseUnit;
}
public function setBaseUnit(?MeasurementUnits $baseUnit): static
{
$this->baseUnit = $baseUnit;
return $this;
}
public function getSoldedUnit(): ?MeasurementUnits
{
return $this->soldedUnit;
}
public function setSoldedUnit(?MeasurementUnits $soldedUnit): static
{
$this->soldedUnit = $soldedUnit;
return $this;
}
public function getSoldQuantity(): ?string
{
return $this->soldQuantity;
}
public function setSoldQuantity(?string $soldQuantity): static
{
$this->soldQuantity = $soldQuantity;
return $this;
}
}