src/Entity/Gos/OrderPart.php line 22

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