src/Entity/EstimateWorkOrder.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Core\Model\WorkOrder;
  4. use App\Entity\EntityTrait\EntityIdTrait;
  5. use App\Entity\EntityTrait\EntityLabelTrait;
  6. use App\Repository\EstimateWorkOrderRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JsonSerializable;
  9. /**
  10.  * @ORM\Entity(repositoryClass=EstimateWorkOrderRepository::class)
  11.  * @ORM\Table(
  12.  *     name="`estimate_work_order`",
  13.  *     indexes={@ORM\Index(name="estimate_work_order_idx_code", columns={"code"})}
  14.  * )
  15.  */
  16. class EstimateWorkOrder extends WorkOrder implements JsonSerializable
  17. {
  18.     use EntityIdTrait;
  19.     /**
  20.      * @var EstimateWorkOrderArticle | null
  21.      * @ORM\OneToOne(targetEntity="App\Entity\EstimateWorkOrderArticle", inversedBy="order", cascade={"persist", "remove"})
  22.      */
  23.     private $article;
  24.     /**
  25.      * @var string|null
  26.      *
  27.      * @ORM\Column(type="text", nullable=true)
  28.      */
  29.     private $label;
  30.     /**
  31.      * @var EstimateWork | null
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\EstimateWork", inversedBy="orders")
  33.      * @ORM\JoinColumn(name="estimate_work_id", referencedColumnName="id", onDelete="CASCADE")
  34.      */
  35.     private $work;
  36.     public function __clone ()
  37.     {
  38.         $this->id null;
  39.     }
  40.     /**
  41.      * Get Article.
  42.      *
  43.      * @return EstimateWorkOrderArticle|null The Article.
  44.      */
  45.     public function getArticle (): ?EstimateWorkOrderArticle
  46.     {
  47.         return $this->article;
  48.     }
  49.     /**
  50.      * Set the Article.
  51.      *
  52.      * @param EstimateWorkOrderArticle|null $article
  53.      * @return EstimateWorkOrder return this class.
  54.      */
  55.     public function setArticle (?EstimateWorkOrderArticle $article): EstimateWorkOrder
  56.     {
  57.         $this->article $article;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return string|null
  62.      */
  63.     public function getLabel (): ?string
  64.     {
  65.         return $this->label;
  66.     }
  67.     /**
  68.      * @param string|null $label
  69.      * @return $this
  70.      */
  71.     public function setLabel (?string $label): self
  72.     {
  73.         $this->label $label;
  74.         return $this;
  75.     }
  76.     /**
  77.      * Get Work.
  78.      *
  79.      * @return EstimateWork|null The Work.
  80.      */
  81.     public function getWork (): ?EstimateWork
  82.     {
  83.         return $this->work;
  84.     }
  85.     /**
  86.      * Set the Work.
  87.      *
  88.      * @param EstimateWork|null $work
  89.      * @return EstimateWorkOrder return this class.
  90.      */
  91.     public function setWork (?EstimateWork $work): EstimateWorkOrder
  92.     {
  93.         $this->work $work;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @inheritDoc
  98.      */
  99.     public function jsonFormSerialize (): array
  100.     {
  101.         return array_merge(parent::jsonSerialize(), [
  102.             'id'                               => $this->getId(),
  103.             'work'                             => $this->getWork()->getId(),
  104.             'code'                             => $this->getCode(),
  105.             'label'                            => $this->getLabel(),
  106.             'excludingVatPrice'                => $this->getExcludingVatPrice(),
  107.             'inludingVatPrice'                 => $this->getIncludingVatPrice(),
  108.             'vatRate'                          => $this->getVatRate(),
  109.             'vatPrice'                         => $this->getVatPrice(),
  110.             'discount'                         => $this->getDiscount(),
  111.             'quantity'                         => $this->getQuantity(),
  112.             'excludingDiscountedVatPrice'      => $this->getExcludingVatDiscountedPrice(),
  113.             'includingDiscountedVatPrice'      => $this->getIncludingVatDiscountedPrice(),
  114.             'totalVatPrice'                    => $this->getTotalVatPrice(),
  115.             'totalIncludingVatPrice'           => $this->getTotalIncludingVatPrice(),
  116.             'totalExcludingVatPrice'           => $this->getTotalExcludingVatPrice(),
  117.             'totalIncludingVatDiscountedPrice' => $this->getTotalIncludingVatDiscountedPrice(),
  118.             'totalExcludingVatDiscountedPrice' => $this->getTotalExcludingVatDiscountedPrice(),
  119.             'product'                          => $this->getProduct() ? $this->getProduct()->getId() : null,
  120.         ]);
  121.     }
  122.     /**
  123.      * @inheritDoc
  124.      */
  125.     public function jsonSerialize (): array
  126.     {
  127.         return array_merge(parent::jsonSerialize(), [
  128.             'work'    => $this->getWork() ? $this->getWork()->getId() : null,
  129.             'article' => $this->getArticle() ? $this->getArticle()->jsonSerialize() : null,
  130.             'label'   => $this->getLabel(),
  131.         ]);
  132.     }
  133. }