src/Entity/Gos/BaseCoupon.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\MappedSuperclass()
  8.  */
  9. class BaseCoupon
  10. {
  11.     /**
  12.      * @var int
  13.      *
  14.      * @ORM\Column(name="id", type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     protected $id;
  19.     /**
  20.      * @var bool
  21.      *
  22.      * @ORM\Column(name="isActive", type="boolean")
  23.      */
  24.     protected $isActive true;
  25.     /**
  26.      * @var bool
  27.      *
  28.      * @ORM\Column(type="boolean", nullable=true)
  29.      */
  30.     protected $isGross;
  31.     /**
  32.      * @ORM\Column(type="boolean", nullable=true)
  33.      */
  34.     protected $isUserAssigned;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\User", inversedBy="assignedCoupons")
  37.      */
  38.     protected $user;
  39.     /**
  40.      * @ORM\Column(type="float", precision=10, scale=2, nullable=true)
  41.      */
  42.     protected $discount;
  43.     /**
  44.      * @ORM\Column(type="integer")
  45.      */
  46.     protected $maximumQuantityUse;
  47.     /**
  48.      * @ORM\Column(type="integer")
  49.      */
  50.     protected $usedCodes 0;
  51.     /**
  52.      * @ORM\Column(type="datetime")
  53.      */
  54.     protected $dateFrom;
  55.     /**
  56.      * @ORM\Column(type="datetime")
  57.      */
  58.     protected $dateTo;
  59.     /**
  60.      * @ORM\Column(type="string", length=8, nullable=true)
  61.      */
  62.     protected $actionNumber;
  63.     /**
  64.      * @ORM\Column(type="string", length=100, nullable=true)
  65.      */
  66.     protected $fromSource;
  67.     /**
  68.      * @ORM\Column(type="string", length=100, nullable=true)
  69.      */
  70.     protected $campaign;
  71.     /**
  72.      * @ORM\Column(type="string", length=100, nullable=true)
  73.      */
  74.     protected $campaignChannel;
  75.     /**
  76.      * @var string
  77.      *
  78.      * @ORM\Column(name="description", type="text", nullable=true)
  79.      */
  80.     protected $description;
  81.     /**
  82.      * @ORM\Column(type="text", nullable=true)
  83.      */
  84.     protected $comment;
  85.     /**
  86.      * @var float
  87.      *
  88.      * @ORM\Column(type="float", precision=18, scale=2, nullable=true)
  89.      */
  90.     protected $gratisPriceNet;
  91.     /**
  92.      * @var float
  93.      *
  94.      * @ORM\Column(type="float", precision=18, scale=2, nullable=true)
  95.      */
  96.     protected $gratisPriceGross;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity="ProductAssociation", mappedBy="couponDefault")
  99.      */
  100.     protected $productAssociation;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Cart", mappedBy="coupon")
  103.      */
  104.     protected $cart;
  105.     /**
  106.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Cart", mappedBy="coupons")
  107.      */
  108.     protected $carts;
  109.     /**
  110.      * @ORM\OneToMany(targetEntity="ProductCart", mappedBy="coupon")
  111.      */
  112.     protected $productCart;
  113.     /**
  114.      * @ORM\ManyToMany(targetEntity="ProductCart", inversedBy="coupons")
  115.      */
  116.     protected $productCarts;
  117.     /**
  118.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\CouponPending", mappedBy="coupon")
  119.      */
  120.     protected $couponPending;
  121.     /**
  122.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\CouponType", inversedBy="coupon")
  123.      */
  124.     protected $couponType;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\CouponPackProduct", mappedBy="coupon", orphanRemoval=true, cascade={"persist"})
  127.      */
  128.     protected $couponPackProducts;
  129.     /**
  130.      * @ORM\Column(type="boolean", options={"default": false})
  131.      */
  132.     protected $isBundle false;
  133.     /**
  134.      * @ORM\Column(type="boolean", options={"default": false})
  135.      */
  136.     protected $isWholeBundleRequired false;
  137.     /**
  138.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Alert", mappedBy="coupon")
  139.      */
  140.     protected $alerts;
  141.     /**
  142.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ClientType", inversedBy="coupons")
  143.      */
  144.     protected $clientType;
  145.     /**
  146.      * @ORM\OneToOne(targetEntity="Gift", mappedBy="giftDiscountCode")
  147.      */
  148.     protected $gift;
  149.     /**
  150.      * @ORM\Column(type="boolean", nullable=true)
  151.      */
  152.     protected $generatedWithCoupon;
  153.     /**
  154.      * @ORM\Column(type="string", length=100, nullable=true)
  155.      */
  156.     protected $nameGeneratedCoupon;
  157.     /**
  158.      * @ORM\Column(type="boolean", nullable=true, options={"default":0})
  159.      */
  160.     protected $isCascade;
  161.     /**
  162.      * @ORM\OneToOne(targetEntity="CouponCascadeSettings", mappedBy="coupon", cascade={"persist"})
  163.      */
  164.     protected $cascadeSettings;
  165.     /**
  166.      * @ORM\Column(type="datetime")
  167.      */
  168.     protected $createdAt;
  169.     /**
  170.      * @ORM\Column(type="datetime", nullable=true)
  171.      */
  172.     protected $updatedAt;
  173.     /**
  174.      * @ORM\Column(type="boolean", nullable=true, options={"default":0})
  175.      */
  176.     protected $freeShippingCost 0;
  177.     /**
  178.      * @var bool
  179.      *
  180.      * @ORM\Column(type="boolean", nullable=true, options={"default": false})
  181.      */
  182.     protected $isAutoGenerated false;
  183.     /**
  184.      * @ORM\Column(type="boolean", nullable=true, options={"default": false})
  185.      */
  186.     private $isApplicationCode;
  187.     /**
  188.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ApplicationCoupon", inversedBy="coupon", cascade={"persist"})
  189.      * @ORM\JoinColumn()
  190.      */
  191.     private $applicationCoupon;
  192.     /**
  193.      * @ORM\Column(type="boolean", nullable=true)
  194.      */
  195.     private $forTele;
  196.     /**
  197.      * @ORM\ManyToOne(targetEntity=User::class)
  198.      */
  199.     private $createdBy;
  200.     /**
  201.      * @ORM\Column(type="boolean", options={"default": false})
  202.      */
  203.     protected $isPostageCostOnePLN false;
  204.     /**
  205.      * @var string
  206.      *
  207.      * @ORM\Column(type="text", nullable=true)
  208.      */
  209.     protected $customPromo1;
  210.     /**
  211.      * @var string
  212.      *
  213.      * @ORM\Column(type="text", nullable=true)
  214.      */
  215.     protected $customPromo2;
  216.     /** @ORM\PrePersist() */
  217.     public function prePersist()
  218.     {
  219.         $this->createdAt = new \DateTime();
  220.     }
  221.     /** @ORM\PreUpdate() */
  222.     public function preUpdate()
  223.     {
  224.         $this->updatedAt = new \DateTime();
  225.     }
  226.     public function __toString()
  227.     {
  228.         return (string)$this->code;
  229.     }
  230.     public function getObjectVars()
  231.     {
  232.         return get_object_vars($this);
  233.     }
  234.     public function isInProductVariantList(Array $productVariantList)
  235.     {
  236.         foreach($this->getProductVariant() as $productVariant)
  237.         {
  238.             if ( \in_array($productVariant->getProductVariantNoComplete(), $productVariantList))
  239.             {
  240.                 return true;
  241.             }
  242.         }
  243.         return false;
  244.     }
  245.     public function isValid(): bool
  246.     {
  247.         $dateNow = (new \DateTime())->format('Y-m-d H:i:s');
  248.         if ($this->getDateFrom()->format('Y-m-d H:i:s') <= $dateNow
  249.            && $this->getDateTo()->format('Y-m-d H:i:s') >= $dateNow
  250.            && $this->isActive)
  251.         {
  252.             return true;
  253.         }
  254.         return false;
  255.     }
  256.     /**
  257.      * Constructor
  258.      */
  259.     public function __construct()
  260.     {
  261.         $this->cart               = new ArrayCollection();
  262.         $this->couponPending      = new ArrayCollection();
  263.         $this->couponPackProducts = new ArrayCollection();
  264.         $this->alerts             = new ArrayCollection();
  265.         $this->productAssociation = new ArrayCollection();
  266.         $this->productCart        = new ArrayCollection();
  267.         $this->carts              = new ArrayCollection();
  268.         $this->productCarts       = new ArrayCollection();
  269.         $this->dateFrom           = new \DateTime();
  270.         $this->dateTo             = new \DateTime("+ 1 month");
  271.     }
  272.     /**
  273.      * Get id
  274.      *
  275.      * @return integer
  276.      */
  277.     public function getId()
  278.     {
  279.         return $this->id;
  280.     }
  281.     /**
  282.      * Set isActive
  283.      *
  284.      * @param boolean $isActive
  285.      *
  286.      * @return Coupon
  287.      */
  288.     public function setIsActive($isActive)
  289.     {
  290.         $this->isActive $isActive;
  291.         return $this;
  292.     }
  293.     /**
  294.      * Get isActive
  295.      *
  296.      * @return boolean
  297.      */
  298.     public function getIsActive()
  299.     {
  300.         return $this->isActive;
  301.     }
  302.     /**
  303.      * Set code
  304.      *
  305.      * @param string $code
  306.      *
  307.      * @return Coupon
  308.      */
  309.     public function setCode($code)
  310.     {
  311.         $this->code $code;
  312.         return $this;
  313.     }
  314.     /**
  315.      * Get code
  316.      *
  317.      * @return string
  318.      */
  319.     public function getCode()
  320.     {
  321.         return $this->code;
  322.     }
  323.     /**
  324.      * Set discount
  325.      *
  326.      * @param float $discount
  327.      *
  328.      * @return Coupon
  329.      */
  330.     public function setDiscount($discount)
  331.     {
  332.         $this->discount $discount;
  333.         return $this;
  334.     }
  335.     /**
  336.      * Get discount
  337.      *
  338.      * @return float
  339.      */
  340.     public function getDiscount()
  341.     {
  342.         return $this->discount;
  343.     }
  344.     /**
  345.      * Set maximumQuantityUse
  346.      *
  347.      * @param integer $maximumQuantityUse
  348.      *
  349.      * @return Coupon
  350.      */
  351.     public function setMaximumQuantityUse($maximumQuantityUse)
  352.     {
  353.         $this->maximumQuantityUse $maximumQuantityUse;
  354.         return $this;
  355.     }
  356.     /**
  357.      * Get maximumQuantityUse
  358.      *
  359.      * @return integer
  360.      */
  361.     public function getMaximumQuantityUse()
  362.     {
  363.         return $this->maximumQuantityUse;
  364.     }
  365.     /**
  366.      * Set usedCodes
  367.      *
  368.      * @param integer $usedCodes
  369.      *
  370.      * @return Coupon
  371.      */
  372.     public function setUsedCodes($usedCodes)
  373.     {
  374.         $this->usedCodes $usedCodes;
  375.         return $this;
  376.     }
  377.     /**
  378.      * Get usedCodes
  379.      *
  380.      * @return integer
  381.      */
  382.     public function getUsedCodes()
  383.     {
  384.         return $this->usedCodes;
  385.     }
  386.     /**
  387.      * Set dateFrom
  388.      *
  389.      * @param \DateTime $dateFrom
  390.      *
  391.      * @return Coupon
  392.      */
  393.     public function setDateFrom($dateFrom)
  394.     {
  395.         $this->dateFrom $dateFrom;
  396.         return $this;
  397.     }
  398.     /**
  399.      * Get dateFrom
  400.      *
  401.      * @return \DateTime
  402.      */
  403.     public function getDateFrom()
  404.     {
  405.         return $this->dateFrom;
  406.     }
  407.     /**
  408.      * Set dateTo
  409.      *
  410.      * @param \DateTime $dateTo
  411.      *
  412.      * @return Coupon
  413.      */
  414.     public function setDateTo($dateTo)
  415.     {
  416.         $this->dateTo $dateTo;
  417.         return $this;
  418.     }
  419.     /**
  420.      * Get dateTo
  421.      *
  422.      * @return \DateTime
  423.      */
  424.     public function getDateTo()
  425.     {
  426.         return $this->dateTo;
  427.     }
  428.     /**
  429.      * Set description
  430.      *
  431.      * @param string $description
  432.      *
  433.      * @return Coupon
  434.      */
  435.     public function setDescription($description)
  436.     {
  437.         $this->description $description;
  438.         return $this;
  439.     }
  440.     /**
  441.      * Get description
  442.      *
  443.      * @return string
  444.      */
  445.     public function getDescription()
  446.     {
  447.         return $this->description;
  448.     }
  449.     /**
  450.      * Set createdAt
  451.      *
  452.      * @param \DateTime $createdAt
  453.      *
  454.      * @return Coupon
  455.      */
  456.     public function setCreatedAt($createdAt)
  457.     {
  458.         $this->createdAt $createdAt;
  459.         return $this;
  460.     }
  461.     /**
  462.      * Get createdAt
  463.      *
  464.      * @return \DateTime
  465.      */
  466.     public function getCreatedAt()
  467.     {
  468.         return $this->createdAt;
  469.     }
  470.     /**
  471.      * Set updatedAt
  472.      *
  473.      * @param \DateTime $updatedAt
  474.      *
  475.      * @return Coupon
  476.      */
  477.     public function setUpdatedAt($updatedAt)
  478.     {
  479.         $this->updatedAt $updatedAt;
  480.         return $this;
  481.     }
  482.     /**
  483.      * Get updatedAt
  484.      *
  485.      * @return \DateTime
  486.      */
  487.     public function getUpdatedAt()
  488.     {
  489.         return $this->updatedAt;
  490.     }
  491.     /**
  492.      * Add cart
  493.      *
  494.      * @param \App\Entity\Gos\Cart $cart
  495.      *
  496.      * @return Coupon
  497.      */
  498.     public function addCart(\App\Entity\Gos\Cart $cart)
  499.     {
  500.         $this->cart[] = $cart;
  501.         $this->addCarts($cart);
  502.         return $this;
  503.     }
  504.     /**
  505.      * Add carts
  506.      *
  507.      * @param \App\Entity\Gos\Cart $cart
  508.      *
  509.      * @return self
  510.      */
  511.     public function addCarts(\App\Entity\Gos\Cart $cart)
  512.     {
  513.         if (!$this->carts->contains($cart))
  514.         {
  515.             $this->carts->add($cart);
  516.         }
  517.         return $this;
  518.     }
  519.     /**
  520.      * Remove cart
  521.      *
  522.      * @param \App\Entity\Gos\Cart $cart
  523.      */
  524.     public function removeCart(\App\Entity\Gos\Cart $cart)
  525.     {
  526.         $this->cart->removeElement($cart);
  527.         $this->carts->removeElement($cart);
  528.     }
  529.     /**
  530.      * Remove carts
  531.      *
  532.      * @param \App\Entity\Gos\Cart $cart
  533.      *
  534.      * @return self
  535.      */
  536.     public function removeCarts(\App\Entity\Gos\Cart $cart)
  537.     {
  538.         $this->carts->removeElement($cart);
  539.         $this->cart->removeElement($cart);
  540.         return $this;
  541.     }
  542.     /**
  543.      * Get cart
  544.      *
  545.      * @return \Doctrine\Common\Collections\Collection
  546.      */
  547.     public function getCart()
  548.     {
  549.         return $this->cart;
  550.     }
  551.     /**
  552.      * Get carts
  553.      *
  554.      * @return \Doctrine\Common\Collections\Collection
  555.      */
  556.     public function getCarts()
  557.     {
  558.         return $this->carts;
  559.     }
  560.     /**
  561.      * Add couponPending
  562.      *
  563.      * @param \App\Entity\Gos\CouponPending $couponPending
  564.      *
  565.      * @return Coupon
  566.      */
  567.     public function addCouponPending(\App\Entity\Gos\CouponPending $couponPending)
  568.     {
  569.         $this->couponPending[] = $couponPending;
  570.         return $this;
  571.     }
  572.     /**
  573.      * Remove couponPending
  574.      *
  575.      * @param \App\Entity\Gos\CouponPending $couponPending
  576.      */
  577.     public function removeCouponPending(\App\Entity\Gos\CouponPending $couponPending)
  578.     {
  579.         $this->couponPending->removeElement($couponPending);
  580.     }
  581.     /**
  582.      * Get couponPending
  583.      *
  584.      * @return \Doctrine\Common\Collections\Collection
  585.      */
  586.     public function getCouponPending()
  587.     {
  588.         return $this->couponPending;
  589.     }
  590.     /**
  591.      * Set couponType
  592.      *
  593.      * @param \App\Entity\Gos\CouponType $couponType
  594.      *
  595.      * @return Coupon
  596.      */
  597.     public function setCouponType(\App\Entity\Gos\CouponType $couponType null)
  598.     {
  599.         $this->couponType $couponType;
  600.         return $this;
  601.     }
  602.     /**
  603.      * Get couponType
  604.      *
  605.      * @return \App\Entity\Gos\CouponType
  606.      */
  607.     public function getCouponType()
  608.     {
  609.         return $this->couponType;
  610.     }
  611.     /**
  612.      * Set actionNumber
  613.      *
  614.      * @param string $actionNumber
  615.      *
  616.      * @return Coupon
  617.      */
  618.     public function setActionNumber($actionNumber)
  619.     {
  620.         $this->actionNumber $actionNumber;
  621.         return $this;
  622.     }
  623.     /**
  624.      * Get actionNumber
  625.      *
  626.      * @return string
  627.      */
  628.     public function getActionNumber()
  629.     {
  630.         return $this->actionNumber;
  631.     }
  632.     /**
  633.      * Set fromSource
  634.      *
  635.      * @param string $fromSource
  636.      *
  637.      * @return Coupon
  638.      */
  639.     public function setFromSource($fromSource)
  640.     {
  641.         $this->fromSource $fromSource;
  642.         return $this;
  643.     }
  644.     /**
  645.      * Get fromSource
  646.      *
  647.      * @return string
  648.      */
  649.     public function getFromSource()
  650.     {
  651.         return $this->fromSource;
  652.     }
  653.     /**
  654.      * Set campaign
  655.      *
  656.      * @param string $campaign
  657.      *
  658.      * @return Coupon
  659.      */
  660.     public function setCampaign($campaign)
  661.     {
  662.         $this->campaign $campaign;
  663.         return $this;
  664.     }
  665.     /**
  666.      * Get campaign
  667.      *
  668.      * @return string
  669.      */
  670.     public function getCampaign()
  671.     {
  672.         return $this->campaign;
  673.     }
  674.     /**
  675.      * Set campaignChannel
  676.      *
  677.      * @param string $campaignChannel
  678.      *
  679.      * @return Coupon
  680.      */
  681.     public function setCampaignChannel($campaignChannel)
  682.     {
  683.         $this->campaignChannel $campaignChannel;
  684.         return $this;
  685.     }
  686.     /**
  687.      * Get campaignChannel
  688.      *
  689.      * @return string
  690.      */
  691.     public function getCampaignChannel()
  692.     {
  693.         return $this->campaignChannel;
  694.     }
  695.     /**
  696.      * Set isGross
  697.      *
  698.      * @param boolean $isGross
  699.      *
  700.      * @return Coupon
  701.      */
  702.     public function setIsGross($isGross)
  703.     {
  704.         $this->isGross $isGross;
  705.         return $this;
  706.     }
  707.     /**
  708.      * Get isGross
  709.      *
  710.      * @return boolean
  711.      */
  712.     public function getIsGross()
  713.     {
  714.         return $this->isGross;
  715.     }
  716.     /**
  717.      * Set isUserAssigned
  718.      *
  719.      * @param boolean $isUsedAssigned
  720.      *
  721.      * @return Coupon
  722.      */
  723.     public function setIsUserAssigned($isUsedAssigned)
  724.     {
  725.         $this->isUserAssigned $isUsedAssigned;
  726.         return $this;
  727.     }
  728.     /**
  729.      * Get isUserAssigned
  730.      *
  731.      * @return boolean
  732.      */
  733.     public function getIsUserAssigned()
  734.     {
  735.         return $this->isUserAssigned;
  736.     }
  737.     /**
  738.      * Set isBundle
  739.      *
  740.      * @param boolean $isBundle
  741.      * @return Coupon
  742.      */
  743.     public function setIsBundle($isBundle)
  744.     {
  745.         $this->isBundle $isBundle;
  746.         return $this;
  747.     }
  748.     /**
  749.      * Get isBundle
  750.      *
  751.      * @return boolean
  752.      */
  753.     public function getIsBundle()
  754.     {
  755.         return $this->isBundle;
  756.     }
  757.     /**
  758.      * Set isWholeBundleRequired
  759.      *
  760.      * @param boolean $isWholeBundleRequired
  761.      * @return Coupon
  762.      */
  763.     public function setIsWholeBundleRequired($isWholeBundleRequired)
  764.     {
  765.         $this->isWholeBundleRequired $isWholeBundleRequired;
  766.         return $this;
  767.     }
  768.     /**
  769.      * Get isWholeBundleRequired
  770.      *
  771.      * @return boolean
  772.      */
  773.     public function getIsWholeBundleRequired()
  774.     {
  775.         return $this->isWholeBundleRequired;
  776.     }
  777.     /**
  778.      * Set couponPackProducts
  779.      *
  780.      * @param \Doctrine\Common\Collections\Collection $couponPackProducts
  781.      * @return Coupon
  782.      */
  783.     public function setCouponPackProducts($couponPackProducts)
  784.     {
  785.         $this->couponPackProducts $couponPackProducts;
  786.         return $this;
  787.     }
  788.     /**
  789.      * Add couponPackProduct
  790.      *
  791.      * @param CouponPackProduct $couponPackProduct
  792.      * @return Coupon
  793.      */
  794.     public function addCouponPackProduct(\App\Entity\Gos\CouponPackProduct $couponPackProduct)
  795.     {
  796.         $couponPackProduct->setCoupon($this);
  797.         $this->couponPackProducts[] = $couponPackProduct;
  798.         return $this;
  799.     }
  800.     /**
  801.      * Remove couponPackProduct
  802.      *
  803.      * @param CouponPackProduct $couponPackProduct
  804.      * @return Coupon
  805.      */
  806.     public function removeCouponPackProduct(\App\Entity\Gos\CouponPackProduct $couponPackProduct)
  807.     {
  808.         $this->couponPackProducts->removeElement($couponPackProduct);
  809.         return $this;
  810.     }
  811.     /**
  812.      * Get couponPackProducts
  813.      *
  814.      * @return ArrayCollection
  815.      */
  816.     public function getCouponPackProducts()
  817.     {
  818.         return $this->couponPackProducts;
  819.     }
  820.     /**
  821.      * Set gratisPriceNet
  822.      *
  823.      * @param float $gratisPriceNet
  824.      *
  825.      * @return Coupon
  826.      */
  827.     public function setGratisPriceNet($gratisPriceNet)
  828.     {
  829.         $this->gratisPriceNet $gratisPriceNet;
  830.         return $this;
  831.     }
  832.     /**
  833.      * Get gratisPriceNet
  834.      *
  835.      * @return float
  836.      */
  837.     public function getGratisPriceNet()
  838.     {
  839.         return $this->gratisPriceNet;
  840.     }
  841.     /**
  842.      * Set gratisPriceGross
  843.      *
  844.      * @param float $gratisPriceGross
  845.      *
  846.      * @return Coupon
  847.      */
  848.     public function setGratisPriceGross($gratisPriceGross)
  849.     {
  850.         $this->gratisPriceGross $gratisPriceGross;
  851.         return $this;
  852.     }
  853.     /**
  854.      * Get gratisPriceGross
  855.      *
  856.      * @return float
  857.      */
  858.     public function getGratisPriceGross()
  859.     {
  860.         return $this->gratisPriceGross;
  861.     }
  862.     /**
  863.      * Set isAutoGenerated
  864.      *
  865.      * @param boolean $isAutoGenerated
  866.      *
  867.      * @return Coupon
  868.      */
  869.     public function setIsAutoGenerated($isAutoGenerated)
  870.     {
  871.         $this->isAutoGenerated $isAutoGenerated;
  872.         return $this;
  873.     }
  874.     /**
  875.      * Get isAutoGenerated
  876.      *
  877.      * @return boolean
  878.      */
  879.     public function getIsAutoGenerated()
  880.     {
  881.         return $this->isAutoGenerated;
  882.     }
  883.     public function getUser(): ?User
  884.     {
  885.         return $this->user;
  886.     }
  887.     public function setUser(?User $user): self
  888.     {
  889.         $this->user $user;
  890.         return $this;
  891.     }
  892.     /**
  893.      * @return Collection|Alert[]
  894.      */
  895.     public function getAlerts(): Collection
  896.     {
  897.         return $this->alerts;
  898.     }
  899.     public function addAlert(Alert $alert): self
  900.     {
  901.         if (!$this->alerts->contains($alert)) {
  902.             $this->alerts[] = $alert;
  903.             $alert->setCoupon($this);
  904.         }
  905.         return $this;
  906.     }
  907.     public function removeAlert(Alert $alert): self
  908.     {
  909.         if ($this->alerts->contains($alert)) {
  910.             $this->alerts->removeElement($alert);
  911.             // set the owning side to null (unless already changed)
  912.             if ($alert->getCoupon() === $this) {
  913.                 $alert->setCoupon(null);
  914.             }
  915.         }
  916.         return $this;
  917.     }
  918.     public function getUsesLeft(): int
  919.     {
  920.         if ($this->maximumQuantityUse == 0)
  921.         {
  922.             return 999;
  923.         }
  924.         return $this->maximumQuantityUse abs($this->usedCodes);
  925.     }
  926.     public function getStatus(): int
  927.     {
  928.         if ($this->dateTo < new \DateTime())
  929.             return 2;
  930.         elseif ($this->dateFrom > new \DateTime())
  931.             return 3;
  932.         else
  933.             return 1;
  934.     }
  935.     /**
  936.      * @return Collection|ProductAssociation[]
  937.      */
  938.     public function getProductAssociation(): Collection
  939.     {
  940.         return $this->productAssociation;
  941.     }
  942.     public function addProductAssociation(ProductAssociation $productAssociation): self
  943.     {
  944.         if (!$this->productAssociation->contains($productAssociation)) {
  945.             $this->productAssociation[] = $productAssociation;
  946.             $productAssociation->setCouponDefault($this);
  947.         }
  948.         return $this;
  949.     }
  950.     public function removeProductAssociation(ProductAssociation $productAssociation): self
  951.     {
  952.         if ($this->productAssociation->contains($productAssociation)) {
  953.             $this->productAssociation->removeElement($productAssociation);
  954.             // set the owning side to null (unless already changed)
  955.             if ($productAssociation->getCouponDefault() === $this) {
  956.                 $productAssociation->setCouponDefault(null);
  957.             }
  958.         }
  959.         return $this;
  960.     }
  961.     public function getClientType(): ?ClientType
  962.     {
  963.         return $this->clientType;
  964.     }
  965.     public function setClientType(?ClientType $clientType): self
  966.     {
  967.         $this->clientType $clientType;
  968.         return $this;
  969.     }
  970.     public function getGift(): ?Gift
  971.     {
  972.         return $this->gift;
  973.     }
  974.     public function setGift(?Gift $gift): self
  975.     {
  976.         $this->gift $gift;
  977.         // set (or unset) the owning side of the relation if necessary
  978.         $newGiftDiscountCode $gift === null null $this;
  979.         if ($newGiftDiscountCode !== $gift->getGiftDiscountCode()) {
  980.             $gift->setGiftDiscountCode($newGiftDiscountCode);
  981.         }
  982.         return $this;
  983.     }
  984.     /**
  985.      * Set generatedWithCoupon
  986.      *
  987.      * @param boolean $generatedWithCoupon
  988.      *
  989.      * @return Coupon
  990.      */
  991.     public function setGeneratedWithCoupon($generatedWithCoupon)
  992.     {
  993.         $this->generatedWithCoupon $generatedWithCoupon;
  994.         return $this;
  995.     }
  996.     /**
  997.      * Get generatedWithCoupon
  998.      *
  999.      * @return boolean
  1000.      */
  1001.     public function getGeneratedWithCoupon()
  1002.     {
  1003.         return $this->generatedWithCoupon;
  1004.     }
  1005.     /**
  1006.      * Set nameGeneratedCoupon
  1007.      *
  1008.      * @param string nameGeneratedCoupon
  1009.      *
  1010.      * @return Coupon
  1011.      */
  1012.     public function setNameGeneratedCoupon($nameGeneratedCoupon)
  1013.     {
  1014.         $this->nameGeneratedCoupon $nameGeneratedCoupon;
  1015.         return $this;
  1016.     }
  1017.     /**
  1018.      * Get nameGeneratedCoupon
  1019.      *
  1020.      * @return string
  1021.      */
  1022.     public function getNameGeneratedCoupon()
  1023.     {
  1024.         return $this->nameGeneratedCoupon;
  1025.     }
  1026.     public function getComment(): ?string
  1027.     {
  1028.         return $this->comment;
  1029.     }
  1030.     public function setComment(?string $comment): self
  1031.     {
  1032.         $this->comment $comment;
  1033.         return $this;
  1034.     }
  1035.     /**
  1036.      * @return Collection|ProductCart[]
  1037.      */
  1038.     public function getProductCart(): Collection
  1039.     {
  1040.         return $this->productCart;
  1041.     }
  1042.     /**
  1043.      * @return Collection|ProductCart[]
  1044.      */
  1045.     public function getProductCarts(): Collection
  1046.     {
  1047.         return $this->productCarts;
  1048.     }
  1049.     public function addProductCart(ProductCart $productCart): self
  1050.     {
  1051.         if (!$this->productCart->contains($productCart)) {
  1052.             $this->productCarts[] = $productCart;
  1053.         }
  1054.         if (!$this->productCarts->contains($productCart)) {
  1055.             $this->productCarts->add($productCart);
  1056.         }
  1057.         return $this;
  1058.     }
  1059.     public function addProductCarts(ProductCart $productCart): self
  1060.     {
  1061.         if (!$this->productCarts->contains($productCart)) {
  1062.             $this->productCarts->add($productCart);
  1063.         }
  1064.         return $this;
  1065.     }
  1066.     public function removeProductCart(ProductCart $productCart): self
  1067.     {
  1068.         if ($this->productCart->contains($productCart)) {
  1069.             $this->productCart->removeElement($productCart);
  1070.         }
  1071.         if ($this->productCarts->contains($productCart)) {
  1072.             $this->productCarts->removeElement($productCart);
  1073.         }
  1074.         return $this;
  1075.     }
  1076.     public function removeProductCarts(ProductCart $productCart): self
  1077.     {
  1078.         if ($this->productCarts->contains($productCart)) {
  1079.             $this->productCarts->removeElement($productCart);
  1080.         }
  1081.         return $this;
  1082.     }
  1083.     public function getIsCascade(): ?bool
  1084.     {
  1085.         return $this->isCascade;
  1086.     }
  1087.     public function setIsCascade(?bool $isCascade): self
  1088.     {
  1089.         $this->isCascade $isCascade;
  1090.         return $this;
  1091.     }
  1092.     public function getCascadeSettings(): ?CouponCascadeSettings
  1093.     {
  1094.         return $this->cascadeSettings;
  1095.     }
  1096.     public function setCascadeSettings(?CouponCascadeSettings $cascadeSettings): self
  1097.     {
  1098.         $this->cascadeSettings $cascadeSettings;
  1099.         // set (or unset) the owning side of the relation if necessary
  1100.         $newCoupon $cascadeSettings === null null $this;
  1101.         if ($newCoupon !== $cascadeSettings->getCoupon()) {
  1102.             $cascadeSettings->setCoupon($newCoupon);
  1103.         }
  1104.         return $this;
  1105.     }
  1106.     public function getFreeShippingCost() :bool
  1107.     {
  1108.         if ($this->freeShippingCost == null)
  1109.         {
  1110.             $this->freeShippingCost 0;
  1111.         }
  1112.         return $this->freeShippingCost;
  1113.     }
  1114.     public function setFreeShippingCost(?bool $freeShippingCost) :self
  1115.     {
  1116.         $this->freeShippingCost $freeShippingCost;
  1117.         return $this;
  1118.     }
  1119.     public function getisApplicationCode(): ?bool
  1120.     {
  1121.         return $this->isApplicationCode;
  1122.     }
  1123.     public function setIsApplicationCode(bool $isApplicationCode): self
  1124.     {
  1125.         $this->isApplicationCode $isApplicationCode;
  1126.         return $this;
  1127.     }
  1128.     public function getApplicationCoupon(): ?ApplicationCoupon
  1129.     {
  1130.         return $this->applicationCoupon;
  1131.     }
  1132.     public function setApplicationCoupon(?ApplicationCoupon $applicationCoupon): self
  1133.     {
  1134.         $this->applicationCoupon $applicationCoupon;
  1135.         return $this;
  1136.     }
  1137.     public function getForTele(): ?bool
  1138.     {
  1139.         return $this->forTele;
  1140.     }
  1141.     public function setForTele(?bool $forTele): self
  1142.     {
  1143.         $this->forTele $forTele;
  1144.         return $this;
  1145.     }
  1146.     public function getCreatedBy(): ?User
  1147.     {
  1148.         return $this->createdBy;
  1149.     }
  1150.     public function setCreatedBy(?User $createdBy): self
  1151.     {
  1152.         $this->createdBy $createdBy;
  1153.         return $this;
  1154.     }
  1155.     public function getIsPostageCostOnePLN(): ?bool
  1156.     {
  1157.         return $this->isPostageCostOnePLN;
  1158.     }
  1159.     public function setIsPostageCostOnePLN(bool $isPostageCostOnePLN): self
  1160.     {
  1161.         $this->isPostageCostOnePLN $isPostageCostOnePLN;
  1162.         return $this;
  1163.     }
  1164.     public function getCustomPromo1(): ?string
  1165.     {
  1166.         return $this->customPromo1;
  1167.     }
  1168.     public function setCustomPromo1(?string $customPromo1): self
  1169.     {
  1170.         $this->customPromo1 $customPromo1;
  1171.         return $this;
  1172.     }
  1173.     public function getCustomPromo2(): ?string
  1174.     {
  1175.         return $this->customPromo2;
  1176.     }
  1177.     public function setCustomPromo2(?string $customPromo2): self
  1178.     {
  1179.         $this->customPromo2 $customPromo2;
  1180.         return $this;
  1181.     }
  1182. }