src/Bidcoz/Bundle/CoreBundle/Entity/Organization.php line 29

Open in your IDE?
  1. <?php
  2. namespace Bidcoz\Bundle\CoreBundle\Entity;
  3. use Bidcoz\Bundle\CoreBundle\Constants;
  4. use Bidcoz\Bundle\CoreBundle\Entity\PaymentGateway\Account\Account;
  5. use Bidcoz\Bundle\CoreBundle\Entity\PaymentGateway\Account\OrganizationAccount;
  6. use Bidcoz\Bundle\CoreBundle\Entity\PaymentGateway\PaymentGateway;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use JMS\Serializer\Annotation as Serialize;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  13. /**
  14.  * @ORM\Entity(repositoryClass="OrganizationRepository")
  15.  *
  16.  * @ORM\Table(
  17.  *     name="organizations",
  18.  *     uniqueConstraints={
  19.  *
  20.  *         @ORM\UniqueConstraint(name="organization_slug_uk",columns={"slug"})
  21.  *     }
  22.  * )
  23.  *
  24.  * @Serialize\ExclusionPolicy("all")
  25.  */
  26. class Organization implements Themeable, \JsonSerializable
  27. {
  28.     public const BIDCOZ_ORG_ID 1;
  29.     public const DEFAULT_MANDRILL_SUBACCOUNT 'default';
  30.     public const CAUSEPILOT_TWILIO_ACCOUNT   'causepilot';
  31.     public const FLIGHT_SIMULATOR_STATUS_READY          0;
  32.     public const FLIGHT_SIMULATOR_STATUS_RESETTING      1;
  33.     public const FLIGHT_SIMULATOR_STATUS_ERROR          2;
  34.     public const FLIGHT_SIMULATOR_STATUS_RESETTING_DONE 3;
  35.     private const DEFAULT_COMMISSION       0.05;
  36.     private const DEFAULT_SERVICE_FEES_CAP 1997;
  37.     /**
  38.      * @ORM\Id
  39.      *
  40.      * @ORM\Column(name="id", type="integer")
  41.      *
  42.      * @ORM\GeneratedValue(strategy="AUTO")
  43.      */
  44.     protected $id;
  45.     /**
  46.      * @ORM\Column(name="name", type="text", nullable=true)
  47.      *
  48.      * @Serialize\Expose
  49.      *
  50.      * @Serialize\Groups({"Default", "API"})
  51.      */
  52.     protected ?string $name null;
  53.     /**
  54.      * @ORM\Column(name="slug", type="string", length=50);
  55.      *
  56.      * @Assert\NotBlank
  57.      *
  58.      * @Assert\Regex(pattern="/^[0-9a-z-]+$/i", message="Organization URL can only contain lower-case letters, numbers and dashes")
  59.      *
  60.      * @Assert\Length(min=3)
  61.      *
  62.      * @Serialize\Expose
  63.      *
  64.      * @Serialize\Groups({"Default", "API"})
  65.      */
  66.     protected $slug;
  67.     /**
  68.      * @ORM\OneToMany(targetEntity="Campaign", mappedBy="organization")
  69.      */
  70.     protected $campaigns;
  71.     /**
  72.      * @ORM\Column(name="active", type="boolean");
  73.      */
  74.     protected $active true;
  75.     /**
  76.      * @ORM\Column(name="approved", type="boolean");
  77.      */
  78.     protected $approved true;
  79.     /**
  80.      * @ORM\Column(name="commission", type="float");
  81.      */
  82.     protected $commission self::DEFAULT_COMMISSION;
  83.     /**
  84.      * @ORM\Column(name="enable_customizations", type="boolean");
  85.      */
  86.     protected $enableCustomizations false;
  87.     /**
  88.      * @ORM\Column(name="non_profit", type="boolean");
  89.      */
  90.     protected $nonProfit false;
  91.     /**
  92.      * @ORM\Column(name="service_fees_cap", type="decimal", scale=2, precision=10)
  93.      *
  94.      * @Assert\NotBlank
  95.      */
  96.     protected float $serviceFeesCap 0.0;
  97.     /**
  98.      * @ORM\Column(name="total_service_fees", type="decimal", scale=2, precision=10)
  99.      *
  100.      * @Assert\NotBlank
  101.      */
  102.     protected float $totalServiceFees 0.0;
  103.     /**
  104.      * @ORM\Column(name="total_service_fees_capped", type="decimal", scale=2, precision=10)
  105.      *
  106.      * @Assert\NotBlank
  107.      */
  108.     protected float $totalServiceFeesCapped 0.0;
  109.     /**
  110.      * @ORM\Column(name="plan_renewal_amount", type="decimal", scale=2, precision=10)
  111.      */
  112.     protected float $planRenewalAmount 0.0;
  113.     /**
  114.      * @ORM\Column(name="tin", type="string", nullable=true);
  115.      *
  116.      * @Serialize\Expose
  117.      */
  118.     protected $tin;
  119.     /**
  120.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\PaymentGateway\Account\OrganizationAccount", mappedBy="organization")
  121.      *
  122.      * @Assert\Valid
  123.      */
  124.     protected $paymentGatewayAccounts;
  125.     /**
  126.      * @var Collection|OrganizationAdmin[]|null
  127.      * @ORM\OneToMany(targetEntity="OrganizationAdmin", mappedBy="organization")
  128.      * @ORM\OrderBy({"createdAt" = "ASC"})
  129.      */
  130.     protected ?Collection $admins;
  131.     /**
  132.      * @ORM\Embedded(class="Theme", columnPrefix="org_")
  133.      *
  134.      * @Assert\Valid
  135.      */
  136.     protected ?Theme $theme null;
  137.     /**
  138.      * @ORM\ManyToOne(targetEntity="Image")
  139.      *
  140.      * @ORM\JoinColumn(name="banner_image_id", referencedColumnName="id", onDelete="SET NULL")
  141.      *
  142.      * @Serialize\Expose
  143.      */
  144.     protected ?Image $bannerImage null;
  145.     /**
  146.      * @ORM\ManyToOne(targetEntity="Image")
  147.      *
  148.      * @ORM\JoinColumn(name="logo_image_id", referencedColumnName="id", onDelete="SET NULL")
  149.      *
  150.      * @Serialize\Expose
  151.      */
  152.     protected ?Image $logo null;
  153.     /**
  154.      * @ORM\Column(name="url_editable_until", type="datetime")
  155.      */
  156.     protected $urlEditableUntil;
  157.     /**
  158.      * @ORM\Column(name="created_at", type="datetime")
  159.      *
  160.      * @Serialize\Expose
  161.      */
  162.     protected $createdAt;
  163.     /**
  164.      * @ORM\Column(name="admin_org", type="boolean");
  165.      */
  166.     protected $adminOrg false;
  167.     /**
  168.      * @ORM\Column(name="stripe_address_check", type="boolean");
  169.      */
  170.     protected $stripeAddressCheck false;
  171.     /**
  172.      * @ORM\Column(name="mandrill_subaccount", type="string", length=50, nullable=true);
  173.      */
  174.     protected $mandrillAccount self::DEFAULT_MANDRILL_SUBACCOUNT;
  175.     /**
  176.      * @ORM\Column(name="currency", type="string", length=3);
  177.      */
  178.     protected $currency 'USD';
  179.     /**
  180.      * @var Address
  181.      *
  182.      * @ORM\Embedded(class= "Bidcoz\Bundle\CoreBundle\Entity\Address", columnPrefix=false)
  183.      *
  184.      * @Assert\Valid
  185.      *
  186.      * @Serialize\Expose
  187.      */
  188.     protected $address;
  189.     /**
  190.      * @ORM\Column(name="phone", type="string", nullable=true);
  191.      *
  192.      * @Serialize\Expose
  193.      */
  194.     protected $phone;
  195.     /**
  196.      * @ORM\Column(name="contact_name", type="string", nullable=true);
  197.      *
  198.      * @Assert\Length(max=255)
  199.      *
  200.      * @Serialize\Expose
  201.      */
  202.     protected $contactName;
  203.     /**
  204.      * @ORM\Column(name="contact_email", type="string", nullable=true);
  205.      *
  206.      * @Assert\Length(max=255)
  207.      *
  208.      * @Assert\Email()
  209.      *
  210.      * @Serialize\Expose
  211.      */
  212.     protected $contactEmail;
  213.     // Not mapped, a hack around the registration form
  214.     protected $acceptTerms;
  215.     /**
  216.      * @ORM\Column(name="notes", type="text", nullable=true);
  217.      */
  218.     protected $notes;
  219.     /**
  220.      * @ORM\Column(name="no_payment_gateway_required", type="boolean", options={"default"= false});
  221.      */
  222.     protected $paymentGatewayNotRequired false;
  223.     /**
  224.      * @ORM\Column(name="kindful_token", length=64, type="string", nullable=true);
  225.      */
  226.     protected $kindfulToken;
  227.     /**
  228.      * @ORM\Column(name="stripe_subscription_id", type="string", nullable=true, length=50);
  229.      */
  230.     protected $stripeSubscriptionId;
  231.     /**
  232.      * @ORM\ManyToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\CreditCard")
  233.      *
  234.      * @ORM\JoinColumn(name="card_id", referencedColumnName="id", onDelete="SET NULL")
  235.      */
  236.     protected $creditCard;
  237.     /**
  238.      * @ORM\ManyToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\TwilioAccount")
  239.      *
  240.      * @ORM\JoinColumn(name="twilio_account", referencedColumnName="id", nullable=false)
  241.      *
  242.      * @Assert\NotNull
  243.      */
  244.     protected $twilioAccount;
  245.     /**
  246.      * @ORM\Column(type="string", length=100, nullable=true, name="web_address")
  247.      */
  248.     protected $webAddress;
  249.     /**
  250.      * @ORM\Column(type="string", length=100, nullable=true, name="organization_type")
  251.      */
  252.     protected $organizationType;
  253.     /**
  254.      * @ORM\OneToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\TaxCertificate", cascade={"remove"})
  255.      *
  256.      * @Serialize\Expose
  257.      */
  258.     protected ?TaxCertificate $taxCertificate null;
  259.     /**
  260.      * @var TaxCertificate[]|Collection|null
  261.      *
  262.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\TaxCertificate", mappedBy="organization", cascade={"remove"})
  263.      *
  264.      * @Serialize\Expose
  265.      */
  266.     protected ?Collection $taxCertificates null;
  267.     /**
  268.      * @ORM\Column(type="boolean", options={"default": false})
  269.      */
  270.     private bool $nonProfitApproved false;
  271.     /**
  272.      * @ORM\Column(name="flight_simulator_status", type="integer", nullable=true);
  273.      */
  274.     protected ?int $flightSimulatorStatus self::FLIGHT_SIMULATOR_STATUS_READY;
  275.     public function __construct()
  276.     {
  277.         $this->campaigns              = new ArrayCollection();
  278.         $this->paymentGatewayAccounts = new ArrayCollection();
  279.         $this->admins                 = new ArrayCollection();
  280.         $this->theme                  = new Theme();
  281.         $this->urlEditableUntil       = new \DateTime('+7 days');
  282.         $this->createdAt              = new \DateTime();
  283.     }
  284.     public function __clone()
  285.     {
  286.         $this->id              null;
  287.         $this->mandrillAccount self::DEFAULT_MANDRILL_SUBACCOUNT;
  288.     }
  289.     public function setId($id)
  290.     {
  291.         $this->id $id;
  292.     }
  293.     public function getId()
  294.     {
  295.         return $this->id;
  296.     }
  297.     public function setName(?string $name): void
  298.     {
  299.         $this->name $name;
  300.     }
  301.     public function getName(): ?string
  302.     {
  303.         return $this->name;
  304.     }
  305.     public function setSlug($slug)
  306.     {
  307.         $this->slug $slug;
  308.     }
  309.     public function ensureSlugLowercase()
  310.     {
  311.         $this->slug strtolower($this->slug);
  312.     }
  313.     public function getSlug()
  314.     {
  315.         return $this->slug;
  316.     }
  317.     public function getOrganizationType()
  318.     {
  319.         return $this->organizationType;
  320.     }
  321.     public function setOrganizationType($organizationType)
  322.     {
  323.         $this->organizationType $organizationType;
  324.         if ($organizationType == 'non-profit') {
  325.             $this->setNonProfit(true);
  326.         }
  327.     }
  328.     /**
  329.      * @return Collection|Campaign[]
  330.      */
  331.     public function getCampaigns(bool $activeOnly falsebool $returnLocked true): Collection
  332.     {
  333.         if (!$activeOnly) {
  334.             return $this->campaigns;
  335.         }
  336.         return $this->campaigns->filter(function (Campaign $campaign) use ($returnLocked) {
  337.             if (!$returnLocked && $campaign->isLocked()) {
  338.                 return false;
  339.             }
  340.             return $campaign->isActive();
  341.         });
  342.     }
  343.     public function getAdminSortedCampaigns()
  344.     {
  345.         $campaigns $this->campaigns->toArray();
  346.         usort($campaigns, function (Campaign $aCampaign $b) {
  347.             if ($a->isHidden() != $b->isHidden()) {
  348.                 return $a->isHidden() ? : -1;
  349.             }
  350.             if ($a->isLocked() != $b->isLocked()) {
  351.                 return $a->isLocked() ? : -1;
  352.             }
  353.             return $a->getName() <=> $b->getName();
  354.         });
  355.         return $campaigns;
  356.     }
  357.     public function getCampaignBySlug($slug): ?Campaign
  358.     {
  359.         $result null;
  360.         foreach ($this->getCampaigns() as $campaign) {
  361.             if ($campaign->getSlug() === $slug) {
  362.                 $result $campaign;
  363.                 break;
  364.             }
  365.         }
  366.         return $result;
  367.     }
  368.     public function setActive($active)
  369.     {
  370.         $this->active $active;
  371.     }
  372.     public function isActive()
  373.     {
  374.         return $this->active;
  375.     }
  376.     public function setStripeAddressCheck($stripeAddressCheck)
  377.     {
  378.         $this->stripeAddressCheck $stripeAddressCheck;
  379.     }
  380.     public function isStripeAddressCheck()
  381.     {
  382.         return $this->stripeAddressCheck;
  383.     }
  384.     public function setApproved($approved)
  385.     {
  386.         $this->approved $approved;
  387.     }
  388.     public function isApproved()
  389.     {
  390.         return $this->approved;
  391.     }
  392.     public function isPendingVerification()
  393.     {
  394.         return $this->isActive()
  395.             && $this->isApproved()
  396.             && $this->isNonprofit()
  397.             && == $this->getServiceFeesCap();
  398.     }
  399.     public function setTin($tin)
  400.     {
  401.         $this->tin $tin;
  402.     }
  403.     public function getTin()
  404.     {
  405.         return $this->tin;
  406.     }
  407.     public function setStripeSubscriptionId(?string $subscriptionId)
  408.     {
  409.         $this->stripeSubscriptionId $subscriptionId;
  410.     }
  411.     public function getStripeSubscriptionId(): ?string
  412.     {
  413.         return $this->stripeSubscriptionId;
  414.     }
  415.     public function setCreditCard(CreditCard $cc)
  416.     {
  417.         $this->creditCard $cc;
  418.     }
  419.     public function getCreditCard(): ?CreditCard
  420.     {
  421.         return $this->creditCard;
  422.     }
  423.     public function isStripeAllowed(): bool
  424.     {
  425.         return true;
  426.     }
  427.     public function getPaymentGatewayChoices()
  428.     {
  429.         return [
  430.             'Stripe' => PaymentGateway::STRIPE,
  431.         ];
  432.     }
  433.     public function clearPaymentGatewayAccounts()
  434.     {
  435.         $this->paymentGatewayAccounts = new ArrayCollection();
  436.     }
  437.     public function addPaymentGatewayAccount(OrganizationAccount $account)
  438.     {
  439.         if (!$this->paymentGatewayAccounts->contains($account)) {
  440.             $this->paymentGatewayAccounts->add($account);
  441.         }
  442.     }
  443.     public function hasPaymentGatewayAccount(Account $account)
  444.     {
  445.         return $this->paymentGatewayAccounts->exists(function ($index$orgAccount) use ($account) {
  446.             return $account == $orgAccount->getAccount();
  447.         });
  448.     }
  449.     public function hasPaymentGatewayAccountType($type)
  450.     {
  451.         return $this->paymentGatewayAccounts->exists(function ($index$orgAccount) use ($type) {
  452.             return $orgAccount->getAccount()->getType() == $type;
  453.         });
  454.     }
  455.     public function getPaymentGatewayAccount($type)
  456.     {
  457.         $orgAccount $this->paymentGatewayAccounts->filter(function ($orgAccount) use ($type) {
  458.             return $orgAccount->getAccount()->getType() == $type;
  459.         })->first();
  460.         if ($orgAccount) {
  461.             return $orgAccount->getAccount();
  462.         }
  463.     }
  464.     public function getPaymentGatewayAccounts()
  465.     {
  466.         return $this->paymentGatewayAccounts;
  467.     }
  468.     /**
  469.      * @Assert\IsTrue(message="You must connect to Stripe to accept payments.", groups={"payment"})
  470.      */
  471.     public function hasPaymentGateway(): bool
  472.     {
  473.         if ($this->paymentGatewayNotRequired) {
  474.             return true;
  475.         }
  476.         if ($this->isStripeAllowed()) {
  477.             return (bool) $this->getPaymentGatewayAccount(Account::STRIPE);
  478.         } else {
  479.             return count($this->getPaymentGatewayAccounts()) > 0;
  480.         }
  481.     }
  482.     public function setTheme(?Theme $theme)
  483.     {
  484.         $this->theme $theme;
  485.     }
  486.     public function getTheme()
  487.     {
  488.         return $this->theme;
  489.     }
  490.     public function setBannerImage(?Image $image)
  491.     {
  492.         $this->bannerImage $image;
  493.     }
  494.     public function removeBannerImage()
  495.     {
  496.         $this->bannerImage null;
  497.     }
  498.     public function getBannerImage()
  499.     {
  500.         return $this->bannerImage;
  501.     }
  502.     public function setLogo(Image $image null)
  503.     {
  504.         $this->logo $image;
  505.     }
  506.     public function getLogo()
  507.     {
  508.         return $this->logo;
  509.     }
  510.     public function removeLogo()
  511.     {
  512.         $this->logo null;
  513.     }
  514.     public function getUrlEditableUntil()
  515.     {
  516.         return $this->urlEditableUntil;
  517.     }
  518.     public function setUrlEditableUntil($urlEditableUntil)
  519.     {
  520.         $this->urlEditableUntil $urlEditableUntil;
  521.     }
  522.     public function isUrlEditable()
  523.     {
  524.         $now = new \DateTime();
  525.         return $now $this->urlEditableUntil;
  526.     }
  527.     public function getCreatedAt()
  528.     {
  529.         return $this->createdAt;
  530.     }
  531.     public function setAcceptTerms($acceptTerms)
  532.     {
  533.         $this->acceptTerms $acceptTerms;
  534.     }
  535.     /**
  536.      * @Assert\IsTrue(message="You must accept the Organization (non-profit) Terms of Use")
  537.      */
  538.     public function getAcceptTerms()
  539.     {
  540.         return $this->acceptTerms;
  541.     }
  542.     public function setAdminOrg($adminOrg)
  543.     {
  544.         $this->adminOrg $adminOrg;
  545.     }
  546.     public function isAdminOrg()
  547.     {
  548.         return $this->adminOrg;
  549.     }
  550.     public function setMandrillAccount($account)
  551.     {
  552.         $this->mandrillAccount $account;
  553.     }
  554.     public function getMandrillAccount()
  555.     {
  556.         return $this->mandrillAccount;
  557.     }
  558.     public function isDefaultSubaccount()
  559.     {
  560.         return self::DEFAULT_MANDRILL_SUBACCOUNT == $this->mandrillAccount;
  561.     }
  562.     public function setCurrency($currency)
  563.     {
  564.         $this->currency $currency;
  565.     }
  566.     public function getCurrency()
  567.     {
  568.         return $this->currency;
  569.     }
  570.     public static function getOrganizationTypeChoices()
  571.     {
  572.         return array_flip([
  573.             'individual' => 'Individual',
  574.             'group' => 'Group',
  575.             'non-profit' => 'Non-Profit Organization',
  576.         ]);
  577.     }
  578.     public static function getCurrencyChoices()
  579.     {
  580.         return array_flip([
  581.             'USD' => 'US Dollar ($)',
  582.             'SGD' => 'Singapore Dollar ($)',
  583.             'AUD' => 'Australian Dollar ($)',
  584.             'NZD' => 'New Zealand Dollar ($)',
  585.         ]);
  586.     }
  587.     public function getCurrencyDisplay(): string
  588.     {
  589.         return array_flip(self::getCurrencyChoices())[$this->currency];
  590.     }
  591.     public function setAddress(Address $address)
  592.     {
  593.         $this->address $address;
  594.     }
  595.     public function getAddress()
  596.     {
  597.         return $this->address;
  598.     }
  599.     public function setPhone($phone)
  600.     {
  601.         $this->phone $phone;
  602.     }
  603.     public function getPhone()
  604.     {
  605.         return $this->phone;
  606.     }
  607.     public function setContactName($contactName)
  608.     {
  609.         $this->contactName $contactName;
  610.     }
  611.     public function getContactName()
  612.     {
  613.         return $this->contactName;
  614.     }
  615.     public function setContactEmail($contactEmail)
  616.     {
  617.         $this->contactEmail $contactEmail;
  618.     }
  619.     public function getContactEmail()
  620.     {
  621.         return $this->contactEmail;
  622.     }
  623.     /**
  624.      * @Assert\Callback
  625.      */
  626.     public function isReservedSlug(ExecutionContextInterface $context)
  627.     {
  628.         if (in_array($this->slug$this->getReservedSlugs()) || !preg_match('#'.Constants::RESERVED_SLUG_REGEX.'#'$this->slug)) {
  629.             $context->buildViolation('This is a reserved url.')
  630.                 ->atPath('slug')
  631.                 ->addViolation();
  632.             return true;
  633.         }
  634.         return false;
  635.     }
  636.     public static function getReservedSlugs()
  637.     {
  638.         $strLen   strlen(Constants::RESERVED_SLUG_REGEX);
  639.         $lastWord strpos(Constants::RESERVED_SLUG_REGEX'))');
  640.         $slugStr  substr(Constants::RESERVED_SLUG_REGEX6, ($strLen $lastWord) * -1);
  641.         return array_merge(explode('|'$slugStr), [
  642.             'organization',
  643.             'manage',
  644.             'home',
  645.             'login_check',
  646.             'dashboard',
  647.             'account',
  648.             'legal',
  649.             'payment',
  650.             'terms',
  651.             'email',
  652.             'admin',
  653.             'login',
  654.         ]);
  655.     }
  656.     public function setNotes(string $notes)
  657.     {
  658.         $this->notes $notes;
  659.     }
  660.     public function getNotes()
  661.     {
  662.         return $this->notes;
  663.     }
  664.     public function getCustomDomain()
  665.     {
  666.         if ('nvidia' === $this->slug) {
  667.             return 'nvidia.causepilot.com';
  668.         } elseif ('chg' === $this->slug) {
  669.             return 'chg.causepilot.com';
  670.         }
  671.     }
  672.     public function isAuctionItemShareable(): bool
  673.     {
  674.         return !$this->isEnableCustomizations();
  675.     }
  676.     public function getKindfulToken()
  677.     {
  678.         return $this->kindfulToken;
  679.     }
  680.     public function setKindfulToken($token)
  681.     {
  682.         $this->kindfulToken $token;
  683.     }
  684.     public function getAdmins(): ?Collection
  685.     {
  686.         return $this->admins;
  687.     }
  688.     public function setAdmins(Collection $admins): Organization
  689.     {
  690.         $this->admins $admins;
  691.         return $this;
  692.     }
  693.     public function setTwilioAccount(TwilioAccount $twilioAccount)
  694.     {
  695.         $this->twilioAccount $twilioAccount;
  696.     }
  697.     public function getTwilioAccount(): TwilioAccount
  698.     {
  699.         return $this->twilioAccount;
  700.     }
  701.     public function isEnableCustomizations(): bool
  702.     {
  703.         return $this->enableCustomizations;
  704.     }
  705.     public function setEnableCustomizations(bool $enableCustomizations)
  706.     {
  707.         $this->enableCustomizations $enableCustomizations;
  708.     }
  709.     public function getCommission(): float
  710.     {
  711.         return $this->commission;
  712.     }
  713.     public function setCommission(float $commission)
  714.     {
  715.         $this->commission $commission;
  716.     }
  717.     public function setDefaultCommission()
  718.     {
  719.         $this->commission self::DEFAULT_COMMISSION;
  720.     }
  721.     public function isNonprofit(): bool
  722.     {
  723.         return $this->nonProfit;
  724.     }
  725.     public function setNonProfit(bool $nonProfit)
  726.     {
  727.         $this->nonProfit $nonProfit;
  728.     }
  729.     public function delayServiceFeeCalculation(): bool
  730.     {
  731.         return $this->slug === 'chg';
  732.     }
  733.     public function getServiceFeesCap(): ?float
  734.     {
  735.         return $this->serviceFeesCap;
  736.     }
  737.     public function setServiceFeesCap(?float $serviceFeesCap): void
  738.     {
  739.         $this->serviceFeesCap $serviceFeesCap;
  740.     }
  741.     public function getTotalServiceFees(): ?float
  742.     {
  743.         return $this->totalServiceFees;
  744.     }
  745.     public function setTotalServiceFees(?float $totalServiceFees): void
  746.     {
  747.         $this->totalServiceFees $totalServiceFees;
  748.     }
  749.     public function getTotalServiceFeesCapped(): ?float
  750.     {
  751.         return $this->totalServiceFeesCapped;
  752.     }
  753.     public function setTotalServiceFeesCapped(?float $totalServiceFeesCapped): void
  754.     {
  755.         $this->totalServiceFeesCapped $totalServiceFeesCapped;
  756.     }
  757.     public function setDefaultServiceFeesCap()
  758.     {
  759.         $this->serviceFeesCap self::DEFAULT_SERVICE_FEES_CAP;
  760.     }
  761.     public function getPlanRenewalAmount(): float
  762.     {
  763.         return $this->planRenewalAmount;
  764.     }
  765.     public function setPlanRenewalAmount(float $planRenewalAmount): void
  766.     {
  767.         $this->planRenewalAmount $planRenewalAmount;
  768.     }
  769.     public function isAutoCreateTransactionForExternalPurchases(): bool
  770.     {
  771.         // Can make a db flag later if needed
  772.         return 'chg' === $this->slug;
  773.     }
  774.     public function getWebAddress()
  775.     {
  776.         return $this->webAddress;
  777.     }
  778.     public function setWebAddress(string $webAddress)
  779.     {
  780.         $this->webAddress $webAddress;
  781.     }
  782.     public function addTaxCertificate(TaxCertificate $taxCertificate): void
  783.     {
  784.         $this->taxCertificates->add($taxCertificate);
  785.         $this->setTaxCertificate($taxCertificate);
  786.     }
  787.     public function removeTaxCertificate(TaxCertificate $taxCertificate): void
  788.     {
  789.         $this->taxCertificates->removeElement($taxCertificate);
  790.         if ($this->taxCertificate === $taxCertificate) {
  791.             $this->setTaxCertificate(null);
  792.         }
  793.     }
  794.     public function getTaxCertificate(): ?TaxCertificate
  795.     {
  796.         return $this->taxCertificate;
  797.     }
  798.     public function setTaxCertificate(?TaxCertificate $taxCertificate): self
  799.     {
  800.         $this->taxCertificate $taxCertificate;
  801.         return $this;
  802.     }
  803.     public function getTaxCertificates(): ?Collection
  804.     {
  805.         return $this->taxCertificates;
  806.     }
  807.     public function setTaxCertificates(?Collection $taxCertificates): self
  808.     {
  809.         $this->taxCertificates $taxCertificates;
  810.         return $this;
  811.     }
  812.     public function hasTaxCertificate(): bool
  813.     {
  814.         return null !== $this->taxCertificate;
  815.     }
  816.     public function getFlightSimulatorStatus(): ?int
  817.     {
  818.         return $this->flightSimulatorStatus;
  819.     }
  820.     public function setFlightSimulatorStatus(int $flightSimulatorStatus): void
  821.     {
  822.         $this->flightSimulatorStatus $flightSimulatorStatus;
  823.     }
  824.     public function jsonSerialize()
  825.     {
  826.         return [
  827.             'name' => $this->getName(),
  828.             'logo' => $this->getLogo(),
  829.         ];
  830.     }
  831.     public function isNonProfitApproved(): bool
  832.     {
  833.         return $this->nonProfitApproved;
  834.     }
  835.     public function setNonProfitApproved(bool $nonProfitApproved): self
  836.     {
  837.         $this->nonProfitApproved $nonProfitApproved;
  838.         return $this;
  839.     }
  840. }