src/Entity/Order.php line 18

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Entity;
  3. use App\Entity\Accounting\Invoice;
  4. use App\Repository\OrderRepository;
  5. use App\Traits\CreatedUpdatedByTrait;
  6. use App\Traits\TaxPriceTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  13.  * @ORM\Table(name="act_order")
  14.  */
  15. class Order
  16. {
  17.     public const SERIALIZER_GROUP_LIST 'order-list';
  18.     public const SERIALIZER_GROUP_SHOW 'order-show';
  19.     use CreatedUpdatedByTrait;
  20.     use TaxPriceTrait;
  21.     /**
  22.      * @ORM\Id()
  23.      * @ORM\GeneratedValue()
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @ORM\Column(type="float", nullable=true)
  29.      *
  30.      * @Groups({
  31.      *     Order::SERIALIZER_GROUP_LIST,
  32.      *     Order::SERIALIZER_GROUP_SHOW,
  33.      *     User::SERIALIZER_GROUP_SHOW
  34.      * })
  35.      */
  36.     private $amount;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=Package::class, inversedBy="orders")
  39.      * @ORM\JoinColumn(nullable=true)
  40.      *
  41.      * @Groups({
  42.      *     Order::SERIALIZER_GROUP_LIST,
  43.      *     Order::SERIALIZER_GROUP_SHOW,
  44.      * })
  45.      */
  46.     private $package;
  47.     /**
  48.      * @ORM\ManyToMany(targetEntity=Accounting\Invoice::class, mappedBy="orderCommand", cascade={"persist", "remove"})
  49.      */
  50.     private $invoices;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=UserSaleOrder::class, mappedBy="indent", cascade={"remove"})
  53.      */
  54.     private $userSaleOrders;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=Status::class, inversedBy="orders")
  57.      */
  58.     private $paymentStatus;
  59.     /**
  60.      * @ORM\Column(type="float", nullable=true)
  61.      */
  62.     private $markUp;
  63.     /**
  64.      * @ORM\Column(type="float", nullable=true)
  65.      */
  66.     private $markUpTTC;
  67.     /**
  68.      * @ORM\ManyToMany(targetEntity=Option::class, inversedBy="orders")
  69.      * @ORM\JoinTable(name="act_additional_order_option")
  70.      */
  71.     private $additionalOptions;
  72.     public function __construct()
  73.     {
  74.         $this->invoices = new ArrayCollection();
  75.         $this->userSaleOrders = new ArrayCollection();
  76.         $this->additionalOptions = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getAmount(): ?float
  83.     {
  84.         return $this->amount;
  85.     }
  86.     /**
  87.      * @param float $amount
  88.      *
  89.      * @return $this
  90.      */
  91.     public function setAmount(float $amount): self
  92.     {
  93.         $this->amount $amount;
  94.         return $this;
  95.     }
  96.     public function getPackage(): ?Package
  97.     {
  98.         return $this->package;
  99.     }
  100.     /**
  101.      * @param Package|null $package
  102.      *
  103.      * @return $this
  104.      */
  105.     public function setPackage(?Package $package): self
  106.     {
  107.         $this->package $package;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection|Invoice[]
  112.      */
  113.     public function getInvoices(): Collection
  114.     {
  115.         return $this->invoices;
  116.     }
  117.     /**
  118.      * @param Invoice $invoice
  119.      *
  120.      * @return $this
  121.      */
  122.     public function addInvoices(Invoice $invoice): self
  123.     {
  124.         if (!$this->invoices->contains($invoice)) {
  125.             $this->invoices[] = $invoice;
  126.             $invoice->addOrderCommand($this);
  127.         }
  128.         return $this;
  129.     }
  130.     /**
  131.      * @param Invoice $invoice
  132.      *
  133.      * @return $this
  134.      */
  135.     public function removeInvoice(Invoice $invoice): self
  136.     {
  137.         if ($this->invoices->contains($invoice)) {
  138.             $this->invoices->removeElement($invoice);
  139.             if ($invoice->getOrderCommand()->contains($this)) {
  140.                 $invoice->removeOrderCommand($this);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection|UserSaleOrder[]
  147.      */
  148.     public function getUserSaleOrders(): Collection
  149.     {
  150.         return $this->userSaleOrders;
  151.     }
  152.     /**
  153.      * @param UserSaleOrder $userSaleOrder
  154.      *
  155.      * @return $this
  156.      */
  157.     public function addUserSaleOrder(UserSaleOrder $userSaleOrder): self
  158.     {
  159.         if (!$this->userSaleOrders->contains($userSaleOrder)) {
  160.             $this->userSaleOrders[] = $userSaleOrder;
  161.             $userSaleOrder->setIndent($this);
  162.         }
  163.         return $this;
  164.     }
  165.     /**
  166.      * @param UserSaleOrder $userSaleOrder
  167.      *
  168.      * @return $this
  169.      */
  170.     public function removeUserSaleOrder(UserSaleOrder $userSaleOrder): self
  171.     {
  172.         if ($this->userSaleOrders->contains($userSaleOrder)) {
  173.             $this->userSaleOrders->removeElement($userSaleOrder);
  174.             // set the owning side to null (unless already changed)
  175.             if ($userSaleOrder->getIndent() === $this) {
  176.                 $userSaleOrder->setIndent(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Status|null
  183.      */
  184.     public function getPaymentStatus(): ?Status
  185.     {
  186.         return $this->paymentStatus;
  187.     }
  188.     /**
  189.      * @param Status|null $paymentStatus
  190.      *
  191.      * @return $this
  192.      */
  193.     public function setPaymentStatus(?Status $paymentStatus): self
  194.     {
  195.         $this->paymentStatus $paymentStatus;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection|Option[]
  200.      */
  201.     public function getAdditionalOptions(): Collection
  202.     {
  203.         return $this->additionalOptions;
  204.     }
  205.     /**
  206.      * @param Option[]|Collection $additionalOptions
  207.      *
  208.      * @return $this
  209.      */
  210.     public function addAdditionalOptions(?array $additionalOptions): self
  211.     {
  212.         foreach ($additionalOptions as $additionalOption) {
  213.             if (!$this->additionalOptions->contains($additionalOption)) {
  214.                 $this->additionalOptions[] = $additionalOption;
  215.                 $additionalOption->addOrder($this);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @param Option $additionalOption
  222.      *
  223.      * @return $this
  224.      */
  225.     public function removeAdditionalOption(Option $additionalOption): self
  226.     {
  227.         if ($this->additionalOptions->contains($additionalOption)) {
  228.             $this->additionalOptions->removeElement($additionalOption);
  229.         }
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return float|null
  234.      */
  235.     public function getMarkUp(): ?float
  236.     {
  237.         return $this->markUp;
  238.     }
  239.     /**
  240.      * @param float|null $markUp
  241.      *
  242.      * @return $this
  243.      */
  244.     public function setMarkUp(?float $markUp): self
  245.     {
  246.         $this->markUp $markUp;
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return null|float
  251.      */
  252.     public function getMarkUpTTC(): ?float
  253.     {
  254.         return $this->markUpTTC;
  255.     }
  256.     /**
  257.      * @param float|null $markUpTTC
  258.      *
  259.      * @return $this
  260.      */
  261.     public function setMarkUpTTC(?float $markUpTTC): self
  262.     {
  263.         $this->markUpTTC $markUpTTC;
  264.         return $this;
  265.     }
  266. }