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