<?php
namespace App\Entity;
use App\Core\Model\WorkOrder;
use App\Entity\EntityTrait\EntityIdTrait;
use App\Entity\EntityTrait\EntityLabelTrait;
use App\Repository\EstimateWorkOrderRepository;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
/**
* @ORM\Entity(repositoryClass=EstimateWorkOrderRepository::class)
* @ORM\Table(
* name="`estimate_work_order`",
* indexes={@ORM\Index(name="estimate_work_order_idx_code", columns={"code"})}
* )
*/
class EstimateWorkOrder extends WorkOrder implements JsonSerializable
{
use EntityIdTrait;
/**
* @var EstimateWorkOrderArticle | null
* @ORM\OneToOne(targetEntity="App\Entity\EstimateWorkOrderArticle", inversedBy="order", cascade={"persist", "remove"})
*/
private $article;
/**
* @var string|null
*
* @ORM\Column(type="text", nullable=true)
*/
private $label;
/**
* @var EstimateWork | null
* @ORM\ManyToOne(targetEntity="App\Entity\EstimateWork", inversedBy="orders")
* @ORM\JoinColumn(name="estimate_work_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $work;
public function __clone ()
{
$this->id = null;
}
/**
* Get Article.
*
* @return EstimateWorkOrderArticle|null The Article.
*/
public function getArticle (): ?EstimateWorkOrderArticle
{
return $this->article;
}
/**
* Set the Article.
*
* @param EstimateWorkOrderArticle|null $article
* @return EstimateWorkOrder return this class.
*/
public function setArticle (?EstimateWorkOrderArticle $article): EstimateWorkOrder
{
$this->article = $article;
return $this;
}
/**
* @return string|null
*/
public function getLabel (): ?string
{
return $this->label;
}
/**
* @param string|null $label
* @return $this
*/
public function setLabel (?string $label): self
{
$this->label = $label;
return $this;
}
/**
* Get Work.
*
* @return EstimateWork|null The Work.
*/
public function getWork (): ?EstimateWork
{
return $this->work;
}
/**
* Set the Work.
*
* @param EstimateWork|null $work
* @return EstimateWorkOrder return this class.
*/
public function setWork (?EstimateWork $work): EstimateWorkOrder
{
$this->work = $work;
return $this;
}
/**
* @inheritDoc
*/
public function jsonFormSerialize (): array
{
return array_merge(parent::jsonSerialize(), [
'id' => $this->getId(),
'work' => $this->getWork()->getId(),
'code' => $this->getCode(),
'label' => $this->getLabel(),
'excludingVatPrice' => $this->getExcludingVatPrice(),
'inludingVatPrice' => $this->getIncludingVatPrice(),
'vatRate' => $this->getVatRate(),
'vatPrice' => $this->getVatPrice(),
'discount' => $this->getDiscount(),
'quantity' => $this->getQuantity(),
'excludingDiscountedVatPrice' => $this->getExcludingVatDiscountedPrice(),
'includingDiscountedVatPrice' => $this->getIncludingVatDiscountedPrice(),
'totalVatPrice' => $this->getTotalVatPrice(),
'totalIncludingVatPrice' => $this->getTotalIncludingVatPrice(),
'totalExcludingVatPrice' => $this->getTotalExcludingVatPrice(),
'totalIncludingVatDiscountedPrice' => $this->getTotalIncludingVatDiscountedPrice(),
'totalExcludingVatDiscountedPrice' => $this->getTotalExcludingVatDiscountedPrice(),
'product' => $this->getProduct() ? $this->getProduct()->getId() : null,
]);
}
/**
* @inheritDoc
*/
public function jsonSerialize (): array
{
return array_merge(parent::jsonSerialize(), [
'work' => $this->getWork() ? $this->getWork()->getId() : null,
'article' => $this->getArticle() ? $this->getArticle()->jsonSerialize() : null,
'label' => $this->getLabel(),
]);
}
}