src/Entity/Notary.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Client\Client2;
  4. use App\Entity\Notification\NotaryNotification;
  5. use App\Enum\NotaryCompanyRegistrationStatus;
  6. use App\Model\BitrixSerialize;
  7. use App\Repository\NotaryRepository;
  8. use App\Service\BitrixSender;
  9. use App\ValueObject\NotaryJusticeMinistryNumber;
  10. use App\ValueObject\NotaryNumberUis;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Exception;
  15. use JMS\Serializer\Annotation as JMS;
  16. /**
  17.  * @ORM\Entity(repositoryClass=NotaryRepository::class)
  18.  */
  19. class Notary extends User implements \JsonSerializableBitrixSerialize
  20. {
  21.     /** Конфигурация страниц краткого заключения по умолчанию  */
  22.     private const ANNOUNCEMENT_CONFIG_DEFAULT '1,2,3,-7';
  23.     /** Ничего не показывать **/
  24.     public const WELCOME_MODAL_NONE 0;
  25.     /** Ново рег через инофонот **/
  26.     public const WELCOME_MODAL_INFO_NOT_NEW 1;
  27.     /** Привязка существующей записи к инофонот **/
  28.     public const WELCOME_MODAL_INFO_NOT_CONNECTED 2;
  29.     /**
  30.      * Стартовый невыводимый бонус для нотариусов
  31.      */
  32.     public const START_BONUS_BALANCE 0;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      *
  36.      * @JMS\Type("string")
  37.      */
  38.     private $name;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      *
  42.      * @JMS\Type("string")
  43.      */
  44.     private $refovodCode;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      *
  48.      * @JMS\Type("string")
  49.      */
  50.     private $surname;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      *
  54.      * @JMS\Type("string")
  55.      */
  56.     private $patronymic;
  57.     /**
  58.      * @ORM\Column(type="string", length=255)
  59.      *
  60.      * @JMS\Type("string")
  61.      */
  62.     private $phone;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=Client::class, mappedBy="notary")
  65.      *
  66.      * @JMS\Exclude()
  67.      */
  68.     private $clients;
  69.     /**
  70.      * @var Collection<int, Client2>
  71.      * @ORM\OneToMany(targetEntity=\App\Entity\Client\Client2::class, mappedBy="partner")
  72.      * @ORM\OrderBy({"id" = "DESC"})
  73.      * @JMS\Exclude()
  74.      */
  75.     private $clients2;
  76.     /**
  77.      * @ORM\Column(type="string", length=255)
  78.      *
  79.      * @JMS\Type("string")
  80.      */
  81.     private $notaryNumber;
  82.     /**
  83.      * @ORM\Column(type="integer", nullable=true)
  84.      *
  85.      * @JMS\Exclude()
  86.      */
  87.     private $moneyBalance;
  88.     /**
  89.      * @ORM\Column(type="float", scale=2, nullable=true)
  90.      *
  91.      * @JMS\Exclude()
  92.      */
  93.     private $bonusBalance;
  94.     /**
  95.      * @ORM\Column(type="float", scale=2, nullable=true)
  96.      *
  97.      * @JMS\Exclude()
  98.      */
  99.     private $undrawableBonusBalance;
  100.     /**
  101.      * @ORM\Column(type="string", length=1255, nullable=true)
  102.      *
  103.      * @JMS\Type("string")
  104.      */
  105.     private $address;
  106.     /**
  107.      * @ORM\OneToMany(targetEntity=BalanceOperation::class, mappedBy="notary")
  108.      *
  109.      * @JMS\Exclude()
  110.      */
  111.     protected $balanceOperations;
  112.     /**
  113.      * @ORM\Column(type="integer", nullable=true)
  114.      *
  115.      * @JMS\Exclude()
  116.      */
  117.     protected $bitrixCompanyId;
  118.     /**
  119.      * @ORM\OneToOne(targetEntity=Worker::class, mappedBy="notary", cascade={"persist", "remove"})
  120.      *
  121.      * @JMS\Exclude()
  122.      */
  123.     private $worker;
  124.     /**
  125.      * @ORM\OneToOne(targetEntity=Referal::class, mappedBy="referalNotary")
  126.      *
  127.      * @JMS\Exclude()
  128.      */
  129.     private $referal;
  130.     /**
  131.      * @ORM\OneToOne(targetEntity=Refovod::class, mappedBy="refovodNotary")
  132.      *
  133.      * @JMS\Exclude()
  134.      */
  135.     private $refovod;
  136.     /**
  137.      * @ORM\OneToMany(targetEntity=NotaryNotification::class, mappedBy="notary")
  138.      *
  139.      * @JMS\Exclude()
  140.      */
  141.     private $notaryNotifications;
  142.     /**
  143.      * @ORM\Column(type="boolean", nullable=true)
  144.      *
  145.      * @JMS\Exclude()
  146.      */
  147.     private $isVip;
  148.     /**
  149.      * @ORM\Column(type="boolean")
  150.      *
  151.      * @JMS\Exclude()
  152.      */
  153.     private $payLinkReferralEnabled false;
  154.     /**
  155.      * @ORM\Column(type="datetime")
  156.      *
  157.      * @JMS\Exclude()
  158.      */
  159.     private $registrationDateTime;
  160.     /**
  161.      * @ORM\Column(type="boolean", nullable=true)
  162.      *
  163.      * @JMS\Exclude()
  164.      */
  165.     private $hideBanner;
  166.     /**
  167.      * @ORM\Column(type="boolean", options={"default" : false}, nullable=false)
  168.      *
  169.      * @JMS\Exclude()
  170.      */
  171.     private $isDevelop false;
  172.     /**
  173.      * @ORM\Column(type="string", length=1255, nullable=true)
  174.      *
  175.      * @JMS\Type("string")
  176.      */
  177.     private $bonusProgramm;
  178.     /**
  179.      * @ORM\Column(type="string", length=255, options={"default" : "1,2,3,-7"}, nullable=false)
  180.      *
  181.      * @JMS\Type("string")
  182.      */
  183.     private string $announcementConfig self::ANNOUNCEMENT_CONFIG_DEFAULT;
  184.     /**
  185.      * @ORM\Column(type="string", length=1255, nullable=true, options={"comment": "Идентификатор нотариуса в единой информационной системе нотариата России, хотя изначально заводилось только как идентификатор в Инфонот/Экспресс"})
  186.      *
  187.      * @JMS\Exclude()
  188.      */
  189.     private $infoNotAccountId null;
  190.     /**
  191.      * @ORM\Column(type="string", length=255, nullable=true, options={"comment": "Номер регистрации нотариуса в министерстве юстиции"})
  192.      * @JMS\Exclude()
  193.      */
  194.     private $justiceMinistryNumber null;
  195.     /**
  196.      * @ORM\Column(type="integer", options={"default" : 0}, nullable=false)
  197.      *
  198.      * @JMS\Exclude()
  199.      */
  200.     private int $showWelcomeModal 0;
  201.     /**
  202.      * @ORM\Column(type="datetime", nullable=true)
  203.      */
  204.     private $connectToInfonotDateTime;
  205.     /**
  206.      * @ORM\ManyToOne(targetEntity=Service::class, inversedBy="notaries")
  207.      * @ORM\JoinColumn(nullable=true)
  208.      */
  209.     private ?Service $service null;
  210.     /**
  211.      * @ORM\OneToOne(targetEntity=NotaryAddress::class, mappedBy="notary", cascade={"persist", "remove"})
  212.      * @JMS\Exclude()
  213.      */
  214.     private ?NotaryAddress $notaryAddress null;
  215.     public function __construct()
  216.     {
  217.         $this->clients = new ArrayCollection();
  218.         $this->clients2 = new ArrayCollection();
  219.         $this->balanceOperations = new ArrayCollection();
  220.         $this->notaryNotifications = new ArrayCollection();
  221.     }
  222.     /**
  223.      * @return mixed
  224.      */
  225.     public function getRegistrationDateTime(): ?\DateTimeInterface
  226.     {
  227.         return $this->registrationDateTime;
  228.     }
  229.     /**
  230.      * @param \DateTimeInterface $sendDateTime
  231.      * @return $this
  232.      */
  233.     public function setRegistrationDateTime(\DateTimeInterface $sendDateTime): self
  234.     {
  235.         $this->registrationDateTime $sendDateTime;
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return Collection<int, Client2>
  240.      */
  241.     public function getClients2(): Collection
  242.     {
  243.         return $this->clients2;
  244.     }
  245.     /**
  246.      * @return Collection|Client[]
  247.      */
  248.     public function getClients(): Collection
  249.     {
  250.         return $this->clients;
  251.     }
  252.     public function addClient(Client $client): self
  253.     {
  254.         if (!$this->clients->contains($client)) {
  255.             $this->clients[] = $client;
  256.             $client->setNotary($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeClient(Client $client): self
  261.     {
  262.         if ($this->clients->contains($client)) {
  263.             $this->clients->removeElement($client);
  264.             // set the owning side to null (unless already changed)
  265.             if ($client->getNotary() === $this) {
  266.                 $client->setNotary(null);
  267.             }
  268.         }
  269.         return $this;
  270.     }
  271.     public function getNotaryNumber(): ?string
  272.     {
  273.         return $this->notaryNumber;
  274.     }
  275.     public function setNotaryNumber(string $notaryNumber): self
  276.     {
  277.         $this->notaryNumber $notaryNumber;
  278.         return $this;
  279.     }
  280.     public function getBalance(): ?float
  281.     {
  282.         return $this->getBonusBalance() + $this->getMoneyBalance() + $this->getUndrawableBonusBalance();
  283.     }
  284.     public function getMoneyBalance(): int
  285.     {
  286.         return $this->moneyBalance ?? 0;
  287.     }
  288.     public function setMoneyBalance(?int $moneyBalance): self
  289.     {
  290.         $this->moneyBalance $moneyBalance;
  291.         return $this;
  292.     }
  293.     public function addMoneyToBalance(int $money): self
  294.     {
  295.         $this->moneyBalance $this->getMoneyBalance() + $money;
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return mixed
  300.      */
  301.     public function getName()
  302.     {
  303.         return $this->name;
  304.     }
  305.     /**
  306.      * @param mixed $name
  307.      */
  308.     public function setName($name): void
  309.     {
  310.         $this->name $name;
  311.     }
  312.     /**
  313.      * @return mixed
  314.      */
  315.     public function getSurname()
  316.     {
  317.         return $this->surname;
  318.     }
  319.     /**
  320.      * @param mixed $surname
  321.      */
  322.     public function setSurname($surname): void
  323.     {
  324.         $this->surname $surname;
  325.     }
  326.     /**
  327.      * @return mixed
  328.      */
  329.     public function getPatronymic()
  330.     {
  331.         return $this->patronymic;
  332.     }
  333.     /**
  334.      * @param mixed $patronymic
  335.      */
  336.     public function setPatronymic($patronymic): void
  337.     {
  338.         $this->patronymic $patronymic;
  339.     }
  340.     /**
  341.      * @return mixed
  342.      */
  343.     public function getPhone()
  344.     {
  345.         return $this->phone;
  346.     }
  347.     /**
  348.      * @param mixed $phone
  349.      */
  350.     public function setPhone($phone): void
  351.     {
  352.         $this->phone $phone;
  353.     }
  354.     /**
  355.      * @see UserInterface
  356.      */
  357.     public function getRoles(): array
  358.     {
  359.         $roles $this->roles;
  360.         // guarantee every user at least has ROLE_USER
  361.         if (!in_array('ROLE_REFOVOD'$roles)) {
  362.             $roles[] = 'ROLE_NOTARY';
  363.         }
  364.         return array_unique($roles);
  365.     }
  366.     
  367.     public function isWorker(): bool
  368.     {
  369.         return in_array('ROLE_WORKER'$this->getRoles());
  370.     }
  371.     /**
  372.      * @return float|null
  373.      */
  374.     public function getUndrawableBonusBalance(): ?float
  375.     {
  376.         return $this->undrawableBonusBalance ?? 0;
  377.     }
  378.     /**
  379.      * @param ?float $undrawableBonusBalance
  380.      * @return Notary
  381.      */
  382.     public function setUndrawableBonusBalance(?float $undrawableBonusBalance): self
  383.     {
  384.         $this->undrawableBonusBalance $undrawableBonusBalance;
  385.         return $this;
  386.     }
  387.     public function jsonSerialize(): array
  388.     {
  389.         return [
  390.             'id'         => $this->getId(),
  391.             'email'      => $this->getEmail(),
  392.             'name'       => $this->getName(),
  393.             'patronymic' => $this->getPatronymic(),
  394.             'surname'    => $this->getSurname(),
  395.             'phone'      => $this->getPhone(),
  396.             'refovodCode'      => $this->getRefovodCode(),
  397.             'address'    => $this->getAddress(),
  398.         ];
  399.     }
  400.     public function getAddress(): ?string
  401.     {
  402.         return $this->address;
  403.     }
  404.     public function setAddress(?string $address): self
  405.     {
  406.         $this->address $address;
  407.         return $this;
  408.     }
  409.     public function getRefovodCode(): ?string
  410.     {
  411.         return $this->refovodCode;
  412.     }
  413.     public function setRefovodCode(?string $refovodCode): self
  414.     {
  415.         $this->refovodCode $refovodCode;
  416.         return $this;
  417.     }
  418.     /**
  419.      * @return Collection|BalanceOperation[]
  420.      */
  421.     public function getBalanceOperations(): Collection
  422.     {
  423.         return $this->balanceOperations;
  424.     }
  425.     public function addBalanceOperation(BalanceOperation $balanceOperation): self
  426.     {
  427.         if (!$this->balanceOperations->contains($balanceOperation)) {
  428.             $this->balanceOperations[] = $balanceOperation;
  429.             $balanceOperation->setNotary($this);
  430.         }
  431.         return $this;
  432.     }
  433.     public function removeBalanceOperation(BalanceOperation $balanceOperation): self
  434.     {
  435.         if ($this->balanceOperations->contains($balanceOperation)) {
  436.             $this->balanceOperations->removeElement($balanceOperation);
  437.             // set the owning side to null (unless already changed)
  438.             if ($balanceOperation->getNotary() === $this) {
  439.                 $balanceOperation->setNotary(null);
  440.             }
  441.         }
  442.         return $this;
  443.     }
  444.     /**
  445.      * @return mixed
  446.      */
  447.     public function getBonusBalance()
  448.     {
  449.         return $this->bonusBalance ?? 0;
  450.     }
  451.     /**
  452.      * @param mixed $bonusBalance
  453.      */
  454.     public function setBonusBalance($bonusBalance): void
  455.     {
  456.         $this->bonusBalance $bonusBalance;
  457.     }
  458.     public function getBitrixCompanyId(): ?int
  459.     {
  460.         return $this->bitrixCompanyId;
  461.     }
  462.     public function setBitrixCompanyId(?int $bitrixCompanyId): self
  463.     {
  464.         $this->bitrixCompanyId $bitrixCompanyId;
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return array
  469.      */
  470.     public function serializeBitrix(): array
  471.     {
  472.         return [
  473.             'NAME'            => $this->getName(),
  474.             'SECOND_NAME'     => $this->getPatronymic(),
  475.             'LAST_NAME'       => $this->getSurname(),
  476.             'EMAIL'           => [
  477.                 "n0" => [
  478.                     "VALUE"      => $this->getEmail(),
  479.                     "VALUE_TYPE" => "WORK",
  480.                 ]
  481.             ],
  482.             'ADDRESS'         => $this->getAddress(),
  483.             'PHONE'           => [
  484.                 'n0' => [
  485.                     "VALUE"      => $this->formatPhoneToB24(),
  486.                     "VALUE_TYPE" => "WORK",
  487.                 ]
  488.             ],
  489.             "NOTARY_NUMBER"   => $this->getNotaryNumber(),
  490.             "TYPE_ID"         => "CLIENT",
  491.             "UF_CRM_ISBANNED" => $this->isBanned(),
  492.         ];
  493.     }
  494.     /**
  495.      * Сериализация для отправки данных компании
  496.      *
  497.      * @return array
  498.      */
  499.     public function serializeBitrixCompany()
  500.     {
  501.         $data = [
  502.             "COMPANY_TYPE"                  => "1",
  503.             "TITLE"                         => 'Нотариус ' $this->getFIO(),
  504.             "ADDRESS"                       => $this->getAddress(),
  505.             "HAS_EMAIL"                     => "Y",// Если есть емл.
  506.             "ASSIGNED_BY_ID"                => BitrixSender::ASSIGNED_SUPER_ADMIN_IN_BITRIX,
  507.             'EMAIL'                         => [
  508.                 "n0" => [
  509.                     "VALUE"      => $this->getEmail(),
  510.                     "VALUE_TYPE" => "WORK",
  511.                 ]
  512.             ],
  513.             "UF_CRM_NOTARYNUMBER"            => $this->getNotaryNumberUis()?->value,
  514.             "UF_CRM_BONUSACCOUNT"            => $this->getBonusBalance() ?? 0,
  515.             "UF_CRM_UNDRAWABLEBONUSACCOUNT"  => $this->getUndrawableBonusBalance() ?? 0,
  516.             "UF_CRM_MAINACCOUNT"             => $this->getBalance() ?? 0,
  517.             "UF_CRM_MONEYACCOUNT"            => $this->getMoneyBalance() ?? 0,
  518.             "UF_CRM_ISBANNED"                => $this->isBanned(),
  519.             "UF_CRM_JUSTICE_MINISTRY_NUMBER" => $this->getJusticeMinistryNumber()?->value,
  520.             "UF_CRM_SERVICE_ID"              => $this->getId(),
  521.         ];
  522.         
  523.         // DEV-350
  524.         if ($this->isRealNotary()) {
  525.             $data['UF_CRM_REGISTRATION_STATUS'] = NotaryCompanyRegistrationStatus::REGISTERED->value;
  526.         }
  527.         if ($this->getPhone()) {
  528.             $data["HAS_PHONE"] = "Y";
  529.             $data['PHONE'] = [
  530.                 'n0' => [
  531.                     "VALUE"      => $this->getPhone(),
  532.                     "VALUE_TYPE" => "WORK",
  533.                 ],
  534.             ];
  535.         }
  536.         $data["UF_CRM_REFERAL"] = "N";
  537.         if ($referal $this->getReferal()) {
  538.             $data["UF_CRM_REFERAL"] = "Y";
  539.             $data["UF_CRM_REFERAL_REFERER"] = $referal->getRefovod()->getRefovodNotary()->getBitrixCompanyId();
  540.         }
  541.         $data["UF_CRM_REFERER"] = "N";
  542.         if ($refovod $this->getRefovod()) {
  543.             $data["UF_CRM_REFERER"] = "Y";
  544.             $data['UF_CRM_REFERER_REFERALS'] = false;
  545.             if ($referals $refovod->getReferals()) {
  546.                 $data['UF_CRM_REFERER_REFERALS'] = false;
  547.                 if (count($referals) > 0) {
  548.                     foreach ($referals as $referal) {
  549.                         $data['UF_CRM_REFERER_REFERALS'][] = $referal->getReferalNotary()->getBitrixCompanyId();
  550.                     }
  551.                 }
  552.             }
  553.         }
  554.         return $data;
  555.     }
  556.     public function getWorker(): ?Worker
  557.     {
  558.         return $this->worker;
  559.     }
  560.     public function setWorker(?Worker $worker): self
  561.     {
  562.         $this->worker $worker;
  563.         // set (or unset) the owning side of the relation if necessary
  564.         $newNotary null === $worker null $this;
  565.         if ($worker->getNotary() !== $newNotary) {
  566.             $worker->setNotary($newNotary);
  567.         }
  568.         return $this;
  569.     }
  570.     public function getReferal(): ?Referal
  571.     {
  572.         return $this->referal;
  573.     }
  574.     public function setReferal(?Referal $referal): self
  575.     {
  576.         $this->referal $referal;
  577.         // set (or unset) the owning side of the relation if necessary
  578.         $newReferalNotary null === $referal null $this;
  579.         if ($referal && $referal->getReferalNotary() !== $newReferalNotary) {
  580.             $referal->setReferalNotary($newReferalNotary);
  581.         }
  582.         return $this;
  583.     }
  584.     public function getRefovod(): ?Refovod
  585.     {
  586.         return $this->refovod;
  587.     }
  588.     public function setRefovod(?Refovod $refovod): self
  589.     {
  590.         $this->refovod $refovod;
  591.         // set (or unset) the owning side of the relation if necessary
  592.         $newRefovodNotary null === $refovod null $this;
  593.         if ($refovod->getRefovodNotary() !== $newRefovodNotary) {
  594.             $refovod->setRefovodNotary($newRefovodNotary);
  595.         }
  596.         return $this;
  597.     }
  598.     /**
  599.      * @return Collection|NotaryNotification[]
  600.      */
  601.     public function getNotaryNotifications(): Collection
  602.     {
  603.         return $this->notaryNotifications;
  604.     }
  605.     public function addNotaryNotification(NotaryNotification $notaryNotification): self
  606.     {
  607.         if (!$this->notaryNotifications->contains($notaryNotification)) {
  608.             $this->notaryNotifications[] = $notaryNotification;
  609.             $notaryNotification->setNotary($this);
  610.         }
  611.         return $this;
  612.     }
  613.     public function removeNotaryNotification(NotaryNotification $notaryNotification): self
  614.     {
  615.         if ($this->notaryNotifications->removeElement($notaryNotification)) {
  616.             // set the owning side to null (unless already changed)
  617.             if ($notaryNotification->getNotary() === $this) {
  618.                 $notaryNotification->setNotary(null);
  619.             }
  620.         }
  621.         return $this;
  622.     }
  623.     public function getIsVip(): ?bool
  624.     {
  625.         return $this->isVip;
  626.     }
  627.     public function setIsVip(?bool $isVip): self
  628.     {
  629.         $this->isVip $isVip;
  630.         return $this;
  631.     }
  632.     public function getPayLinkReferralEnabled(): ?bool
  633.     {
  634.         return $this->payLinkReferralEnabled;
  635.     }
  636.     public function setPayLinkReferralEnabled(bool $payLinkReferralEnabled): self
  637.     {
  638.         $this->payLinkReferralEnabled $payLinkReferralEnabled;
  639.         return $this;
  640.     }
  641.     public function getHideBanner(): ?bool
  642.     {
  643.         return $this->hideBanner;
  644.     }
  645.     public function setHideBanner(?bool $hideBanner): self
  646.     {
  647.         $this->hideBanner $hideBanner;
  648.         return $this;
  649.     }
  650.     /**
  651.      * @return int
  652.      */
  653.     public function getShowWelcomeModal()
  654.     {
  655.         return $this->showWelcomeModal ?? 0;
  656.     }
  657.     /**
  658.      * @param mixed $showWelcomeModal
  659.      * @return Notary
  660.      */
  661.     public function setShowWelcomeModal(int $showWelcomeModal)
  662.     {
  663.         $this->showWelcomeModal $showWelcomeModal;
  664.         return $this;
  665.     }
  666.     /**
  667.      * @return bool
  668.      */
  669.     public function isDevelop(): bool
  670.     {
  671.         return $this->isDevelop;
  672.     }
  673.     /**
  674.      * @param bool $isDevelop
  675.      * @return Notary
  676.      */
  677.     public function setIsDevelop(bool $isDevelop): Notary
  678.     {
  679.         $this->isDevelop $isDevelop;
  680.         return $this;
  681.     }
  682.     private function formatPhoneToB24(): string
  683.     {
  684.         $str $this->getPhone() ?? '';
  685.         return preg_replace("/[^+0-9]/"''$str);
  686.     }
  687.     /**
  688.      * @return mixed
  689.      */
  690.     public function getBonusProgramm()
  691.     {
  692.         return $this->bonusProgramm ?? '';
  693.     }
  694.     /**
  695.      * @param mixed $bonusProgramm
  696.      * @return Notary
  697.      */
  698.     public function setBonusProgramm($bonusProgramm)
  699.     {
  700.         $this->bonusProgramm $bonusProgramm;
  701.         return $this;
  702.     }
  703.     /**
  704.      * @return mixed
  705.      * @deprecated Использовать getNotaryNumberUis
  706.      */
  707.     public function getInfoNotAccountId()
  708.     {
  709.         return $this->infoNotAccountId;
  710.     }
  711.     /**
  712.      * @param mixed $infoNotAccountId
  713.      * @return Notary
  714.      * @deprecated Использовать setNotaryNumberUis
  715.      */
  716.     public function setInfoNotAccountId($infoNotAccountId)
  717.     {
  718.         $this->infoNotAccountId $infoNotAccountId;
  719.         return $this;
  720.     }
  721.     public function setNotaryNumberUis(NotaryNumberUis $notaryNumberUis): self
  722.     {
  723.         $this->infoNotAccountId $notaryNumberUis->value;
  724.         if (!$this->notaryNumber) {
  725.             $this->notaryNumber $notaryNumberUis->value;
  726.         }
  727.         return $this;
  728.     }
  729.     public function getNotaryNumberUis(): ?NotaryNumberUis
  730.     {
  731.         try {
  732.             return NotaryNumberUis::fromString($this->infoNotAccountId);
  733.         } catch (\Throwable $_) {
  734.         }
  735.         try {
  736.             return NotaryNumberUis::fromString($this->notaryNumber);
  737.         } catch (\Throwable $_) {
  738.             return null;
  739.         }
  740.     }
  741.     public function setJusticeMinistryNumber(NotaryJusticeMinistryNumber $number): self
  742.     {
  743.         $this->justiceMinistryNumber $number->value;
  744.         return $this;
  745.     }
  746.     public function getJusticeMinistryNumber(): ?NotaryJusticeMinistryNumber
  747.     {
  748.         return $this->justiceMinistryNumber NotaryJusticeMinistryNumber::fromString($this->justiceMinistryNumber) : null;
  749.     }
  750.     public function getSurnameAndInitials(): string
  751.     {
  752.         return "{$this->getSurname()} " mb_substr($this->getName(), 01) . '.' mb_substr($this->getPatronymic(), 01);
  753.     }
  754.     public function getFIO(): string
  755.     {
  756.         return "{$this->getSurname()} {$this->getName()} {$this->getPatronymic()}";
  757.     }
  758.     public function jsonSerializeInfoNot(): array
  759.     {
  760.         return [
  761.             'id'      => $this->getNotaryNumberUis()?->value,
  762.             'balance' => $this->getBalance(),
  763.         ];
  764.     }
  765.     public function getConnectToInfonotDateTime(): ?\DateTimeInterface
  766.     {
  767.         return $this->connectToInfonotDateTime;
  768.     }
  769.     public function setConnectToInfonotDateTime(?\DateTimeInterface $connectToInfonotDateTime): self
  770.     {
  771.         $this->connectToInfonotDateTime $connectToInfonotDateTime;
  772.         return $this;
  773.     }
  774.     public function getAnnouncementConfig(): string
  775.     {
  776.         return $this->announcementConfig;
  777.     }
  778.     public function setAnnouncementConfig(string $announcementConfig): self
  779.     {
  780.         $this->announcementConfig $announcementConfig;
  781.         return $this;
  782.     }
  783.     public function getService(): ?Service
  784.     {
  785.         return $this->service;
  786.     }
  787.     public function setService(?Service $service): self
  788.     {
  789.         $this->service $service;
  790.         return $this;
  791.     }
  792.     public function isRealNotary()
  793.     {
  794.         return !empty($this->getNotaryNumber()) 
  795.             || !empty($this->getJusticeMinistryNumber());
  796.     }
  797.     public function getNotaryAddress(): ?NotaryAddress
  798.     {
  799.         return $this->notaryAddress;
  800.     }
  801.     public function setNotaryAddress(?NotaryAddress $notaryAddress): self
  802.     {
  803.         $this->notaryAddress $notaryAddress;
  804.         // set (or unset) the owning side of the relation if necessary
  805.         $newNotary null === $notaryAddress null $this;
  806.         if ($notaryAddress && $notaryAddress->getNotary() !== $newNotary) {
  807.             $notaryAddress->setNotary($newNotary);
  808.         }
  809.         return $this;
  810.     }
  811. }