<?php declare(strict_types=1);
namespace App\Entity;
use App\Entity\Accounting\Invoice;
use App\Repository\OrderRepository;
use App\Traits\CreatedUpdatedByTrait;
use App\Traits\TaxPriceTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=OrderRepository::class)
* @ORM\Table(name="act_order")
*/
class Order
{
public const SERIALIZER_GROUP_LIST = 'order-list';
public const SERIALIZER_GROUP_SHOW = 'order-show';
use CreatedUpdatedByTrait;
use TaxPriceTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="float", nullable=true)
*
* @Groups({
* Order::SERIALIZER_GROUP_LIST,
* Order::SERIALIZER_GROUP_SHOW,
* User::SERIALIZER_GROUP_SHOW
* })
*/
private $amount;
/**
* @ORM\ManyToOne(targetEntity=Package::class, inversedBy="orders")
* @ORM\JoinColumn(nullable=true)
*
* @Groups({
* Order::SERIALIZER_GROUP_LIST,
* Order::SERIALIZER_GROUP_SHOW,
* })
*/
private $package;
/**
* @ORM\ManyToMany(targetEntity=Accounting\Invoice::class, mappedBy="orderCommand", cascade={"persist", "remove"})
*/
private $invoices;
/**
* @ORM\OneToMany(targetEntity=UserSaleOrder::class, mappedBy="indent", cascade={"remove"})
*/
private $userSaleOrders;
/**
* @ORM\ManyToOne(targetEntity=Status::class, inversedBy="orders")
*/
private $paymentStatus;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $markUp;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $markUpTTC;
/**
* @ORM\ManyToMany(targetEntity=Option::class, inversedBy="orders")
* @ORM\JoinTable(name="act_additional_order_option")
*/
private $additionalOptions;
public function __construct()
{
$this->invoices = new ArrayCollection();
$this->userSaleOrders = new ArrayCollection();
$this->additionalOptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getAmount(): ?float
{
return $this->amount;
}
/**
* @param float $amount
*
* @return $this
*/
public function setAmount(float $amount): self
{
$this->amount = $amount;
return $this;
}
public function getPackage(): ?Package
{
return $this->package;
}
/**
* @param Package|null $package
*
* @return $this
*/
public function setPackage(?Package $package): self
{
$this->package = $package;
return $this;
}
/**
* @return Collection|Invoice[]
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
/**
* @param Invoice $invoice
*
* @return $this
*/
public function addInvoices(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices[] = $invoice;
$invoice->addOrderCommand($this);
}
return $this;
}
/**
* @param Invoice $invoice
*
* @return $this
*/
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->contains($invoice)) {
$this->invoices->removeElement($invoice);
if ($invoice->getOrderCommand()->contains($this)) {
$invoice->removeOrderCommand($this);
}
}
return $this;
}
/**
* @return Collection|UserSaleOrder[]
*/
public function getUserSaleOrders(): Collection
{
return $this->userSaleOrders;
}
/**
* @param UserSaleOrder $userSaleOrder
*
* @return $this
*/
public function addUserSaleOrder(UserSaleOrder $userSaleOrder): self
{
if (!$this->userSaleOrders->contains($userSaleOrder)) {
$this->userSaleOrders[] = $userSaleOrder;
$userSaleOrder->setIndent($this);
}
return $this;
}
/**
* @param UserSaleOrder $userSaleOrder
*
* @return $this
*/
public function removeUserSaleOrder(UserSaleOrder $userSaleOrder): self
{
if ($this->userSaleOrders->contains($userSaleOrder)) {
$this->userSaleOrders->removeElement($userSaleOrder);
// set the owning side to null (unless already changed)
if ($userSaleOrder->getIndent() === $this) {
$userSaleOrder->setIndent(null);
}
}
return $this;
}
/**
* @return Status|null
*/
public function getPaymentStatus(): ?Status
{
return $this->paymentStatus;
}
/**
* @param Status|null $paymentStatus
*
* @return $this
*/
public function setPaymentStatus(?Status $paymentStatus): self
{
$this->paymentStatus = $paymentStatus;
return $this;
}
/**
* @return Collection|Option[]
*/
public function getAdditionalOptions(): Collection
{
return $this->additionalOptions;
}
/**
* @param Option[]|Collection $additionalOptions
*
* @return $this
*/
public function addAdditionalOptions(?array $additionalOptions): self
{
foreach ($additionalOptions as $additionalOption) {
if (!$this->additionalOptions->contains($additionalOption)) {
$this->additionalOptions[] = $additionalOption;
$additionalOption->addOrder($this);
}
}
return $this;
}
/**
* @param Option $additionalOption
*
* @return $this
*/
public function removeAdditionalOption(Option $additionalOption): self
{
if ($this->additionalOptions->contains($additionalOption)) {
$this->additionalOptions->removeElement($additionalOption);
}
return $this;
}
/**
* @return float|null
*/
public function getMarkUp(): ?float
{
return $this->markUp;
}
/**
* @param float|null $markUp
*
* @return $this
*/
public function setMarkUp(?float $markUp): self
{
$this->markUp = $markUp;
return $this;
}
/**
* @return null|float
*/
public function getMarkUpTTC(): ?float
{
return $this->markUpTTC;
}
/**
* @param float|null $markUpTTC
*
* @return $this
*/
public function setMarkUpTTC(?float $markUpTTC): self
{
$this->markUpTTC = $markUpTTC;
return $this;
}
}