src/Entity/Gos/OrderPart.php line 20

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