src/AtechNet/CoreBundle/Entity/Domain.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use App\AtechNet\CoreBundle\Helper\VAT;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping\Column;
  6. use Doctrine\ORM\Mapping\Entity;
  7. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  8. use Doctrine\ORM\Mapping\JoinColumn;
  9. use Doctrine\ORM\Mapping\ManyToOne;
  10. use Doctrine\ORM\Mapping\OneToMany;
  11. use Doctrine\ORM\Mapping\OrderBy;
  12. use Doctrine\ORM\Mapping\Table as Table;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15.  * Domain
  16.  *
  17.  * @Table(name="domains")
  18.  * @Entity(repositoryClass="App\AtechNet\CoreBundle\Repository\DomainRepository")
  19.  * @HasLifecycleCallbacks
  20.  */
  21. class Domain extends AbstractSortableEntity
  22. {
  23.     public const string TYPE_RETAIL = 'retail';
  24.     public const string TYPE_WHOLESALE = 'wholesale';
  25.     public const string TYPE_OTHER = 'other';
  26.     public const string TYPE_EXPORT = 'export';
  27.     public const string WARRANTY_12 = '12';
  28.     public const string WARRANTY_24 = '24';
  29.     public const string WARRANTY_36 = '36';
  30.     public const int HU_VAT_CHANGE_DATE = 201711051720; // Date format: YmdHi
  31.     public const int HU_VAT_CHANGE_BACK_DATE = 202501010000; // Date format: YmdHi
  32.     public const int CZ_VAT_CHANGE_DATE = 202107010000;
  33.     public const int SK_VAT_CHANGE_DATE = 202501010000;
  34.     public const DOMAIN_IDS_FOR_ACTIVE_CAMPAIGN = [1, 2, 3, 4, 5, 9, 8, 7];
  35.     public const DOMAINS_WITH_WEBSITE = [
  36.         1, 2, 3, 4, 5, 7, 9, 11
  37.     ];
  38.     public const DOMAINS_FOR_QUALITY_RESULT_FILTER = [
  39.         1, 2, 3, 4, 5, 7, 9, 10, 11
  40.     ];
  41.     public const WS_DOMAINS_WITH_WEBSITE = [
  42.         2,
  43.         4,
  44.         5,
  45.         7,
  46.     ];
  47.     public const DOMAINS_WITH_WEBSITE_WITHOUT_WS = [
  48.         1,
  49.         3,
  50.         9,
  51.         11
  52.     ];
  53.     public const int DOMAIN_ID_RT_SK = 1;
  54.     public const int DOMAIN_ID_WS_SK = 2;
  55.     public const int DOMAIN_ID_RT_HU = 3;
  56.     public const int DOMAIN_ID_WS_HU = 4;
  57.     public const int DOMAIN_ID_WS_CZ = 5;
  58.     public const int DOMAIN_ID_RT_CZ = 9;
  59.     public const int DOMAIN_ID_PC_SHOP = 6;
  60.     public const int DOMAIN_ID_WS_EU = 7;
  61.     public const int DOMAIN_ID_OTHER = 8;
  62.     public const int DOMAIN_ID_B2C_EU = 10;
  63.     public const int DOMAIN_ID_RT_EU = 11;
  64.     public const int DOMAIN_ID_B2C_CH = 12;
  65.     public const int DOMAIN_ID_B2C_GB = 13;
  66.     public const string CURRENCY_EUR = '€';
  67.     public const string CURRENCY_HUF = 'Ft';
  68.     public const string CURRENCY_CZK = 'Kč';
  69.     public const string CURRENCY_CHF = 'CHF';
  70.     public const string CURRENCY_GBP = '£';
  71.     public static function getWarrantyChoices(): array
  72.     {
  73.         return [
  74.             self::WARRANTY_24 => self::WARRANTY_24,
  75.             self::WARRANTY_12 => self::WARRANTY_12,
  76.             self::WARRANTY_36 => self::WARRANTY_36,
  77.         ];
  78.     }
  79.     /**
  80.      * @return int[]
  81.      */
  82.     public static function getRetailWholesaleDomainPairs(): array
  83.     {
  84.         return [
  85.             1 => 2,
  86.             2 => 1,
  87.             3 => 4,
  88.             4 => 3,
  89.             5 => 9,
  90.             9 => 5,
  91.             7 => 11,
  92.             11 => 7,
  93.         ];
  94.     }
  95.     /**
  96.      * @return string[]
  97.      */
  98.     public static function getCurrencyChoices(): array
  99.     {
  100.         return [
  101.             self::CURRENCY_EUR,
  102.             self::CURRENCY_HUF,
  103.             self::CURRENCY_CZK,
  104.             self::CURRENCY_CHF,
  105.             self::CURRENCY_GBP,
  106.         ];
  107.     }
  108.     public static function getDomainCodeByDomainId()
  109.     {
  110.         return [
  111.             self::DOMAIN_ID_RT_SK => 'sk',
  112.             self::DOMAIN_ID_WS_SK => 'sk',
  113.             self::DOMAIN_ID_RT_HU => 'hu',
  114.             self::DOMAIN_ID_WS_HU => 'hu',
  115.             self::DOMAIN_ID_RT_CZ => 'cz',
  116.             self::DOMAIN_ID_WS_CZ => 'cz',
  117.             self::DOMAIN_ID_RT_EU => 'eu',
  118.             self::DOMAIN_ID_WS_EU => 'eu',
  119.         ];
  120.     }
  121.     /**
  122.      * @param int $rtDomain
  123.      * @return int
  124.      */
  125.     public static function getWSdomainForRt(int $rtDomain): int
  126.     {
  127.         return match ($rtDomain) {
  128.             self::DOMAIN_ID_RT_SK => self::DOMAIN_ID_WS_SK,
  129.             self::DOMAIN_ID_RT_HU => self::DOMAIN_ID_WS_HU,
  130.             self::DOMAIN_ID_RT_CZ => self::DOMAIN_ID_WS_CZ,
  131.             self::DOMAIN_ID_RT_EU => self::DOMAIN_ID_WS_EU,
  132.         };
  133.     }
  134.     /**
  135.      * @var Language
  136.      *
  137.      * @Assert\NotNull
  138.      *
  139.      * @ManyToOne(targetEntity="Language")
  140.      * @JoinColumn(name="language_id", referencedColumnName="id")
  141.      */
  142.     private $language;
  143.     /**
  144.      * @var Company
  145.      *
  146.      * @Assert\NotNull
  147.      *
  148.      * @ManyToOne(targetEntity="Company")
  149.      * @JoinColumn(name="company_id", referencedColumnName="id")
  150.      */
  151.     private $company;
  152.     /**
  153.      * @var string
  154.      *
  155.      * @Assert\NotNull
  156.      *
  157.      * @Column(name="type", type="text")
  158.      */
  159.     private $type;
  160.     /**
  161.      * @var string
  162.      *
  163.      * @Assert\NotNull
  164.      *
  165.      * @Column(name="name", type="text")
  166.      */
  167.     private $name;
  168.     /**
  169.      * @var string
  170.      *
  171.      * @Assert\NotNull
  172.      *
  173.      * @Column(name="currency", type="text")
  174.      */
  175.     private $currency;
  176.     /**
  177.      * @var float
  178.      *
  179.      * @Assert\NotNull
  180.      *
  181.      * @Column(name="price_factor", type="float")
  182.      */
  183.     private $priceFactor = 1;
  184.     /**
  185.      * @var int
  186.      *
  187.      * @Assert\NotNull
  188.      *
  189.      * @Column(name="price_precision", type="decimal")
  190.      */
  191.     private $pricePrecision = 2;
  192.     /**
  193.      * @var float
  194.      *
  195.      * @Assert\NotNull
  196.      *
  197.      * @Column(name="price_end", type="float")
  198.      */
  199.     private $priceEnd;
  200.     /**
  201.      * @var float
  202.      *
  203.      * @Assert\NotNull
  204.      *
  205.      * @Column(name="price_end2", type="float")
  206.      */
  207.     private $priceEnd2;
  208.     /**
  209.      * @var float
  210.      *
  211.      * @Assert\NotNull
  212.      *
  213.      * @Column(name="price_end2_under", type="float")
  214.      */
  215.     private $priceEnd2Under;
  216.     /**
  217.      * @var float
  218.      *
  219.      * @Column(name="vat", type="decimal", precision=10, scale=2)
  220.      */
  221.     private $vat;
  222.     /**
  223.      * @var int
  224.      *
  225.      * @Assert\NotNull
  226.      *
  227.      * @Column(name="warranty", type="integer")
  228.      */
  229.     private $warranty;
  230.     /**
  231.      * @var string
  232.      *
  233.      * @Assert\NotNull
  234.      *
  235.      * @Column(name="url", type="text")
  236.      */
  237.     private $url;
  238.     /**
  239.      * @var User
  240.      *
  241.      * @ManyToOne(targetEntity="User")
  242.      * @JoinColumn(name="default_sales_manager_id", referencedColumnName="id", nullable=true)
  243.      */
  244.     private $defaultSalesManager;
  245.     /**
  246.      * @var ArrayCollection
  247.      *
  248.      * @Assert\Valid
  249.      *
  250.      * @OneToMany(targetEntity="Customer", mappedBy="domain")
  251.      **/
  252.     private $customers;
  253.     /**
  254.      * @var ArrayCollection
  255.      *
  256.      * @Assert\Valid
  257.      *
  258.      * @OneToMany(targetEntity="DomainShippingType", mappedBy="domain")
  259.      * @OrderBy({"type" = "ASC"})
  260.      **/
  261.     private $domainShippingTypes;
  262.     /**
  263.      * @var ArrayCollection
  264.      *
  265.      * @Assert\Valid
  266.      *
  267.      * @OneToMany(targetEntity="DomainPaymentType", mappedBy="domain")
  268.      * @OrderBy({"type" = "ASC"})
  269.      **/
  270.     private $domainPaymentTypes;
  271.     /**
  272.      * @var ArrayCollection
  273.      *
  274.      * @Assert\Valid
  275.      *
  276.      * @OneToMany(targetEntity="Order", mappedBy="domain")
  277.      * @OrderBy({"created" = "DESC"})
  278.      **/
  279.     private $orders;
  280.     /**
  281.      * @var string
  282.      *
  283.      * @Assert\NotNull
  284.      *
  285.      * @Column(name="title", type="text")
  286.      */
  287.     private $title;
  288.     /**
  289.      * @var string
  290.      *
  291.      * @Assert\NotNull
  292.      *
  293.      * @Column(name="short_title", type="text", length=8)
  294.      */
  295.     private $shortTitle;
  296.     /**
  297.      * @var string
  298.      *
  299.      * @Column(name="ga_id", type="text", nullable=true)
  300.      */
  301.     private $gaId = null;
  302.     /**
  303.      * @var string
  304.      *
  305.      * @Column(name="blog_url", type="text", nullable=true)
  306.      */
  307.     private $blogUrl = null;
  308.     /**
  309.      * @var string
  310.      *
  311.      * @Column(name="facebook_url", type="text", nullable=true)
  312.      */
  313.     private $facebookUrl = null;
  314.     /**
  315.      * @var string
  316.      *
  317.      * @Column(name="twitter_url", type="text", nullable=true)
  318.      */
  319.     private $twitterUrl = null;
  320.     /**
  321.      * @var string
  322.      *
  323.      * @Column(name="youtube_url", type="text", nullable=true)
  324.      */
  325.     private $youtubeUrl = null;
  326.     /**
  327.      * @var string
  328.      *
  329.      * @Column(name="gplus_url", type="text", nullable=true)
  330.      */
  331.     private $GPlusUrl = null;
  332.     /**
  333.      * @var string
  334.      *
  335.      * @Column(name="livechat_username", type="text", nullable=true)
  336.      */
  337.     private $liveChatUsername = null;
  338.     /**
  339.      * @var string
  340.      *
  341.      * @Column(name="javascripts", type="text", nullable=true)
  342.      */
  343.     private $javascripts = null;
  344.     /**
  345.      * @var ArrayCollection
  346.      *
  347.      * @Assert\Valid
  348.      *
  349.      * @OneToMany(targetEntity="DocumentGroup", mappedBy="domain")
  350.      * @OrderBy({"prefix" = "DESC"})
  351.      **/
  352.     private $documentGroups;
  353.     /**
  354.      * @var ArrayCollection
  355.      *
  356.      * @Assert\Valid
  357.      *
  358.      * @OneToMany(targetEntity="Banner", mappedBy="domain")
  359.      * @OrderBy({"id" = "DESC"})
  360.      **/
  361.     private $banners;
  362.     /**
  363.      * @var ArrayCollection
  364.      *
  365.      * @Assert\Valid
  366.      *
  367.      * @OneToMany(targetEntity="Nanobar", mappedBy="domain")
  368.      **/
  369.     private $nanobars;
  370.     public function __construct()
  371.     {
  372.         parent::__construct();
  373.         $this->customers = new ArrayCollection();
  374.         $this->nanobars = new ArrayCollection();
  375.     }
  376.     /**
  377.      * @return Language
  378.      */
  379.     public function getLanguage()
  380.     {
  381.         return $this->language;
  382.     }
  383.     /**
  384.      * @param Language $language
  385.      */
  386.     public function setLanguage($language)
  387.     {
  388.         $this->language = $language;
  389.     }
  390.     /**
  391.      * @return Company
  392.      */
  393.     public function getCompany()
  394.     {
  395.         return $this->company;
  396.     }
  397.     /**
  398.      * @param Company $company
  399.      */
  400.     public function setCompany($company)
  401.     {
  402.         $this->company = $company;
  403.     }
  404.     /**
  405.      * @return string
  406.      */
  407.     public function getName()
  408.     {
  409.         return $this->name;
  410.     }
  411.     /**
  412.      * @param string $name
  413.      */
  414.     public function setName($name)
  415.     {
  416.         $this->name = $name;
  417.     }
  418.     /**
  419.      * @return string
  420.      */
  421.     public function getCurrency()
  422.     {
  423.         return $this->currency;
  424.     }
  425.     /**
  426.      * @param string $currency
  427.      */
  428.     public function setCurrency($currency)
  429.     {
  430.         $this->currency = $currency;
  431.     }
  432.     /**
  433.      * @return string
  434.      */
  435.     public function getType()
  436.     {
  437.         return $this->type;
  438.     }
  439.     /**
  440.      * @param string $type
  441.      */
  442.     public function setType($type)
  443.     {
  444.         if (!in_array($type, [self::TYPE_RETAIL, self::TYPE_WHOLESALE, self::TYPE_EXPORT, self::TYPE_OTHER])) {
  445.             throw new \LogicException('Invalid Domain Type.');
  446.         }
  447.         $this->type = $type;
  448.     }
  449.     /**
  450.      * @param null|float $date
  451.      * @return float
  452.      * date format: YmdHi
  453.      */
  454.     public function getVat($date = null): float
  455.     {
  456.         $vat = $this->vat;
  457.         if ((in_array($this->getId(), [3, 4]) && !is_null($date) && $date < self::HU_VAT_CHANGE_DATE)
  458.             || (in_array($this->getId(), [5, 9]) && !is_null($date) && $date < self::CZ_VAT_CHANGE_DATE)) {
  459.             if ($date < self::SK_VAT_CHANGE_DATE) {
  460.                 $vat = 20.00;
  461.             } else {
  462.                 $vat = 23.00;
  463.             }
  464.         }
  465.         return $vat;
  466.     }
  467.     /**
  468.      * @param float $vat
  469.      */
  470.     public function setVat($vat)
  471.     {
  472.         $this->vat = $vat;
  473.     }
  474.     /**
  475.      * @Assert\IsTrue
  476.      */
  477.     public function isVatValid()
  478.     {
  479.         return $this->vat >= 0;
  480.     }
  481.     /**
  482.      * @return float
  483.      */
  484.     public function getPriceFactor()
  485.     {
  486.         return $this->priceFactor;
  487.     }
  488.     /**
  489.      * @param float $priceFactor
  490.      */
  491.     public function setPriceFactor($priceFactor)
  492.     {
  493.         $this->priceFactor = $priceFactor;
  494.     }
  495.     /**
  496.      * @return int
  497.      */
  498.     public function getPricePrecision()
  499.     {
  500.         return $this->pricePrecision;
  501.     }
  502.     /**
  503.      * @param int $pricePrecision
  504.      */
  505.     public function setPricePrecision($pricePrecision)
  506.     {
  507.         $this->pricePrecision = $pricePrecision;
  508.     }
  509.     /**
  510.      * @return float
  511.      */
  512.     public function getPriceEnd()
  513.     {
  514.         return $this->priceEnd;
  515.     }
  516.     /**
  517.      * @param float $priceEnd
  518.      */
  519.     public function setPriceEnd($priceEnd)
  520.     {
  521.         $this->priceEnd = $priceEnd;
  522.     }
  523.     public function toDomainPrice($price)
  524.     {
  525.         return $this->getPriceFactor() * $price;
  526.     }
  527.     public function toDomainVatPrice($price)
  528.     {
  529.         return $this->toDomainPrice($price) * self::getVatMultiplier($this->vat);
  530.     }
  531.     public static function getVatMultiplier($vat)
  532.     {
  533.         return 1. + $vat / 100.;
  534.     }
  535.     /**
  536.      * this function exist at JavaScript version, file: product-list.js (with the same function name)
  537.      * @param $priceSrc
  538.      * @param float $vatMultiplier
  539.      * @return float convert the price based on the domain settings
  540.      */
  541.     public function createVatPrice($priceSrc, float $vatMultiplier = 0)
  542.     {
  543.         if ($priceSrc <= 0) {
  544.             return 0;
  545.         }
  546.         if ($vatMultiplier > 0) {
  547.             $price = $priceSrc * $vatMultiplier;
  548.         } else {
  549.             $price = $priceSrc * self::getVatMultiplier($this->vat);
  550.         }
  551.         //round price
  552.         $price = round($price, $this->getPricePrecision(), PHP_ROUND_HALF_EVEN);
  553.         if (!in_array($priceSrc, ['11811.02', '39370.08', '78740.16', '196850.39'])) {
  554.             //setup ending
  555.             if ($priceSrc < $this->getPriceEnd2Under()) {
  556.                 if (($priceEnd = $this->getPriceEnd2()) > 0) {
  557.                     $price = $this->createPriceWithEnding($price, $priceEnd);
  558.                 }
  559.             } else {
  560.                 if (($priceEnd = $this->getPriceEnd()) > 0) {
  561.                     $price = $this->createPriceWithEnding($price, $priceEnd);
  562.                 }
  563.             }
  564.         }
  565.         if ($this->hasLastTwoDigits($price, '01')) {
  566.             $price = floor($price);
  567.         }
  568.         return $price;
  569.     }
  570.     /**
  571.      * @param $priceSrc
  572.      * @param string $country
  573.      * @return float convert the price based on the domain settings
  574.      */
  575.     public function createWithoutVatPriceFromVatPrice($priceSrc, string $country = '')
  576.     {
  577.         if ($priceSrc <= 0) {
  578.             return 0;
  579.         }
  580.         $vatForCountry = VAT::getVatPercentageByCountry($country);
  581.         $vat = $country == '' ? $this->vat : $vatForCountry;
  582.         $price = $priceSrc / self::getVatMultiplier($vat);
  583.         //round price
  584.         $price = round($price, $this->getPricePrecision(), PHP_ROUND_HALF_EVEN);
  585.         //setup ending
  586.         if ($priceSrc < $this->getPriceEnd2Under()) {
  587.             if (($priceEnd = $this->getPriceEnd2()) > 0) {
  588.                 $price = $this->createPriceWithEnding($price, $priceEnd);
  589.             }
  590.         } else {
  591.             if (($priceEnd = $this->getPriceEnd()) > 0) {
  592.                 $price = $this->createPriceWithEnding($price, $priceEnd);
  593.             }
  594.         }
  595.         return $price;
  596.     }
  597.     // this function exist at JavaScript version, file: product-list.js (with the same function name)
  598.     private function createPriceWithEnding($price, $priceEnd)
  599.     {
  600.         $split = preg_split('/[.,]/', '' . $priceEnd);
  601.         $wholePlaces = strlen($split[0]);
  602.         if (count($split) > 1) {
  603.             $decimalPlaces = strlen($split[1]);
  604.         } else {
  605.             $decimalPlaces = 0;
  606.         }
  607.         //remove the ending
  608.         //ending: 990
  609.         //12888 => 12000
  610.         //12000+990 => 12990
  611.         if ($wholePlaces > 0) {
  612.             $rounder = pow(10, $wholePlaces);
  613.             $price1 = $price / $rounder;
  614.             $price1 = (int)($price1);
  615.             $price1 *= $rounder;
  616.             if ($price - $price1 > $priceEnd) {
  617.                 $price = $price1 + $rounder;
  618.             } else {
  619.                 $price = $price1;
  620.             }
  621.         } elseif ($decimalPlaces > 0) {
  622.             $price = (int)($price);
  623.         }
  624.         $price += $priceEnd;
  625.         return $price;
  626.     }
  627.     /**
  628.      * @return int
  629.      */
  630.     public function getWarranty()
  631.     {
  632.         return $this->warranty;
  633.     }
  634.     /**
  635.      * @param int $warranty
  636.      */
  637.     public function setWarranty($warranty)
  638.     {
  639.         $this->warranty = $warranty;
  640.     }
  641.     /**
  642.      * @return string
  643.      */
  644.     public function getUrl()
  645.     {
  646.         return $this->url;
  647.     }
  648.     /**
  649.      * @param string $url
  650.      */
  651.     public function setUrl($url)
  652.     {
  653.         $this->url = $url;
  654.     }
  655.     /**
  656.      * @return ArrayCollection
  657.      */
  658.     public function getCustomers()
  659.     {
  660.         return $this->customers;
  661.     }
  662.     /**
  663.      * @return ArrayCollection
  664.      */
  665.     public function getDomainShippingTypes()
  666.     {
  667.         return $this->domainShippingTypes;
  668.     }
  669.     /**
  670.      * @param ArrayCollection $domainShippingTypes
  671.      */
  672.     public function setDomainShippingTypes($domainShippingTypes)
  673.     {
  674.         $this->domainShippingTypes = $domainShippingTypes;
  675.     }
  676.     /**
  677.      * @return ArrayCollection
  678.      */
  679.     public function getDomainPaymentTypes()
  680.     {
  681.         return $this->domainPaymentTypes;
  682.     }
  683.     /**
  684.      * @param ArrayCollection $domainPaymentTypes
  685.      */
  686.     public function setDomainPaymentTypes($domainPaymentTypes)
  687.     {
  688.         $this->domainPaymentTypes = $domainPaymentTypes;
  689.     }
  690.     /**
  691.      * @return ArrayCollection
  692.      */
  693.     public function getOrders()
  694.     {
  695.         return $this->orders;
  696.     }
  697.     /**
  698.      * @return float
  699.      */
  700.     public function getPriceEnd2()
  701.     {
  702.         return $this->priceEnd2;
  703.     }
  704.     /**
  705.      * @param float $priceEnd2
  706.      */
  707.     public function setPriceEnd2($priceEnd2)
  708.     {
  709.         $this->priceEnd2 = $priceEnd2;
  710.     }
  711.     /**
  712.      * @return float
  713.      */
  714.     public function getPriceEnd2Under()
  715.     {
  716.         return $this->priceEnd2Under;
  717.     }
  718.     /**
  719.      * @param float $priceEnd2Under
  720.      */
  721.     public function setPriceEnd2Under($priceEnd2Under)
  722.     {
  723.         $this->priceEnd2Under = $priceEnd2Under;
  724.     }
  725.     /**
  726.      * @return string
  727.      */
  728.     public function getTitle()
  729.     {
  730.         return $this->title;
  731.     }
  732.     /**
  733.      * @param string $title
  734.      */
  735.     public function setTitle($title)
  736.     {
  737.         $this->title = $title;
  738.     }
  739.     /**
  740.      * @return string
  741.      */
  742.     public function getShortTitle()
  743.     {
  744.         return $this->shortTitle;
  745.     }
  746.     /**
  747.      * @param string $shortTitle
  748.      */
  749.     public function setShortTitle($shortTitle)
  750.     {
  751.         $this->shortTitle = $shortTitle;
  752.     }
  753.     /**
  754.      * @return bool
  755.      */
  756.     public function hasGaId()
  757.     {
  758.         return !is_null($this->gaId) && strlen($this->gaId) > 0;
  759.     }
  760.     /**
  761.      * @return string
  762.      */
  763.     public function getGaId()
  764.     {
  765.         return $this->gaId;
  766.     }
  767.     /**
  768.      * @param string $gaId
  769.      */
  770.     public function setGaId($gaId)
  771.     {
  772.         $this->gaId = $gaId;
  773.     }
  774.     /**
  775.      * @return bool
  776.      */
  777.     public function hasBlogUrl()
  778.     {
  779.         return !is_null($this->blogUrl) && strlen($this->blogUrl) > 0;
  780.     }
  781.     /**
  782.      * @return string
  783.      */
  784.     public function getBlogUrl()
  785.     {
  786.         return $this->blogUrl;
  787.     }
  788.     /**
  789.      * @param string $blogUrl
  790.      */
  791.     public function setBlogUrl($blogUrl)
  792.     {
  793.         $this->blogUrl = $blogUrl;
  794.     }
  795.     /**
  796.      * @return bool
  797.      */
  798.     public function hasFacebookUrl()
  799.     {
  800.         return !is_null($this->facebookUrl) && strlen($this->facebookUrl) > 0;
  801.     }
  802.     /**
  803.      * @return string
  804.      */
  805.     public function getFacebookUrl()
  806.     {
  807.         return $this->facebookUrl;
  808.     }
  809.     /**
  810.      * @param string $facebookUrl
  811.      */
  812.     public function setFacebookUrl($facebookUrl)
  813.     {
  814.         $this->facebookUrl = $facebookUrl;
  815.     }
  816.     /**
  817.      * @return bool
  818.      */
  819.     public function hasTwitterUrl()
  820.     {
  821.         return !is_null($this->twitterUrl) && strlen($this->twitterUrl) > 0;
  822.     }
  823.     /**
  824.      * @return string
  825.      */
  826.     public function getTwitterUrl()
  827.     {
  828.         return $this->twitterUrl;
  829.     }
  830.     /**
  831.      * @param string $twitterUrl
  832.      */
  833.     public function setTwitterUrl($twitterUrl)
  834.     {
  835.         $this->twitterUrl = $twitterUrl;
  836.     }
  837.     /**
  838.      * @return bool
  839.      */
  840.     public function hasYoutubeUrl()
  841.     {
  842.         return !is_null($this->youtubeUrl) && strlen($this->youtubeUrl) > 0;
  843.     }
  844.     /**
  845.      * @return string
  846.      */
  847.     public function getYoutubeUrl()
  848.     {
  849.         return $this->youtubeUrl;
  850.     }
  851.     /**
  852.      * @param string $youtubeUrl
  853.      */
  854.     public function setYoutubeUrl($youtubeUrl)
  855.     {
  856.         $this->youtubeUrl = $youtubeUrl;
  857.     }
  858.     /**
  859.      * @return bool
  860.      */
  861.     public function hasGPlusUrl()
  862.     {
  863.         return !is_null($this->GPlusUrl) && strlen($this->GPlusUrl) > 0;
  864.     }
  865.     /**
  866.      * @return string
  867.      */
  868.     public function getGPlusUrl()
  869.     {
  870.         return $this->GPlusUrl;
  871.     }
  872.     /**
  873.      * @param string $GPlusUrl
  874.      */
  875.     public function setGPlusUrl($GPlusUrl)
  876.     {
  877.         $this->GPlusUrl = $GPlusUrl;
  878.     }
  879.     /**
  880.      * @return bool
  881.      */
  882.     public function hasLiveChatUsername()
  883.     {
  884.         return !is_null($this->liveChatUsername) && strlen($this->liveChatUsername) > 0;
  885.     }
  886.     /**
  887.      * @return string
  888.      */
  889.     public function getLiveChatUsername()
  890.     {
  891.         return $this->liveChatUsername;
  892.     }
  893.     /**
  894.      * @param string $liveChatUsername
  895.      */
  896.     public function setLiveChatUsername($liveChatUsername)
  897.     {
  898.         $this->liveChatUsername = $liveChatUsername;
  899.     }
  900.     /**
  901.      * @return bool
  902.      */
  903.     public function hasJavascripts()
  904.     {
  905.         return !is_null($this->javascripts) && strlen($this->javascripts) > 0;
  906.     }
  907.     /**
  908.      * @return string
  909.      */
  910.     public function getJavascripts()
  911.     {
  912.         return $this->javascripts;
  913.     }
  914.     /**
  915.      * @param string $javaScripts
  916.      */
  917.     public function setJavascripts($javaScripts)
  918.     {
  919.         $this->javascripts = $javaScripts;
  920.     }
  921.     /**
  922.      * @return ArrayCollection
  923.      */
  924.     public function getDocumentGroups()
  925.     {
  926.         return $this->documentGroups;
  927.     }
  928.     /**
  929.      * @param ArrayCollection $documentGroups
  930.      */
  931.     public function setDocumentGroups($documentGroups)
  932.     {
  933.         $this->documentGroups = $documentGroups;
  934.     }
  935.     /**
  936.      * @return User
  937.      */
  938.     public function getDefaultSalesManager()
  939.     {
  940.         return $this->defaultSalesManager;
  941.     }
  942.     /**
  943.      * @param User $defaultSalesManager
  944.      */
  945.     public function setDefaultSalesManager($defaultSalesManager)
  946.     {
  947.         $this->defaultSalesManager = $defaultSalesManager;
  948.     }
  949.     /**
  950.      * @return ArrayCollection
  951.      */
  952.     public function getBanners()
  953.     {
  954.         return $this->banners;
  955.     }
  956.     /**
  957.      * @return array
  958.      */
  959.     public function getActiveBanners()
  960.     {
  961.         $activeBanners = [];
  962.         foreach ($this->getBanners() as $banner) {
  963.             if ($banner->isCurrentlyActive()) {
  964.                 $activeBanners[] = $banner;
  965.             }
  966.         }
  967.         return $activeBanners;
  968.     }
  969.     /**
  970.      * @return string
  971.      */
  972.     public function getCurrencyTextCode()
  973.     {
  974.         switch (trim($this->getCurrency())) {
  975.             case '€':
  976.                 $currencyTextCode = 'EUR';
  977.                 break;
  978.             case 'Ft':
  979.                 $currencyTextCode = 'HUF';
  980.                 break;
  981.             case 'Kč':
  982.                 $currencyTextCode = 'CZK';
  983.                 break;
  984.             case 'CHF':
  985.                 $currencyTextCode = 'CHF';
  986.                 break;
  987.             default:
  988.                 $currencyTextCode = '';
  989.         }
  990.         return $currencyTextCode;
  991.     }
  992.     public function addNanobar(Nanobar $nanobar): Domain
  993.     {
  994.         $this->nanobars[] = $nanobar;
  995.         return $this;
  996.     }
  997.     public function removeNanobar(Nanobar $nanobar)
  998.     {
  999.         return $this->nanobars->removeElement($nanobar);
  1000.     }
  1001.     public function getNanobars(): ArrayCollection
  1002.     {
  1003.         return $this->nanobars;
  1004.     }
  1005.     public function hasLastTwoDigits($number, $lastTwoDigitsToCheck): bool
  1006.     {
  1007.         $formatted = number_format($number, 2, '.', ''); // Ensure two decimal places
  1008.         $lastTwo = substr($formatted, -2); // Get last two characters
  1009.         return $lastTwo === $lastTwoDigitsToCheck;
  1010.     }
  1011. }