<?php
namespace App\Entity;
use App\Repository\WarehouseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WarehouseRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Warehouse extends BaseEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'string', length: 255)]
private $country;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $address;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $fax;
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: Stock::class, orphanRemoval: true)]
private $stocks;
#[ORM\OneToMany(mappedBy: 'outWarehouse', targetEntity: StockTransfer::class, orphanRemoval: true)]
private $outgoingTransfers;
#[ORM\OneToMany(mappedBy: 'arrivalWarehouse', targetEntity: StockTransfer::class, orphanRemoval: true)]
private $incomingTransfers;
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: StockInfo::class)]
private $stockInfos;
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: Sales::class)]
private $sales;
#[ORM\Column(type: 'boolean')]
private $isMainWarehouse;
#[ORM\OneToMany(mappedBy: 'arrivalWarehouse', targetEntity: NewStockTransfer::class)]
private $newStockTransfers;
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: StockTransaction::class)]
private $stockTransactions;
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: Invoice::class)]
private Collection $invoices;
public function __construct()
{
$this->stocks = new ArrayCollection();
$this->outgoingTransfers = new ArrayCollection();
$this->incomingTransfers = new ArrayCollection();
$this->stockInfos = new ArrayCollection();
$this->sales = new ArrayCollection();
$this->newStockTransfers = new ArrayCollection();
$this->stockTransactions = new ArrayCollection();
$this->invoices = new ArrayCollection();
}
public function __invoke()
{
return $this->getId();
}
public function __toString(): string
{
return $this->getName();
}
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 getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getFax(): ?string
{
return $this->fax;
}
public function setFax(?string $fax): self
{
$this->fax = $fax;
return $this;
}
/**
* @return Collection<int, Stock>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stock $stock): self
{
if (!$this->stocks->contains($stock)) {
$this->stocks[] = $stock;
$stock->setWarehouse($this);
}
return $this;
}
public function removeStock(Stock $stock): self
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getWarehouse() === $this) {
$stock->setWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, StockTransfer>
*/
public function getOutgoingTransfers(): Collection
{
return $this->outgoingTransfers;
}
public function addOutgoingTransfer(StockTransfer $outgoingTransfer): self
{
if (!$this->outgoingTransfers->contains($outgoingTransfer)) {
$this->outgoingTransfers[] = $outgoingTransfer;
$outgoingTransfer->setOutWarehouse($this);
}
return $this;
}
public function removeOutgoingTransfer(StockTransfer $outgoingTransfer): self
{
if ($this->outgoingTransfers->removeElement($outgoingTransfer)) {
// set the owning side to null (unless already changed)
if ($outgoingTransfer->getOutWarehouse() === $this) {
$outgoingTransfer->setOutWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, StockTransfer>
*/
public function getIncomingTransfers(): Collection
{
return $this->incomingTransfers;
}
public function addIncomingTransfer(StockTransfer $incomingTransfer): self
{
if (!$this->incomingTransfers->contains($incomingTransfer)) {
$this->incomingTransfers[] = $incomingTransfer;
$incomingTransfer->setArrivalWarehouse($this);
}
return $this;
}
public function removeIncomingTransfer(StockTransfer $incomingTransfer): self
{
if ($this->incomingTransfers->removeElement($incomingTransfer)) {
// set the owning side to null (unless already changed)
if ($incomingTransfer->getArrivalWarehouse() === $this) {
$incomingTransfer->setArrivalWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, StockInfo>
*/
public function getStockInfos(): Collection
{
return $this->stockInfos;
}
public function addStockInfo(StockInfo $stockInfo): self
{
if (!$this->stockInfos->contains($stockInfo)) {
$this->stockInfos[] = $stockInfo;
$stockInfo->setWarehouse($this);
}
return $this;
}
public function removeStockInfo(StockInfo $stockInfo): self
{
if ($this->stockInfos->removeElement($stockInfo)) {
// set the owning side to null (unless already changed)
if ($stockInfo->getWarehouse() === $this) {
$stockInfo->setWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, Sales>
*/
public function getSales(): Collection
{
return $this->sales;
}
public function addSale(Sales $sale): self
{
if (!$this->sales->contains($sale)) {
$this->sales[] = $sale;
$sale->setWarehouse($this);
}
return $this;
}
public function removeSale(Sales $sale): self
{
if ($this->sales->removeElement($sale)) {
// set the owning side to null (unless already changed)
if ($sale->getWarehouse() === $this) {
$sale->setWarehouse(null);
}
}
return $this;
}
public function getIsMainWarehouse(): ?float
{
return $this->isMainWarehouse;
}
public function setIsMainWarehouse(float $isMainWarehouse): self
{
$this->isMainWarehouse = $isMainWarehouse;
return $this;
}
/**
* @return Collection<int, NewStockTransfer>
*/
public function getNewStockTransfers(): Collection
{
return $this->newStockTransfers;
}
public function addNewStockTransfer(NewStockTransfer $newStockTransfer): self
{
if (!$this->newStockTransfers->contains($newStockTransfer)) {
$this->newStockTransfers[] = $newStockTransfer;
$newStockTransfer->setArrivalWarehouse($this);
}
return $this;
}
public function removeNewStockTransfer(NewStockTransfer $newStockTransfer): self
{
if ($this->newStockTransfers->removeElement($newStockTransfer)) {
// set the owning side to null (unless already changed)
if ($newStockTransfer->getArrivalWarehouse() === $this) {
$newStockTransfer->setArrivalWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, StockTransaction>
*/
public function getStockTransactions(): Collection
{
return $this->stockTransactions;
}
public function addStockTransaction(StockTransaction $stockTransaction): self
{
if (!$this->stockTransactions->contains($stockTransaction)) {
$this->stockTransactions[] = $stockTransaction;
$stockTransaction->setWarehouse($this);
}
return $this;
}
public function removeStockTransaction(StockTransaction $stockTransaction): self
{
if ($this->stockTransactions->removeElement($stockTransaction)) {
// set the owning side to null (unless already changed)
if ($stockTransaction->getWarehouse() === $this) {
$stockTransaction->setWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): static
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setWarehouse($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): static
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getWarehouse() === $this) {
$invoice->setWarehouse(null);
}
}
return $this;
}
}