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