src/Entity/Gos/OrderPart.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Entity\Gos\Embeddable\BufferedShopOrderPart;
  4. use App\Entity\Gos\Uniqskills\OrderCancellation;
  5. use App\Entity\Gos\Uniqskills\OrderCycle;
  6. use App\Entity\Gos\Uniqskills\UserCertificate;
  7. use App\Entity\Gos\VirtualCurrency\VirtualCurrencyTransaction;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12.  * OrderPart
  13.  *
  14.  * @ORM\Table(name="order_part", indexes={@ORM\Index(name="idx_bs_status", columns={"bs_status"}), @ORM\Index(name="idx_bs_is_eligible", columns={"bs_is_eligible"})})
  15.  * @ORM\Entity(repositoryClass="App\Repository\OrderPartRepository")
  16.  * @ORM\HasLifecycleCallbacks
  17.  */
  18. class OrderPart
  19. {
  20.     /**
  21.      * @var int
  22.      *
  23.      * @ORM\Column(name="id", type="integer")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var string
  30.      *
  31.      * @ORM\Column(type="string", length=150, nullable=true)
  32.      */
  33.     private $ordTran;
  34.     /**
  35.      * @var boolean
  36.      *
  37.      * @ORM\Column(type="boolean", nullable=true)
  38.      */
  39.     private $verification;
  40.     /**
  41.      * @var \DateTime
  42.      *
  43.      * @ORM\Column(type="datetime", nullable=true)
  44.      */
  45.     private $verificationDate;
  46.     /**
  47.      * @var float
  48.      *
  49.      * @ORM\Column(type="float", precision=18, scale=2)
  50.      */
  51.     private $totalPriceGross;
  52.     /**
  53.      * @var float
  54.      *
  55.      * @ORM\Column(type="float", precision=18, scale=2)
  56.      */
  57.     private $totalPriceNet;
  58.     /**
  59.      * @var float
  60.      *
  61.      * @ORM\Column(type="float", precision=18, scale=2, nullable=true)
  62.      */
  63.     private $totalShippingCostGross;
  64.     /**
  65.      * @var float
  66.      *
  67.      * @ORM\Column(type="float", precision=18, scale=2, nullable=true)
  68.      */
  69.     private $totalShippingCostNet;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Orders", inversedBy="orderPart")
  72.      * @ORM\JoinColumn()
  73.      */
  74.     private $orders;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderProductVariant", mappedBy="orderPart", cascade={"persist"})
  77.      */
  78.     private $orderProductVariant;
  79.     /**
  80.      * @ORM\OneToOne(targetEntity="App\Entity\Gos\Notify", inversedBy="masterOrderPart", cascade={"persist"})
  81.      * @ORM\JoinColumn(onDelete="CASCADE")
  82.      */
  83.     private $masterNotify;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Notify", mappedBy="orderPart")
  86.      */
  87.     private $notify;
  88.     /**
  89.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\PaymentMethod", inversedBy="orderPart")
  90.      * @ORM\JoinColumn()
  91.      */
  92.     private $paymentMethod;
  93.     /**
  94.      * @var boolean
  95.      *
  96.      * @ORM\Column(type="boolean", nullable=true)
  97.      */
  98.     private $updateProductVariant;
  99.     /**
  100.      * @ORM\Column(type="datetime")
  101.      */
  102.     private $createdAt;
  103.     /**
  104.      * @ORM\Column(type="datetime", nullable=true)
  105.      */
  106.     private $updatedAt;
  107.     /**
  108.      * @ORM\Column(type="datetime", nullable=true)
  109.      */
  110.     private $deletedAt;
  111.     /**
  112.      * @var boolean
  113.      *
  114.      * @ORM\Column(type="boolean", options={"default": true})
  115.      */
  116.     private $isCorrect true;
  117.     /**
  118.      * @ORM\OneToOne(targetEntity="App\Entity\Gos\Uniqskills\OrderCancellation", mappedBy="orderPart")
  119.      */
  120.     private $orderCancellation;
  121.     /**
  122.      * @ORM\Column(type="boolean", options={"default": false})
  123.      */
  124.     private $isCancellation false;
  125.     /**
  126.      * @ORM\OneToOne(targetEntity="App\Entity\Gos\OrdersAwaiting", mappedBy="orderPart", cascade={"persist", "remove"})
  127.      */
  128.     private $ordersAwaiting;
  129.     /**
  130.      * @ORM\Column(type="boolean", nullable=true)
  131.      */
  132.     private $isSubscriptionRenewed;
  133.     /**
  134.      * @ORM\Column(type="boolean", nullable=true)
  135.      */
  136.     private $isTrialRecurring;
  137.     /**
  138.      * @ORM\Column(type="boolean", options={"default": false})
  139.      */
  140.     private $isTrialExtended false;
  141.     /**
  142.      * @ORM\Column(type="datetime", nullable=true)
  143.      */
  144.     private $dateNextInvoice;
  145.     /**
  146.      * @ORM\OneToOne(targetEntity=Orders::class, cascade={"persist", "remove"})
  147.      */
  148.     private $newOrdersCreatedFromTrial;
  149.     /**
  150.      * @ORM\OneToMany(targetEntity=CancellationFoResponse::class, mappedBy="orderPart")
  151.      */
  152.     private $cancellationFoResponses;
  153.     /**
  154.      * @ORM\OneToMany(targetEntity=VirtualCurrencyTransaction::class, mappedBy="orderPart")
  155.      */
  156.     private $virtualCurrencyTransactions;
  157.     /**
  158.      * @ORM\Column(type="boolean", options={"default": false})
  159.      */
  160.     private $isPaid false;
  161.     /**
  162.      * @ORM\Column(type="string", length=255, nullable=true)
  163.      */
  164.     private $paymentVerifiedOn;
  165.     /**
  166.      * @ORM\OneToMany(targetEntity=UserCertificate::class, mappedBy="orderPart")
  167.      */
  168.     private $userCertificates;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity=NewCardTokenRequest::class, mappedBy="orderPart")
  171.      */
  172.     private $newCardTokenRequests;
  173.     /**
  174.      * @ORM\OneToOne(targetEntity=CouponAudioteka::class, mappedBy="orderPart")
  175.      */
  176.     private $audiotekaCoupon;
  177.     /**
  178.      * @ORM\Embedded(class="App\Entity\Gos\Embeddable\BufferedShopOrderPart", columnPrefix="bs_")
  179.      */
  180.     private BufferedShopOrderPart $bufferedShopOrderPart;
  181.     /**
  182.      * @ORM\OneToMany(targetEntity=BufferedShopOrderPartChangeLog::class, mappedBy="orderPart")
  183.      * @ORM\OrderBy({"changedAt" = "DESC"})
  184.      */
  185.     private Collection $bufferedShopChangeLogs;
  186.     /** @ORM\PrePersist() */
  187.     public function prePersist()
  188.     {
  189.         if (empty($this->createdAt))
  190.         {
  191.             $this->createdAt = new \DateTime();
  192.         }
  193.     }
  194.     /** @ORM\PreUpdate() */
  195.     public function preUpdate()
  196.     {
  197.         $this->updatedAt = new \DateTime();
  198.     }
  199.     public function __toString()
  200.     {
  201.         return (string)$this->ordTran;
  202.     }
  203.     public function getObjectVars()
  204.     {
  205.         return get_object_vars($this);
  206.     }
  207.     public function hasEventProduct()
  208.     {
  209.         if (!$this->getOrderProductVariant()->isEmpty())
  210.         {
  211.             foreach ($this->getOrderProductVariant() as $opv)
  212.             {
  213.                 /** @var OrderProductVariant $opv */
  214.                 if ($opv->getProductVariant()->isEvent())
  215.                 {
  216.                     return true;
  217.                 }
  218.             }
  219.         }
  220.         return false;
  221.     }
  222.     public function hasEventAssigned(): bool
  223.     {
  224.         foreach ($this->getOrderProductVariant() as $opv)
  225.         {
  226.             /** @var OrderProductVariant $opv */
  227.             $event $opv->getProductPackItem()
  228.                 ? $opv->getProductPackItem()->getProductPack()?->getEvent()
  229.                 : $opv->getProductVariant()->getEvent();
  230.             if ($event instanceof Events && $event->getDontSendNotifications() !== true)
  231.             {
  232.                 return true;
  233.             }
  234.         }
  235.         return false;
  236.     }
  237.     public function omittedShippingCostsInAllProducts(): bool
  238.     {
  239.         if (!$this->getOrderProductVariant()->isEmpty())
  240.         {
  241.             foreach ($this->getOrderProductVariant() as $opv)
  242.             {
  243.                 /** @var OrderProductVariant $opv */
  244.                 if ($opv->getPrimaryVariant())
  245.                 {
  246.                     continue;
  247.                 }
  248.                 if (!$opv->getOmittedShippingCosts())
  249.                 {
  250.                     return false;
  251.                 }
  252.             }
  253.         }
  254.         return true;
  255.     }
  256.     public function hasProductOnEventTypeName($names = [])
  257.     {
  258.         if (!$this->getOrderProductVariant()->isEmpty())
  259.         {
  260.             foreach ($this->getOrderProductVariant() as $opv)
  261.             {
  262.                 /** @var OrderProductVariant $opv */
  263.                 if (
  264.                     $opv->getProductVariant()->getMasterProduct()->getProductGosType() !== null
  265.                     && $opv->getProductVariant()->getMasterProduct()->getEventType() !== null
  266.                     && $opv->getProductVariant()->getMasterProduct()->getProductGosType()->getName() === 'event'
  267.                     && in_array($opv->getProductVariant()->getMasterProduct()->getEventType()->getName(), $namesfalse)
  268.                 )
  269.                 {
  270.                     return true;
  271.                 }
  272.             }
  273.         }
  274.         return false;
  275.     }
  276.     public function checkIfPayOnlineIsActive()
  277.     {
  278.         /** @var OrderProductVariant $opv */
  279.         foreach ($this->getOrderProductVariant() as $opv)
  280.         {
  281.             if (!$opv->checkIfProductVariantHavePaymentMethod('online'))
  282.             {
  283.                 return false;
  284.             }
  285.         }
  286.         return true;
  287.     }
  288.     public function checkIfProformaIsActive()
  289.     {
  290.         /** @var OrderProductVariant $opv */
  291.         foreach ($this->getOrderProductVariant() as $opv)
  292.         {
  293.             if (!$opv->checkIfProductVariantHavePaymentMethod('proforma-invoice'))
  294.             {
  295.                 return false;
  296.             }
  297.         }
  298.         return true;
  299.     }
  300.     public function checkIfToHideInSB()
  301.     {
  302.         /** @var OrderProductVariant $opv */
  303.         foreach ($this->getOrderProductVariant() as $opv)
  304.         {
  305.             if ($opv->checkIfProductVariantHaveToBeHiddenInSB())
  306.             {
  307.                 return true;
  308.             }
  309.         }
  310.         return false;
  311.     }
  312.     /**
  313.      * Add orderProductVariant
  314.      *
  315.      * @param \App\Entity\Gos\OrderProductVariant $orderProductVariant
  316.      *
  317.      * @return OrderPart
  318.      */
  319.     public function setOrderProductVariant(\App\Entity\Gos\OrderProductVariant $orderProductVariant)
  320.     {
  321.         $this->orderProductVariant[] = $orderProductVariant;
  322.         return $this;
  323.     }
  324.     /**
  325.      * Set orders
  326.      *
  327.      * @param \App\Entity\Gos\Orders $orders
  328.      *
  329.      * @return OrderPart
  330.      */
  331.     public function setOrders(\App\Entity\Gos\Orders $orders null)
  332.     {
  333.         $this->orders $orders;
  334.         if (!empty($orders))
  335.         {
  336.             $orders->addOrderPart($this);
  337.         }
  338.         return $this;
  339.     }
  340.     public function hasTestProduct()
  341.     {
  342.         /** @var OrderProductVariant $orderProductVariant */
  343.         foreach ($this->getOrderProductVariant() as $orderProductVariant)
  344.         {
  345.             /** @var \App\Entity\Gos\ProductVariant $productVariant */
  346.             $productVariant $orderProductVariant->getProductVariant();
  347.             if (
  348.                 !empty($productVariant)
  349.                 && $productVariant->getIsTest()
  350.             )
  351.             {
  352.                 return true;
  353.             }
  354.         }
  355.         return false;
  356.     }
  357.     //------------------------------ setters & getters
  358.     /**
  359.      * Get id
  360.      *
  361.      * @return int
  362.      */
  363.     public function getId()
  364.     {
  365.         return $this->id;
  366.     }
  367.     /**
  368.      * Set totalShippingCostGross
  369.      *
  370.      * @param float $totalShippingCostGross
  371.      *
  372.      * @return OrderPart
  373.      */
  374.     public function setTotalShippingCostGross($totalShippingCostGross)
  375.     {
  376.         $this->totalShippingCostGross $totalShippingCostGross;
  377.         return $this;
  378.     }
  379.     /**
  380.      * Get totalShippingCostGross
  381.      *
  382.      * @return float
  383.      */
  384.     public function getTotalShippingCostGross()
  385.     {
  386.         return $this->totalShippingCostGross;
  387.     }
  388.     /**
  389.      * Set totalShippingCostNet
  390.      *
  391.      * @param float $totalShippingCostNet
  392.      *
  393.      * @return OrderPart
  394.      */
  395.     public function setTotalShippingCostNet($totalShippingCostNet)
  396.     {
  397.         $this->totalShippingCostNet $totalShippingCostNet;
  398.         return $this;
  399.     }
  400.     /**
  401.      * Get totalShippingCostNet
  402.      *
  403.      * @return float
  404.      */
  405.     public function getTotalShippingCostNet()
  406.     {
  407.         return $this->totalShippingCostNet;
  408.     }
  409.     /**
  410.      * Set ordTran
  411.      *
  412.      * @param string $ordTran
  413.      *
  414.      * @return OrderPart
  415.      */
  416.     public function setOrdTran($ordTran)
  417.     {
  418.         $this->ordTran $ordTran;
  419.         return $this;
  420.     }
  421.     /**
  422.      * Get ordTran
  423.      *
  424.      * @return string
  425.      */
  426.     public function getOrdTran()
  427.     {
  428.         return $this->ordTran;
  429.     }
  430.     /**
  431.      * Set createdAt
  432.      *
  433.      * @param \DateTime $createdAt
  434.      *
  435.      * @return OrderPart
  436.      */
  437.     public function setCreatedAt($createdAt)
  438.     {
  439.         $this->createdAt $createdAt;
  440.         return $this;
  441.     }
  442.     /**
  443.      * Get createdAt
  444.      *
  445.      * @return \DateTime
  446.      */
  447.     public function getCreatedAt()
  448.     {
  449.         return $this->createdAt;
  450.     }
  451.     /**
  452.      * Set updatedAt
  453.      *
  454.      * @param \DateTime $updatedAt
  455.      *
  456.      * @return OrderPart
  457.      */
  458.     public function setUpdatedAt($updatedAt)
  459.     {
  460.         $this->updatedAt $updatedAt;
  461.         return $this;
  462.     }
  463.     /**
  464.      * Get updatedAt
  465.      *
  466.      * @return \DateTime
  467.      */
  468.     public function getUpdatedAt()
  469.     {
  470.         return $this->updatedAt;
  471.     }
  472.     /**
  473.      * Get orders
  474.      *
  475.      * @return \App\Entity\Gos\Orders
  476.      */
  477.     public function getOrders()
  478.     {
  479.         return $this->orders;
  480.     }
  481.     /**
  482.      * Constructor
  483.      */
  484.     public function __construct()
  485.     {
  486.         $this->orderProductVariant = new \Doctrine\Common\Collections\ArrayCollection();
  487.         $this->notify = new ArrayCollection();
  488.         $this->virtualCurrencyTransactions = new ArrayCollection();
  489.         $this->newCardTokenRequests = new ArrayCollection();
  490.         $this->userCertificates = new ArrayCollection();
  491.         $this->bufferedShopOrderPart = new BufferedShopOrderPart();
  492.         $this->bufferedShopChangeLogs = new ArrayCollection();
  493.     }
  494.     /**
  495.      * Add orderProductVariant
  496.      *
  497.      * @param \App\Entity\Gos\OrderProductVariant $orderProductVariant
  498.      *
  499.      * @return OrderPart
  500.      */
  501.     public function addOrderProductVariant(\App\Entity\Gos\OrderProductVariant $orderProductVariant)
  502.     {
  503.         $orderProductVariant->setOrderPart($this);
  504.         return $this;
  505.     }
  506.     /**
  507.      * Remove orderProductVariant
  508.      *
  509.      * @param \App\Entity\Gos\OrderProductVariant $orderProductVariant
  510.      */
  511.     public function removeOrderProductVariant(\App\Entity\Gos\OrderProductVariant $orderProductVariant)
  512.     {
  513.         $this->orderProductVariant->removeElement($orderProductVariant);
  514.     }
  515.     /**
  516.      * Get orderProductVariant
  517.      *
  518.      * @return \Doctrine\Common\Collections\Collection
  519.      */
  520.     public function getOrderProductVariant()
  521.     {
  522.         return $this->orderProductVariant;
  523.     }
  524.     public function getNotGratisOrderProductVariants(): array
  525.     {
  526.         $result = [];
  527.         foreach ($this->orderProductVariant as $orderProductVariant) {
  528.             if (
  529.                 $orderProductVariant->getOrderProductVariantType() !== null
  530.                 && $orderProductVariant->getOrderProductVariantType()->getName() !== 'gratis'
  531.             ) {
  532.                 $result[] = $orderProductVariant;
  533.             }
  534.         }
  535.         return $result;
  536.     }
  537.     /**
  538.      * Set totalPriceGross
  539.      *
  540.      * @param float $totalPriceGross
  541.      *
  542.      * @return OrderPart
  543.      */
  544.     public function setTotalPriceGross($totalPriceGross)
  545.     {
  546.         $this->totalPriceGross round($totalPriceGross,2);
  547.         return $this;
  548.     }
  549.     /**
  550.      * Get totalPriceGross
  551.      *
  552.      * @return float
  553.      */
  554.     public function getTotalPriceGross()
  555.     {
  556.         return $this->totalPriceGross;
  557.     }
  558.     /**
  559.      * Set totalPriceNet
  560.      *
  561.      * @param float $totalPriceNet
  562.      *
  563.      * @return OrderPart
  564.      */
  565.     public function setTotalPriceNet($totalPriceNet)
  566.     {
  567.         $this->totalPriceNet round($totalPriceNet,2);
  568.         return $this;
  569.     }
  570.     /**
  571.      * Get totalPriceNet
  572.      *
  573.      * @return float
  574.      */
  575.     public function getTotalPriceNet()
  576.     {
  577.         return $this->totalPriceNet;
  578.     }
  579.     /**
  580.      * Set masterNotify
  581.      *
  582.      * @param \App\Entity\Gos\Notify $masterNotify
  583.      *
  584.      * @return OrderPart
  585.      */
  586.     public function setMasterNotify(\App\Entity\Gos\Notify $masterNotify null)
  587.     {
  588.         $this->masterNotify $masterNotify;
  589.         return $this;
  590.     }
  591.     /**
  592.      * Get masterNotify
  593.      *
  594.      * @return \App\Entity\Gos\Notify
  595.      */
  596.     public function getMasterNotify()
  597.     {
  598.         return $this->masterNotify;
  599.     }
  600.     /**
  601.      * Add notify
  602.      *
  603.      * @param \App\Entity\Gos\Notify $notify
  604.      *
  605.      * @return OrderPart
  606.      */
  607.     public function addNotify(\App\Entity\Gos\Notify $notify)
  608.     {
  609.         $this->notify[] = $notify;
  610.         return $this;
  611.     }
  612.     /**
  613.      * Remove notify
  614.      *
  615.      * @param \App\Entity\Gos\Notify $notify
  616.      */
  617.     public function removeNotify(\App\Entity\Gos\Notify $notify)
  618.     {
  619.         $this->notify->removeElement($notify);
  620.     }
  621.     /**
  622.      * Get notify
  623.      *
  624.      * @return \Doctrine\Common\Collections\Collection
  625.      */
  626.     public function getNotify()
  627.     {
  628.         return $this->notify;
  629.     }
  630.     /**
  631.      * Set paymentMethod
  632.      *
  633.      * @param \App\Entity\Gos\PaymentMethod $paymentMethod
  634.      *
  635.      * @return OrderPart
  636.      */
  637.     public function setPaymentMethod(\App\Entity\Gos\PaymentMethod $paymentMethod null)
  638.     {
  639.         $this->paymentMethod $paymentMethod;
  640.         return $this;
  641.     }
  642.     /**
  643.      * Get paymentMethod
  644.      *
  645.      * @return \App\Entity\Gos\PaymentMethod
  646.      */
  647.     public function getPaymentMethod()
  648.     {
  649.         return $this->paymentMethod;
  650.     }
  651.     /**
  652.      * Set verification
  653.      *
  654.      * @param boolean $verification
  655.      *
  656.      * @return OrderPart
  657.      */
  658.     public function setVerification($verification)
  659.     {
  660.         $this->verification $verification;
  661.         return $this;
  662.     }
  663.     /**
  664.      * Get verification
  665.      *
  666.      * @return boolean
  667.      */
  668.     public function getVerification()
  669.     {
  670.         return $this->verification;
  671.     }
  672.     /**
  673.      * Set verificationDate
  674.      *
  675.      * @param \DateTime $verificationDate
  676.      *
  677.      * @return OrderPart
  678.      */
  679.     public function setVerificationDate($verificationDate)
  680.     {
  681.         $this->verificationDate $verificationDate;
  682.         return $this;
  683.     }
  684.     /**
  685.      * Get verificationDate
  686.      *
  687.      * @return \DateTime
  688.      */
  689.     public function getVerificationDate()
  690.     {
  691.         return $this->verificationDate;
  692.     }
  693.     /**
  694.      * Set deletedAt
  695.      *
  696.      * @param \DateTime $deletedAt
  697.      *
  698.      * @return OrderPart
  699.      */
  700.     public function setDeletedAt($deletedAt)
  701.     {
  702.         $this->deletedAt $deletedAt;
  703.         return $this;
  704.     }
  705.     /**
  706.      * Get deletedAt
  707.      *
  708.      * @return \DateTime
  709.      */
  710.     public function getDeletedAt()
  711.     {
  712.         return $this->deletedAt;
  713.     }
  714.     /**
  715.      * Set updateProductVariant
  716.      *
  717.      * @param boolean $updateProductVariant
  718.      *
  719.      * @return OrderPart
  720.      */
  721.     public function setUpdateProductVariant($updateProductVariant)
  722.     {
  723.         $this->updateProductVariant $updateProductVariant;
  724.         return $this;
  725.     }
  726.     /**
  727.      * Get updateProductVariant
  728.      *
  729.      * @return boolean
  730.      */
  731.     public function getUpdateProductVariant()
  732.     {
  733.         return $this->updateProductVariant;
  734.     }
  735.     
  736.     /**
  737.      * Set isCorrect
  738.      *
  739.      * @param boolean $isCorrect
  740.      *
  741.      * @return OrderPart
  742.      */
  743.     public function setIsCorrect($isCorrect)
  744.     {
  745.         $this->isCorrect $isCorrect;
  746.         return $this;
  747.     }
  748.     /**
  749.      * Get isCorrect
  750.      *
  751.      * @return boolean
  752.      */
  753.     public function getIsCorrect()
  754.     {
  755.         return $this->isCorrect;
  756.     }
  757.     public function isGift()
  758.     {
  759.         return (!$this->getOrderProductVariantsToGift()->isEmpty() && !empty($this->getOrders()->getBuyerGift()));
  760.     }
  761.     public function getOrderProductVariantsToGift()
  762.     {
  763.         if (!empty($this->orderProductVariant))
  764.         {
  765.             return $this->getOrderProductVariant()->filter(
  766.                 function ($orderProductVariant) {
  767.                     return !empty($orderProductVariant->getGift());
  768.                 }
  769.             );
  770.         }
  771.         return new ArrayCollection();
  772.     }
  773.     public function hasRecurringPaymentProducts(): bool
  774.     {
  775.         foreach ($this->orderProductVariant as $opv)
  776.         {
  777.             /** @var OrderProductVariant $opv */
  778.             if ($opv->getProductVariant()->getIsRecurringSubscription())
  779.             {
  780.                 return true;
  781.             }
  782.         }
  783.         return false;
  784.     }
  785.     public function hasTrialProducts(): bool
  786.     {
  787.         /** @var OrderProductVariant $opv */
  788.         foreach ($this->orderProductVariant as $opv)
  789.         {
  790.             if ($opv->getProductVariant()->getStateIsTrialRecurring())
  791.             {
  792.                 return true;
  793.             }
  794.         }
  795.         return false;
  796.     }
  797.     public function getTrialProduct()
  798.     {
  799.         /** @var OrderProductVariant $opv */
  800.         foreach ($this->orderProductVariant as $opv)
  801.         {
  802.             if ($opv->getProductVariant()->getStateIsTrialRecurring())
  803.             {
  804.                 return $opv->getProductVariant();
  805.             }
  806.         }
  807.         return false;
  808.     }
  809.     public function hasUniqskillsProducts()
  810.     {
  811.         foreach ($this->orderProductVariant as $opv)
  812.         {
  813.             /** @var OrderProductVariant $opv */
  814.             if (!$opv->getProductVariant()->getCourses()->isEmpty())
  815.             {
  816.                 return true;
  817.             }
  818.         }
  819.         return false;
  820.     }
  821.     public function hasOnlyUniqskillsProducts()
  822.     {
  823.         foreach ($this->orderProductVariant as $opv)
  824.         {
  825.             /** @var OrderProductVariant $opv */
  826.             if ($opv->getProductVariant()->getCourses()->isEmpty())
  827.             {
  828.                 return false;
  829.             }
  830.         }
  831.         return true;
  832.     }
  833.     public function hasDelayedProformaProducts()
  834.     {
  835.         foreach ($this->orderProductVariant as $opv)
  836.         {
  837.             /** @var OrderProductVariant $opv */
  838.             if ($opv->checkIfProductVariantHavePaymentMethod('delayed-proforma'))
  839.             {
  840.                 return true;
  841.             }
  842.         }
  843.         return false;
  844.     }
  845.     public function getIsSubscriptionRenewed(): ?bool
  846.     {
  847.         return $this->isSubscriptionRenewed;
  848.     }
  849.     public function setIsSubscriptionRenewed(?bool $isSubscriptionRenewed): self
  850.     {
  851.         $this->isSubscriptionRenewed $isSubscriptionRenewed;
  852.         return $this;
  853.     }
  854.     public function getIsTrialRecurring(): ?bool
  855.     {
  856.         return $this->isTrialRecurring;
  857.     }
  858.     public function setIsTrialRecurring(?bool $isTrialRecurring): self
  859.     {
  860.         $this->isTrialRecurring $isTrialRecurring;
  861.         return $this;
  862.     }
  863.     public function getIsTrialExtended(): ?bool
  864.     {
  865.         return $this->isTrialExtended;
  866.     }
  867.     public function setIsTrialExtended(?bool $isTrialExtended): self
  868.     {
  869.         $this->isTrialExtended $isTrialExtended;
  870.         return $this;
  871.     }
  872.     public function getOrderCancellation(): ?OrderCancellation
  873.     {
  874.         return $this->orderCancellation;
  875.     }
  876.     public function setOrderCancellation(?OrderCancellation $orderCancellation): self
  877.     {
  878.         $this->orderCancellation $orderCancellation;
  879.         return $this;
  880.     }
  881.     /**
  882.      * Set isCancellation
  883.      *
  884.      * @param boolean $isCancellation
  885.      *
  886.      * @return OrderPart
  887.      */
  888.     public function setIsCancellation($isCancellation)
  889.     {
  890.         $this->isCancellation $isCancellation;
  891.         return $this;
  892.     }
  893.     /**
  894.      * Get isCancellation
  895.      *
  896.      * @return boolean
  897.      */
  898.     public function getIsCancellation()
  899.     {
  900.         return $this->isCancellation;
  901.     }
  902.     public function getOrdersAwaiting(): ?OrdersAwaiting
  903.     {
  904.         return $this->ordersAwaiting;
  905.     }
  906.     public function setOrdersAwaiting(OrdersAwaiting $ordersAwaiting): self
  907.     {
  908.         $this->ordersAwaiting $ordersAwaiting;
  909.         // set the owning side of the relation if necessary
  910.         if ($ordersAwaiting->getOrderPart() !== $this) {
  911.             $ordersAwaiting->setOrderPart($this);
  912.         }
  913.         return $this;
  914.     }
  915.     public function hasCycle(): bool
  916.     {
  917.         /** @var OrderProductVariant $opv */
  918.         foreach ($this->getOrderProductVariant() as $opv)
  919.         {
  920.             if ($opv->getCycle())
  921.             {
  922.                 return true;
  923.             }
  924.         }
  925.         return false;
  926.     }
  927.     public function getCycle(): ?OrderCycle
  928.     {
  929.         /** @var OrderProductVariant $opv */
  930.         foreach ($this->getOrderProductVariant() as $opv)
  931.         {
  932.             if ($opv->getCycle())
  933.             {
  934.                 return $opv->getCycle();
  935.             }
  936.         }
  937.         return null;
  938.     }
  939.     public function createOrdTran(?string $ordTranPrefix null): void
  940.     {
  941.         $ordTranPrefix ??= 'WF';
  942.         $hash substr(md5($this->getId() . '-' $this->getOrders()->getPortalSettings()->getId()), -5);
  943.         $isShortFormat in_array($ordTranPrefix, ['UK''MNT'], true);
  944.         $hash $isShortFormat
  945.             $ordTranPrefix $this->getId() . '-' $hash
  946.             $ordTranPrefix $this->getId() . '-GOS-' $hash;
  947.         $this->setOrdTran($hash);
  948.     }
  949.     public function getDateNextInvoice(): ?\DateTimeInterface
  950.     {
  951.         return $this->dateNextInvoice;
  952.     }
  953.     public function setDateNextInvoice(?\DateTimeInterface $dateNextInvoice): self
  954.     {
  955.         $this->dateNextInvoice $dateNextInvoice;
  956.         return $this;
  957.     }
  958.     public function hasAnnualSubscription(): bool
  959.     {
  960.         /** @var OrderProductVariant $opv */
  961.         foreach ($this->getOrderProductVariant() as $opv)
  962.         {
  963.             if (strpos(strtolower($opv->getProductVariant()->getTradeName()), 'abonament roczny') !== false)
  964.             {
  965.                 return true;
  966.             }
  967.         }
  968.         return false;
  969.     }
  970.     public function getNewOrdersCreatedFromTrial(): ?Orders
  971.     {
  972.         return $this->newOrdersCreatedFromTrial;
  973.     }
  974.     public function setNewOrdersCreatedFromTrial(?Orders $newOrdersCreatedFromTrial): self
  975.     {
  976.         $this->newOrdersCreatedFromTrial $newOrdersCreatedFromTrial;
  977.         return $this;
  978.     }
  979.     /**
  980.      * @return Collection|CancellationFoResponse[]
  981.      */
  982.     public function getCancellationFoResponses(): Collection
  983.     {
  984.         return $this->cancellationFoResponses;
  985.     }
  986.     public function addCancellationFoResponse(CancellationFoResponse $cancellationFoResponse): self
  987.     {
  988.         if (!$this->cancellationFoResponses->contains($cancellationFoResponse)) {
  989.             $this->cancellationFoResponses[] = $cancellationFoResponse;
  990.             $cancellationFoResponse->setOrderPart($this);
  991.         }
  992.         return $this;
  993.     }
  994.     public function removeCancellationFoResponse(CancellationFoResponse $cancellationFoResponse): self
  995.     {
  996.         if ($this->cancellationFoResponses->contains($cancellationFoResponse)) {
  997.             $this->cancellationFoResponses->removeElement($cancellationFoResponse);
  998.             // set the owning side to null (unless already changed)
  999.             if ($cancellationFoResponse->getOrderPart() === $this) {
  1000.                 $cancellationFoResponse->setOrderPart(null);
  1001.             }
  1002.         }
  1003.         return $this;
  1004.     }
  1005.     /**
  1006.      * @return Collection|VirtualCurrencyTransaction[]
  1007.      */
  1008.     public function getVirtualCurrencyTransactions(): Collection
  1009.     {
  1010.         return $this->virtualCurrencyTransactions;
  1011.     }
  1012.     public function addVirtualCurrencyTransaction(VirtualCurrencyTransaction $virtualCurrencyTransaction): self
  1013.     {
  1014.         if (!$this->virtualCurrencyTransactions->contains($virtualCurrencyTransaction)) {
  1015.             $this->virtualCurrencyTransactions[] = $virtualCurrencyTransaction;
  1016.             $virtualCurrencyTransaction->setOrderPart($this);
  1017.         }
  1018.         return $this;
  1019.     }
  1020.     public function removeVirtualCurrencyTransaction(VirtualCurrencyTransaction $virtualCurrencyTransaction): self
  1021.     {
  1022.         if ($this->virtualCurrencyTransactions->contains($virtualCurrencyTransaction)) {
  1023.             $this->virtualCurrencyTransactions->removeElement($virtualCurrencyTransaction);
  1024.             // set the owning side to null (unless already changed)
  1025.             if ($virtualCurrencyTransaction->getOrderPart() === $this) {
  1026.                 $virtualCurrencyTransaction->setOrderPart(null);
  1027.             }
  1028.         }
  1029.         return $this;
  1030.     }
  1031.     public function getIsPaid(): ?bool
  1032.     {
  1033.         return $this->isPaid;
  1034.     }
  1035.     public function setIsPaid(bool $isPaid): self
  1036.     {
  1037.         $this->isPaid $isPaid;
  1038.         return $this;
  1039.     }
  1040.     public function getPaymentVerifiedOn(): ?string
  1041.     {
  1042.         return $this->paymentVerifiedOn;
  1043.     }
  1044.     public function setPaymentVerifiedOn(?string $paymentVerifiedOn): self
  1045.     {
  1046.         $this->paymentVerifiedOn $paymentVerifiedOn;
  1047.         return $this;
  1048.     }
  1049.     /**
  1050.      * @return Collection|UserCertificate[]
  1051.      */
  1052.     public function getUserCertificates(): Collection
  1053.     {
  1054.         return $this->userCertificates;
  1055.     }
  1056.     public function addUserCertificate(UserCertificate $userCertificate): self
  1057.     {
  1058.         if (!$this->userCertificates->contains($userCertificate)) {
  1059.             $this->userCertificates[] = $userCertificate;
  1060.             $userCertificate->setOrderPart($this);
  1061.         }
  1062.         return $this;
  1063.     }
  1064.     public function removeUserCertificate(UserCertificate $userCertificate): self
  1065.     {
  1066.         if ($this->userCertificates->contains($userCertificate)) {
  1067.             $this->userCertificates->removeElement($userCertificate);
  1068.             // set the owning side to null (unless already changed)
  1069.             if ($userCertificate->getOrderPart() === $this) {
  1070.                 $userCertificate->setOrderPart(null);
  1071.             }
  1072.         }
  1073.         return $this;
  1074.     }
  1075.     /**
  1076.      * @return Collection|NewCardTokenRequest[]
  1077.      */
  1078.     public function getNewCardTokenRequests(): Collection
  1079.     {
  1080.         return $this->newCardTokenRequests;
  1081.     }
  1082.     public function addNewCardTokenRequest(NewCardTokenRequest $newCardTokenRequest): self
  1083.     {
  1084.         if (!$this->newCardTokenRequests->contains($newCardTokenRequest)) {
  1085.             $this->newCardTokenRequests[] = $newCardTokenRequest;
  1086.             $newCardTokenRequest->setOrderPart($this);
  1087.         }
  1088.         return $this;
  1089.     }
  1090.     public function removeNewCardTokenRequest(NewCardTokenRequest $newCardTokenRequest): self
  1091.     {
  1092.         if ($this->newCardTokenRequests->contains($newCardTokenRequest)) {
  1093.             $this->newCardTokenRequests->removeElement($newCardTokenRequest);
  1094.             // set the owning side to null (unless already changed)
  1095.             if ($newCardTokenRequest->getOrderPart() === $this) {
  1096.                 $newCardTokenRequest->setOrderPart(null);
  1097.             }
  1098.         }
  1099.         return $this;
  1100.     }
  1101.     public function getAudiotekaCoupon(): ?CouponAudioteka
  1102.     {
  1103.         return $this->audiotekaCoupon;
  1104.     }
  1105.     public function setAudiotekaCoupon(?CouponAudioteka $coupon): self
  1106.     {
  1107.         $this->audiotekaCoupon $coupon;
  1108.         return $this;
  1109.     }
  1110.     public function getBufferedShopOrderPart(): ?BufferedShopOrderPart
  1111.     {
  1112.         return $this->bufferedShopOrderPart;
  1113.     }
  1114.     public function setBufferedShopOrderPart(?BufferedShopOrderPart $bufferedShopOrderPart): self
  1115.     {
  1116.         $this->bufferedShopOrderPart $bufferedShopOrderPart;
  1117.         return $this;
  1118.     }
  1119.     /**
  1120.      * @ORM\PreFlush
  1121.      */
  1122.     public function setBufferedShopEligibility(): void
  1123.     {
  1124.         $isEligible str_starts_with($this->ordTran ?? '''WF') && $this->totalPriceGross 0;
  1125.         $this->bufferedShopOrderPart->setIsEligible($isEligible);
  1126.     }
  1127.     /**
  1128.      * @ORM\PreFlush
  1129.      */
  1130.     public function setBufferedShopPriority(): void
  1131.     {
  1132.         /** @var OrderProductVariant $orderProductVariant */
  1133.         foreach ($this->orderProductVariant as $orderProductVariant) {
  1134.             if ($orderProductVariant->hasEventInAWeek() === true) {
  1135.                 $this->bufferedShopOrderPart->setIsPriority(true);
  1136.                 return;
  1137.             }
  1138.         }
  1139.     }
  1140.     public function getClosestEventDate(): ?\DateTimeInterface
  1141.     {
  1142.         $closestEventDate null;
  1143.         /** @var OrderProductVariant $orderProductVariant */
  1144.         foreach ($this->orderProductVariant as $orderProductVariant) {
  1145.             if ($orderProductVariant->getEvent() instanceof Events) {
  1146.                 $eventDate $orderProductVariant->getEvent()->getStartAt();
  1147.                 if ($closestEventDate === null || $eventDate $closestEventDate) {
  1148.                     $closestEventDate $eventDate;
  1149.                 }
  1150.             }
  1151.         }
  1152.         return $closestEventDate;
  1153.     }
  1154.     public function getBufferedShopChangeLogs(): Collection
  1155.     {
  1156.         return $this->bufferedShopChangeLogs;
  1157.     }
  1158. }