src/Entity/Account.php line 93

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\Criteria;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use MedBrief\MSR\Controller\Account\Managers;
  11. use MedBrief\MSR\Controller\Account\UserRestrictedAccounts;
  12. use MedBrief\MSR\Entity\MatterRequest\MatterRequestDefaults;
  13. use MedBrief\MSR\Repository\AccountRepository;
  14. use MedBrief\MSR\Service\MatterTypeAwareInterface;
  15. use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. /**
  19. * @ApiResource(
  20. * collectionOperations={
  21. * "get"={
  22. * "access_control"="is_granted('CREATE_MATTER_REQUEST')",
  23. * "method"="GET",
  24. * "path"="/accounts",
  25. * "controller"=UserRestrictedAccounts::class,
  26. * "defaults"={"_api_receive"=false},
  27. * "openapi_context"={
  28. * "summary"="Retrieves all Account (Client Area) resources available.",
  29. * "description"="Retrieves all Account (Client Area) resources available. To be used in the 'clientAreaId' field when creating a Matter Request.",
  30. * }
  31. * },
  32. * "client_areas"={
  33. * "access_control"="is_granted('CREATE_MATTER_REQUEST')",
  34. * "method"="GET",
  35. * "path"="/client-areas",
  36. * "controller"=UserRestrictedAccounts::class,
  37. * "defaults"={"_api_receive"=false},
  38. * "normalization_context"={"groups"={"client_area:read"}},
  39. * "openapi_context"={
  40. * "summary"="Retrieves all Account (Client Area) resources available.",
  41. * "description"="Retrieves all Account (Client Area) resources available. See [Client Areas](/docs/api/detail#client-areas)",
  42. * }
  43. * }
  44. * },
  45. * itemOperations={
  46. * "get"={"access_control"="is_granted('READ', object)"},
  47. * "managers_get"={
  48. * "access_control"="is_granted('CREATE_MATTER_REQUEST')",
  49. * "method"="GET",
  50. * "path"="/accounts/{id}/managers",
  51. * "controller"=Managers::class,
  52. * "openapi_context"={
  53. * "summary"="Retrieves all User resources that can be assigned as Matter Manager.",
  54. * "description"="Retrieves a list of User resources specific to the specified Account (Client Area) that can be assigned as a Matter Manager on a Matter Request. To be used in the 'manager' field when creating a Matter Request.",
  55. * "responses"={
  56. * "200"={
  57. * "description"="A collection of User resources",
  58. * "content"={
  59. * "application/ld+json"={
  60. * "schema"={
  61. * "$ref"="#/components/schemas/User.jsonld-user.read"
  62. * }
  63. * },
  64. * "application/json"={
  65. * "schema"={
  66. * "$ref"="#/components/schemas/User-user.read"
  67. * }
  68. * }
  69. * }
  70. * }
  71. * }
  72. * }
  73. * },
  74. * },
  75. * attributes={
  76. * "normalization_context"={"groups"={"account:read"}},
  77. * }
  78. * )
  79. *
  80. * @ORM\Table(name="account")
  81. *
  82. * @ORM\Entity(repositoryClass=AccountRepository::class)
  83. *
  84. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  85. *
  86. * @Audit\Auditable
  87. *
  88. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  89. */
  90. class Account implements MatterTypeAwareInterface
  91. {
  92. use FilterableClassConstantsTrait;
  93. public const INVOICE_BILLING_FREQUENCY_MONTHLY = 1;
  94. public const INVOICE_BILLING_FREQUENCY_QUARTERLY = 2;
  95. public const INVOICE_BILLING_FREQUENCY_START_OF_MATTER = 3;
  96. public const INVOICE_TYPE_INDIVIDUAL_MATTER = 1;
  97. public const INVOICE_TYPE_CONSOLIDATED = 2;
  98. // Default role options
  99. public const DEFAULT_ROLE_ADMINISTRATOR = 'ADMINISTRATOR';
  100. public const DEFAULT_ROLE_SUPERADMINISTRATOR = 'SUPERADMINISTRATOR';
  101. public const DEFAULT_ROLE_PROJECTMANAGER = 'PROJECTMANAGER';
  102. public const DEFAULT_ROLE_SORTER = 'SORTER';
  103. // Only has access to the old matter creation form
  104. public const MATTER_CREATION_PROCESS_CLASSIC = 'classic';
  105. public const MATTER_CREATION_PROCESS_CLASSIC__LABEL = 'Classic';
  106. // Only has access to the new matter creation form
  107. public const MATTER_CREATION_PROCESS_STANDARD = 'standard';
  108. public const MATTER_CREATION_PROCESS_STANDARD__LABEL = 'Standard';
  109. // Has access to both the old and new matter creation form
  110. public const MATTER_CREATION_PROCESS_ALL = 'all';
  111. public const MATTER_CREATION_PROCESS_ALL__LABEL = 'Standard & Classic';
  112. // Country of Registration options
  113. public const COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES = 'england_and_wales';
  114. public const COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES__LABEL = 'England and Wales';
  115. public const COUNTRY_OF_REGISTRATION_SCOTLAND = 'scotland';
  116. public const COUNTRY_OF_REGISTRATION_SCOTLAND__LABEL = 'Scotland';
  117. public const COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND = 'northern_ireland';
  118. public const COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND__LABEL = 'Northern Ireland';
  119. // Match Opt In options
  120. public const MATCH_OPT_IN_NONE = 'none';
  121. public const MATCH_OPT_IN_NONE__LABEL = 'None';
  122. public const MATCH_OPT_IN_ALL_CLIENT_USERS = 'all_client_users';
  123. public const MATCH_OPT_IN_ALL_CLIENT_USERS__LABEL = 'All Client Users';
  124. public const MATCH_OPT_IN_SPECIFIC_USERS = 'specific_users';
  125. public const MATCH_OPT_IN_SPECIFIC_USERS__LABEL = 'Specific Users';
  126. // Insights Opt In options
  127. public const INSIGHTS_OPT_IN_NONE = 'none';
  128. public const INSIGHTS_OPT_IN_NONE__LABEL = 'None';
  129. public const INSIGHTS_OPT_IN_ALL_CLIENT_USERS = 'all_client_users';
  130. public const INSIGHTS_OPT_IN_ALL_CLIENT_USERS__LABEL = 'All Client Users';
  131. public const INSIGHTS_OPT_IN_SPECIFIC_USERS = 'specific_users';
  132. public const INSIGHTS_OPT_IN_SPECIFIC_USERS__LABEL = 'Specific Users';
  133. /**
  134. * @var ContactableAddress
  135. *
  136. * This field is unmapped, and is purely here for the API.
  137. *
  138. * @Groups({"account:read", "matter_request:read"})
  139. */
  140. protected $returnDetailsAddress;
  141. /**
  142. * @var string
  143. *
  144. * @ORM\Column(name="matterCreationProcess", type="string", nullable=true)
  145. */
  146. protected $matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
  147. /**
  148. * @var string|null
  149. *
  150. * @ORM\Column(name="custom_index_header", type="text", nullable=true)
  151. */
  152. protected $custom_index_header;
  153. /**
  154. * @var string|null
  155. *
  156. * @ORM\Column(name="standardIndexHeader", type="text", nullable=true)
  157. */
  158. protected $standardIndexHeader;
  159. /**
  160. * Indicates if the MedBrief logo should be hidden from the index produced.
  161. * The scenario for this is where clients sort their own records, or a sorting standard that
  162. * deviates from our standard sorting product.
  163. *
  164. * @var bool
  165. *
  166. * @ORM\Column(type="boolean", options={"default"=false})
  167. */
  168. protected $hideLogoFromIndex = false;
  169. /**
  170. * @Groups({"client_area:read"})
  171. *
  172. * @ORM\Column(name="id", type="bigint", nullable=false)
  173. *
  174. * @ORM\Id
  175. *
  176. * @ORM\GeneratedValue(strategy="IDENTITY")
  177. */
  178. private ?int $id;
  179. /**
  180. * @Groups({"account:read", "matter_request:read", "client_area:read"})
  181. *
  182. * @ORM\Column(name="name", type="string", length=155, nullable=false)
  183. */
  184. private ?string $name;
  185. /**
  186. * @var Collection
  187. *
  188. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Domain", mappedBy="account", cascade={"all"})
  189. */
  190. private $domains;
  191. /**
  192. * @var array|null
  193. *
  194. * @ORM\Column(name="allowed_license_levels", type="array", nullable=true)
  195. */
  196. private $allowed_license_levels;
  197. /**
  198. * @var string|null
  199. *
  200. * @ORM\Column(name="prefix", type="string", length=25, nullable=true)
  201. */
  202. private $prefix;
  203. /**
  204. * @var string|null
  205. *
  206. * @ORM\Column(name="legal_entity_name", type="text", nullable=true)
  207. */
  208. private $legal_entity_name = null;
  209. /**
  210. * Sets all service requests for this client not to come up for invoicing.
  211. *
  212. * @var bool
  213. *
  214. * @ORM\Column(name="hide_from_invoicing", type="boolean", options={"default"=false})
  215. */
  216. private $hide_from_invoicing;
  217. /**
  218. * @var string|null
  219. *
  220. * @ORM\Column(name="default_role", type="string", nullable=true)
  221. */
  222. private $default_role;
  223. /**
  224. * Holds the Account's payment terms value (in days) for adjusting
  225. * the due date on invoices automagically.
  226. *
  227. * @var int
  228. *
  229. * @ORM\Column(name="invoice_payment_terms", type="integer", nullable=true)
  230. */
  231. private $invoice_payment_terms;
  232. /**
  233. * @var int|null
  234. *
  235. * @ORM\Column(name="invoice_billing_frequency", type="integer", nullable=true)
  236. */
  237. private $invoice_billing_frequency;
  238. /**
  239. * @var int|null
  240. *
  241. * @ORM\Column(name="invoice_type", type="integer", nullable=true)
  242. */
  243. private $invoice_type;
  244. /**
  245. * The different UserNotifications disabled for this Client
  246. *
  247. * @var array
  248. *
  249. * @ORM\Column(name="disabled_notifications", type="array", nullable=true)
  250. */
  251. private $disabled_notifications = [];
  252. /**
  253. * A default sorting instruction for all the Account's sorting sessions.
  254. * This is visible to the sorter.
  255. *
  256. * @var SortingInstruction
  257. *
  258. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\SortingInstruction", inversedBy="account", cascade={"persist","remove"}, orphanRemoval=true)
  259. *
  260. * @ORM\JoinColumns({
  261. *
  262. * @ORM\JoinColumn(name="defaultSortingInstruction_id", referencedColumnName="id", unique=true)
  263. * })
  264. */
  265. private $defaultSortingInstruction;
  266. /**
  267. * Determines if a draft memo will be exported for the client on Sorting Session completions.
  268. *
  269. * @var bool
  270. *
  271. * @ORM\Column(name="requireMemo", type="boolean", options={"default"=false})
  272. */
  273. private $requireMemo = false;
  274. /**
  275. * Whether to require the user to enter a password on downloading a document or folder
  276. *
  277. * @var bool
  278. *
  279. * @ORM\Column(name="require_password_on_download", type="boolean", options={"default"=false})
  280. */
  281. private $require_password_on_download;
  282. /**
  283. * @var ArrayCollection
  284. *
  285. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\AccountSortingMemoPhrase", mappedBy="account", cascade={"all"})
  286. */
  287. private $accountSortingMemoPhrases;
  288. /**
  289. * @var MatterRequestDefaults
  290. *
  291. * @Groups({"account:read", "matter_request:read"})
  292. *
  293. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\MatterRequestDefaults", mappedBy="account")
  294. */
  295. private $matterRequestDefaults;
  296. /**
  297. * @var ContactableAddress
  298. *
  299. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
  300. *
  301. * @ORM\JoinColumns({
  302. *
  303. * @ORM\JoinColumn(name="billingAddress_id", referencedColumnName="id", unique=true)
  304. * })
  305. */
  306. private $billingAddress;
  307. /**
  308. * @var ContactableAddress
  309. */
  310. private $accountsAddress;
  311. /**
  312. * @var ContactableAddress
  313. *
  314. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
  315. *
  316. * @ORM\JoinColumns({
  317. *
  318. * @ORM\JoinColumn(name="physicalAddress_id", referencedColumnName="id", unique=true)
  319. * })
  320. */
  321. private $physicalAddress;
  322. /**
  323. * @var Collection
  324. *
  325. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\ContactableAddress", inversedBy="accounts", cascade={"persist"})
  326. *
  327. * @ORM\JoinTable(name="account_contactableaddress",
  328. * joinColumns={
  329. *
  330. * @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE")
  331. * },
  332. * inverseJoinColumns={
  333. * @ORM\JoinColumn(name="contactableaddress_id", referencedColumnName="id", onDelete="CASCADE")
  334. * }
  335. * )
  336. */
  337. private $offices;
  338. /**
  339. * @var string
  340. *
  341. * @ORM\Column(name="slug", type="string")
  342. *
  343. * @Gedmo\Slug(fields={"name"}, updatable=false, separator="_")
  344. */
  345. private $slug;
  346. /**
  347. * @var \DateTime
  348. *
  349. * @ORM\Column(name="created", type="datetime")
  350. *
  351. * @Gedmo\Timestampable(on="create")
  352. */
  353. private $created;
  354. /**
  355. * @var \DateTime
  356. *
  357. * @ORM\Column(name="updated", type="datetime")
  358. *
  359. * @Gedmo\Timestampable(on="update")
  360. */
  361. private $updated;
  362. /**
  363. * @var Collection
  364. *
  365. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Project", mappedBy="account", cascade={"all"})
  366. */
  367. private $projects;
  368. /**
  369. * @var Collection
  370. */
  371. private $addresses;
  372. /**
  373. * @var \DateTime
  374. *
  375. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  376. */
  377. private $deletedAt;
  378. /**
  379. * @var string
  380. */
  381. private $image;
  382. /**
  383. * @var string
  384. *
  385. * @ORM\Column(name="image_name", type="string", length=255, nullable=true)
  386. */
  387. private $image_name;
  388. /**
  389. * @var string|null
  390. */
  391. private $companyThumbnail = null;
  392. /**
  393. * @var string|null
  394. *
  395. * @ORM\Column(name="companyThumbnailName", type="string", length=255, nullable=true)
  396. *
  397. */
  398. private $companyThumbnailName = null;
  399. /**
  400. * @var string|null
  401. */
  402. private $companyLetterheadLogo = null;
  403. /**
  404. * @var string|null
  405. *
  406. * @ORM\Column(name="companyLetterheadLogoName", type="string", length=255, nullable=true)
  407. *
  408. */
  409. private $companyLetterheadLogoName = null;
  410. /**
  411. * Determines if an account can create/update batch requests and sort sessions.
  412. *
  413. * @var bool
  414. *
  415. * @ORM\Column(name="canCreateBatchAndSort", type="boolean", options={"default"=false})
  416. */
  417. private $canCreateBatchAndSort = false;
  418. /**
  419. * Determines if an account is able to use match.
  420. *
  421. * @var string
  422. *
  423. * @ORM\Column(name="matchOptIn", type="string", length=50, nullable=false)
  424. */
  425. private string $matchOptIn = self::MATCH_OPT_IN_NONE;
  426. /**
  427. * Determines if an account is able to use MedBrief Insights.
  428. *
  429. * @var string
  430. *
  431. * @ORM\Column(name="insightsOptIn", type="string", length=50, nullable=false)
  432. */
  433. private ?string $insightsOptIn = self::INSIGHTS_OPT_IN_NONE;
  434. /**
  435. * Determines the default value of the same field on a Project/Matter, when a new Project is created.
  436. *
  437. * @var bool
  438. *
  439. * @ORM\Column(name="allowExpertViewUnsortedRecords", type="boolean", options={"default"=false})
  440. */
  441. private $allowExpertViewUnsortedRecords = false;
  442. /**
  443. * Determines if the questions presented during the Matter Closure Wizard are optional.
  444. *
  445. * @var bool
  446. *
  447. * @ORM\Column(name="matterClosureQuestionsOptional", type="boolean", options={"default"=false})
  448. */
  449. private $matterClosureQuestionsOptional = false;
  450. /**
  451. * @var bool
  452. *
  453. * @ORM\Column(name="useParentClinicalSectionsOnly", type="boolean")
  454. */
  455. private $useParentClinicalSectionsOnly = false;
  456. /**
  457. * @ORM\ManyToOne(targetEntity=Firm::class, inversedBy="clientAreas")
  458. */
  459. private $firm;
  460. /**
  461. * @Groups({"account:read", "matter_request:read"})
  462. *
  463. * @ORM\Column(name="allowedMatterTypes", type="array", nullable=true)
  464. *
  465. * @Assert\Count(
  466. * min=1,
  467. * minMessage = "Please select an option.",
  468. * groups={"account:read", "matter_request:read"}
  469. * )
  470. */
  471. private array $allowedMatterTypes = [];
  472. /**
  473. * @ORM\OneToMany(targetEntity=LicenceRenewalTerm::class, mappedBy="account", orphanRemoval=true)
  474. *
  475. * @ORM\OrderBy({"effectiveDate" = "ASC"})
  476. *
  477. * When a new period is added, a new related service option for the same period should also be created and mapped.
  478. */
  479. private ?Collection $licenceRenewalTerms;
  480. /**
  481. * Sets whether any client level users, or users invited to the client's
  482. * matters should require 2FA to be enabled.
  483. *
  484. * @ORM\Column(type="boolean", options={"default"=false})
  485. */
  486. private bool $enforceTwoFactorAuth = false;
  487. /**
  488. * If enabled, allows the users that are forced to enabled 2FA via the
  489. * enforceTwoFactorAuth property to skip the requirement for the first
  490. * two (2) logins.
  491. *
  492. * @ORM\Column(type="boolean", options={"default"=false})
  493. */
  494. private bool $allowTwoFactorAuthGracePeriod = false;
  495. /**
  496. * If enabled, the account (client) is not liable for the disclosure fee,
  497. * the Recipient Firm is liable.
  498. *
  499. * @ORM\Column(type="boolean", options={"default"=false})
  500. */
  501. private bool $clientNotLiableForDisclosureFee = false;
  502. /**
  503. * @var string|null
  504. *
  505. * @ORM\Column(name="trading_name", type="text", nullable=true)
  506. */
  507. private $trading_name = null;
  508. /**
  509. * @var string|null
  510. *
  511. * @ORM\Column(name="company_registration_number", type="string", length=255, nullable=true)
  512. */
  513. private $company_registration_number = null;
  514. /**
  515. * @var string|null
  516. *
  517. * @ORM\Column(name="country_of_registration", type="string", length=255, nullable=true)
  518. */
  519. private $country_of_registration = null;
  520. /**
  521. * Constructor
  522. */
  523. public function __construct()
  524. {
  525. $this->domains = new ArrayCollection();
  526. $this->allowed_license_levels = [];
  527. $this->hide_from_invoicing = false;
  528. $this->require_password_on_download = false;
  529. $this->accountSortingMemoPhrases = new ArrayCollection();
  530. $this->matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
  531. $this->projects = new ArrayCollection();
  532. $this->offices = new ArrayCollection();
  533. $this->licenceRenewalTerms = new ArrayCollection();
  534. }
  535. public function __toString()
  536. {
  537. return $this->getName();
  538. }
  539. /**
  540. * Get id
  541. *
  542. * @return int
  543. */
  544. public function getId()
  545. {
  546. return $this->id;
  547. }
  548. /**
  549. * Set name
  550. *
  551. * @param string $name
  552. *
  553. * @return Account
  554. */
  555. public function setName($name)
  556. {
  557. $this->name = $name;
  558. return $this;
  559. }
  560. /**
  561. * Get name
  562. *
  563. * @return string
  564. */
  565. public function getName()
  566. {
  567. return $this->name;
  568. }
  569. /**
  570. * Add domains
  571. *
  572. * @param Domain $domains
  573. *
  574. * @return Account
  575. */
  576. public function addDomain(Domain $domains)
  577. {
  578. $this->domains[] = $domains;
  579. return $this;
  580. }
  581. /**
  582. * Remove domains
  583. *
  584. * @param Domain $domains
  585. */
  586. public function removeDomain(Domain $domains)
  587. {
  588. $this->domains->removeElement($domains);
  589. }
  590. /**
  591. * Get domains
  592. *
  593. * @return Collection
  594. */
  595. public function getDomains()
  596. {
  597. return $this->domains;
  598. }
  599. /**
  600. * Set slug
  601. *
  602. * @param string $slug
  603. *
  604. * @return Account
  605. */
  606. public function setSlug($slug)
  607. {
  608. $this->slug = $slug;
  609. return $this;
  610. }
  611. /**
  612. * Get slug
  613. *
  614. * @return string
  615. */
  616. public function getSlug()
  617. {
  618. return $this->slug;
  619. }
  620. /**
  621. * Set created
  622. *
  623. * @param \DateTime $created
  624. *
  625. * @return Account
  626. */
  627. public function setCreated($created)
  628. {
  629. $this->created = $created;
  630. return $this;
  631. }
  632. /**
  633. * Get created
  634. *
  635. * @return \DateTime
  636. */
  637. public function getCreated()
  638. {
  639. return $this->created;
  640. }
  641. /**
  642. * Set updated
  643. *
  644. * @param \DateTime $updated
  645. *
  646. * @return Account
  647. */
  648. public function setUpdated($updated)
  649. {
  650. $this->updated = $updated;
  651. return $this;
  652. }
  653. /**
  654. * Get updated
  655. *
  656. * @return \DateTime
  657. */
  658. public function getUpdated()
  659. {
  660. return $this->updated;
  661. }
  662. /**
  663. * Add projects
  664. *
  665. * @param Project $projects
  666. *
  667. * @return Account
  668. */
  669. public function addProject(Project $projects)
  670. {
  671. $this->projects[] = $projects;
  672. return $this;
  673. }
  674. /**
  675. * Remove projects
  676. *
  677. * @param Project $projects
  678. */
  679. public function removeProject(Project $projects)
  680. {
  681. $this->projects->removeElement($projects);
  682. }
  683. /**
  684. * Get projects
  685. *
  686. * @return Collection
  687. */
  688. public function getProjects()
  689. {
  690. return $this->projects;
  691. }
  692. public function getArchivedProjects()
  693. {
  694. $criteria = Criteria::create()
  695. ->where(Criteria::expr()->gt('archive_status', 0))
  696. ->orderBy(['name' => Criteria::ASC])
  697. ;
  698. return $this->getProjects()->matching($criteria);
  699. }
  700. public function getActiveProjects()
  701. {
  702. $criteria = Criteria::create()
  703. ->where(Criteria::expr()->eq('status', Project::STATUS_ACTIVE))
  704. ->orderBy(['name' => Criteria::ASC])
  705. ;
  706. return $this->getProjects()->matching($criteria);
  707. }
  708. public function getInactiveProjects()
  709. {
  710. $criteria = Criteria::create()
  711. ->where(Criteria::expr()->eq('status', Project::STATUS_INACTIVE))
  712. ->orderBy(['name' => Criteria::ASC])
  713. ;
  714. return $this->getProjects()->matching($criteria);
  715. }
  716. /**
  717. * Set invoice_billing_frequency
  718. *
  719. * @param string $invoiceBillingFrequency
  720. *
  721. * @return Account
  722. */
  723. public function setInvoiceBillingFrequency($invoiceBillingFrequency)
  724. {
  725. $this->invoice_billing_frequency = $invoiceBillingFrequency;
  726. return $this;
  727. }
  728. /**
  729. * Get invoice_billing_frequency
  730. *
  731. * @return string
  732. */
  733. public function getInvoiceBillingFrequency()
  734. {
  735. return $this->invoice_billing_frequency;
  736. }
  737. /**
  738. * Set invoice_type
  739. *
  740. * @param string $invoiceType
  741. *
  742. * @return Account
  743. */
  744. public function setInvoiceType($invoiceType)
  745. {
  746. $this->invoice_type = $invoiceType;
  747. return $this;
  748. }
  749. /**
  750. * Get invoice_type
  751. *
  752. * @return string
  753. */
  754. public function getInvoiceType()
  755. {
  756. return $this->invoice_type;
  757. }
  758. /**
  759. * Set billingAddress
  760. *
  761. * @param ContactableAddress $billingAddress
  762. *
  763. * @return Account
  764. */
  765. public function setBillingAddress(?ContactableAddress $billingAddress = null)
  766. {
  767. $this->billingAddress = $billingAddress;
  768. return $this;
  769. }
  770. /**
  771. * Get billingAddress
  772. *
  773. * @return ContactableAddress
  774. */
  775. public function getBillingAddress()
  776. {
  777. return $this->billingAddress;
  778. }
  779. /**
  780. * Set accountsAddress
  781. *
  782. * @param ContactableAddress $accountsAddress
  783. *
  784. * @return Account
  785. */
  786. public function setAccountsAddress(?ContactableAddress $accountsAddress = null)
  787. {
  788. $this->accountsAddress = $accountsAddress;
  789. return $this;
  790. }
  791. /**
  792. * Get accountsAddress
  793. *
  794. * @return ContactableAddress
  795. */
  796. public function getAccountsAddress()
  797. {
  798. return $this->accountsAddress;
  799. }
  800. /**
  801. * Set physicalAddress
  802. *
  803. * @param ContactableAddress $physicalAddress
  804. *
  805. * @return Account
  806. */
  807. public function setPhysicalAddress(?ContactableAddress $physicalAddress = null)
  808. {
  809. $this->physicalAddress = $physicalAddress;
  810. return $this;
  811. }
  812. /**
  813. * Get physicalAddress
  814. *
  815. * @return ContactableAddress
  816. */
  817. public function getPhysicalAddress()
  818. {
  819. return $this->physicalAddress;
  820. }
  821. /**
  822. * Add offices
  823. *
  824. * @param ContactableAddress $offices
  825. *
  826. * @return Account
  827. */
  828. public function addOffice(ContactableAddress $offices)
  829. {
  830. $this->offices[] = $offices;
  831. return $this;
  832. }
  833. /**
  834. * Remove offices
  835. *
  836. * @param ContactableAddress $offices
  837. */
  838. public function removeOffice(ContactableAddress $offices)
  839. {
  840. $this->offices->removeElement($offices);
  841. }
  842. /**
  843. * Get offices
  844. *
  845. * @return Collection
  846. */
  847. public function getOffices()
  848. {
  849. return $this->offices;
  850. }
  851. /**
  852. * Returns an array of permitted values for the invoice billing frequency field and their
  853. * associated labels,
  854. *
  855. * @return array
  856. */
  857. public static function getInvoiceBillingFrequencyOptions()
  858. {
  859. return [
  860. self::INVOICE_BILLING_FREQUENCY_MONTHLY => 'Monthly',
  861. self::INVOICE_BILLING_FREQUENCY_QUARTERLY => 'Quarterly',
  862. self::INVOICE_BILLING_FREQUENCY_START_OF_MATTER => 'At the start of the matter',
  863. ];
  864. }
  865. /**
  866. * Returns a human readable version of the invoice billing frequency
  867. *
  868. * @return string
  869. */
  870. public function getInvoiceBillingFrequencyName()
  871. {
  872. $options = self::getInvoiceBillingFrequencyOptions();
  873. return
  874. $options[$this->getInvoiceBillingFrequency()] ?? $this->getInvoiceBillingFrequency();
  875. }
  876. /**
  877. * Returns an array of permitted values for the invoice billing frequency field and their
  878. * associated labels,
  879. *
  880. * @return array
  881. */
  882. public static function getInvoiceTypeOptions()
  883. {
  884. return [
  885. self::INVOICE_TYPE_CONSOLIDATED => 'Consolidated',
  886. self::INVOICE_TYPE_INDIVIDUAL_MATTER => 'Individual Matter',
  887. ];
  888. }
  889. /**
  890. * Returns a human readable version of the invoice billing frequency
  891. *
  892. * @return string
  893. */
  894. public function getInvoiceTypeName()
  895. {
  896. $options = self::getInvoiceTypeOptions();
  897. return
  898. $options[$this->getInvoiceType()] ?? $this->getInvoiceType();
  899. }
  900. /**
  901. * Set deletedAt
  902. *
  903. * @param \DateTime $deletedAt
  904. *
  905. * @return Account
  906. */
  907. public function setDeletedAt($deletedAt)
  908. {
  909. $this->deletedAt = $deletedAt;
  910. return $this;
  911. }
  912. /**
  913. * Get deletedAt
  914. *
  915. * @return \DateTime
  916. */
  917. public function getDeletedAt()
  918. {
  919. return $this->deletedAt;
  920. }
  921. /**
  922. * Set image
  923. *
  924. * @param string $image
  925. *
  926. * @return Account
  927. */
  928. public function setImage($image)
  929. {
  930. if (null !== $image) {
  931. // It is required that at least one field changes if you are using doctrine
  932. // otherwise the event listeners won't be called and the file is lost
  933. $this->updated = new \DateTimeImmutable();
  934. }
  935. $this->image = $image;
  936. return $this;
  937. }
  938. /**
  939. * Indicates whether or not this user has an image
  940. *
  941. * @return bool
  942. */
  943. public function hasImage()
  944. {
  945. // note that we use the imageName field because the image field will be
  946. // populated with the gaufrette file location immediately on upload
  947. // even if the upload fails. So if you call this function on the user
  948. // before it is peristed it may give you a false positive.
  949. $image = $this->getImageName();
  950. return !empty($image);
  951. }
  952. /**
  953. * Get image
  954. *
  955. * @return string
  956. */
  957. public function getImage()
  958. {
  959. return $this->image;
  960. }
  961. /**
  962. * Set image_name
  963. *
  964. * @param string $imageName
  965. *
  966. * @return Account
  967. */
  968. public function setImageName($imageName)
  969. {
  970. $this->image_name = $imageName;
  971. return $this;
  972. }
  973. /**
  974. * Get image_name
  975. *
  976. * @return string
  977. */
  978. public function getImageName()
  979. {
  980. return $this->image_name;
  981. }
  982. /**
  983. * Set companyThumbnail
  984. *
  985. * @param string $companyThumbnail
  986. *
  987. * @return Account
  988. */
  989. public function setCompanyThumbnail($companyThumbnail)
  990. {
  991. if (null !== $companyThumbnail) {
  992. // It is required that at least one field changes if you are using doctrine
  993. // otherwise the event listeners won't be called and the file is lost
  994. $this->updated = new \DateTimeImmutable();
  995. }
  996. $this->companyThumbnail = $companyThumbnail;
  997. return $this;
  998. }
  999. /**
  1000. * Get companyThumbnail
  1001. *
  1002. * @return string
  1003. */
  1004. public function getCompanyThumbnail()
  1005. {
  1006. return $this->companyThumbnail;
  1007. }
  1008. /**
  1009. * Indicates whether or not this account has a company thumbnail
  1010. *
  1011. * @return bool
  1012. */
  1013. public function hasCompanyThumbnail()
  1014. {
  1015. // note that we use the companyThumbnailName field because the companyThumbnail field will be
  1016. // populated with the gaufrette file location immediately on upload
  1017. // even if the upload fails. So if you call this function on the user
  1018. // before it is persisted it may give you a false positive.
  1019. $companyThumbnail = $this->getCompanyThumbnailName();
  1020. return !empty($companyThumbnail);
  1021. }
  1022. /**
  1023. * Set companyThumbnailName
  1024. *
  1025. * @param string $companyThumbnailName
  1026. *
  1027. * @return Account
  1028. */
  1029. public function setCompanyThumbnailName($companyThumbnailName)
  1030. {
  1031. $this->companyThumbnailName = $companyThumbnailName;
  1032. return $this;
  1033. }
  1034. /**
  1035. * Get companyThumbnailName
  1036. *
  1037. * @return string
  1038. */
  1039. public function getCompanyThumbnailName()
  1040. {
  1041. return $this->companyThumbnailName;
  1042. }
  1043. /**
  1044. * Set companyLetterheadLogo
  1045. *
  1046. * @param string $companyLetterheadLogo
  1047. *
  1048. * @return Account
  1049. */
  1050. public function setCompanyLetterheadLogo($companyLetterheadLogo)
  1051. {
  1052. if (null !== $companyLetterheadLogo) {
  1053. // It is required that at least one field changes if you are using doctrine
  1054. // otherwise the event listeners won't be called and the file is lost
  1055. $this->updated = new \DateTimeImmutable();
  1056. }
  1057. $this->companyLetterheadLogo = $companyLetterheadLogo;
  1058. return $this;
  1059. }
  1060. /**
  1061. * Get companyLetterheadLogo
  1062. *
  1063. * @return string
  1064. */
  1065. public function getCompanyLetterheadLogo()
  1066. {
  1067. return $this->companyLetterheadLogo;
  1068. }
  1069. /**
  1070. * Indicates whether or not this account has a company letterhead logo
  1071. *
  1072. * @return bool
  1073. */
  1074. public function hasCompanyLetterheadLogo()
  1075. {
  1076. // note that we use the companyLetterheadLogoName field because the companyLetterheadLogo field will be
  1077. // populated with the gaufrette file location immediately on upload
  1078. // even if the upload fails. So if you call this function on the user
  1079. // before it is persisted it may give you a false positive.
  1080. $companyLetterheadLogo = $this->getCompanyLetterheadLogoName();
  1081. return !empty($companyLetterheadLogo);
  1082. }
  1083. /**
  1084. * Set companyLetterheadLogoName
  1085. *
  1086. * @param string $companyLetterheadLogoName
  1087. *
  1088. * @return Account
  1089. */
  1090. public function setCompanyLetterheadLogoName($companyLetterheadLogoName)
  1091. {
  1092. $this->companyLetterheadLogoName = $companyLetterheadLogoName;
  1093. return $this;
  1094. }
  1095. /**
  1096. * Get companyLetterheadLogoName
  1097. *
  1098. * @return string
  1099. */
  1100. public function getCompanyLetterheadLogoName()
  1101. {
  1102. return $this->companyLetterheadLogoName;
  1103. }
  1104. /**
  1105. * Set allowedLicenseLevels
  1106. *
  1107. * @param array $allowedLicenseLevels
  1108. *
  1109. * @return Account
  1110. */
  1111. public function setAllowedLicenseLevels($allowedLicenseLevels)
  1112. {
  1113. $this->allowed_license_levels = $allowedLicenseLevels;
  1114. return $this;
  1115. }
  1116. /**
  1117. * Get allowedLicenseLevels
  1118. *
  1119. * @return array
  1120. */
  1121. public function getAllowedLicenseLevels()
  1122. {
  1123. if ($this->allowed_license_levels === null) {
  1124. return [];
  1125. }
  1126. return $this->allowed_license_levels;
  1127. }
  1128. /**
  1129. * Set prefix
  1130. *
  1131. * @param string $prefix
  1132. *
  1133. * @return Account
  1134. */
  1135. public function setPrefix($prefix)
  1136. {
  1137. $this->prefix = strtoupper($prefix);
  1138. return $this;
  1139. }
  1140. /**
  1141. * Get prefix
  1142. *
  1143. * @return string
  1144. */
  1145. public function getPrefix()
  1146. {
  1147. return strtoupper($this->prefix);
  1148. }
  1149. /**
  1150. * Set legalEntityName
  1151. *
  1152. * @param string $legalEntityName
  1153. *
  1154. * @return Account
  1155. */
  1156. public function setLegalEntityName($legalEntityName)
  1157. {
  1158. $this->legal_entity_name = $legalEntityName;
  1159. return $this;
  1160. }
  1161. /**
  1162. * Get legalEntityName
  1163. *
  1164. * @return string
  1165. */
  1166. public function getLegalEntityName()
  1167. {
  1168. return $this->legal_entity_name;
  1169. }
  1170. /**
  1171. * Set defaultRole
  1172. *
  1173. * @param string $defaultRole
  1174. *
  1175. * @return Account
  1176. */
  1177. public function setDefaultRole($defaultRole)
  1178. {
  1179. $this->default_role = $defaultRole;
  1180. return $this;
  1181. }
  1182. /**
  1183. * Get defaultRole
  1184. *
  1185. * @return string
  1186. */
  1187. public function getDefaultRole()
  1188. {
  1189. return $this->default_role;
  1190. }
  1191. /**
  1192. * Get defaultRoleOptions
  1193. *
  1194. * @return array
  1195. */
  1196. public static function getDefaultRoleOptions()
  1197. {
  1198. return [
  1199. self::DEFAULT_ROLE_ADMINISTRATOR => 'Client Administrator',
  1200. self::DEFAULT_ROLE_SUPERADMINISTRATOR => 'Client Super Administrator',
  1201. self::DEFAULT_ROLE_PROJECTMANAGER => 'Client Project Manager',
  1202. self::DEFAULT_ROLE_SORTER => 'Sorter',
  1203. ];
  1204. }
  1205. /**
  1206. * Get DefaultRoleLabel
  1207. *
  1208. * @return string
  1209. */
  1210. public function getDefaultRoleLabel()
  1211. {
  1212. $options = self::getDefaultRoleOptions();
  1213. return $options[$this->getDefaultRole()] ?? '';
  1214. }
  1215. /**
  1216. * Get DefaultRoleLabel
  1217. *
  1218. * @return string
  1219. */
  1220. public function getDefaultRoleAsRole()
  1221. {
  1222. if (!$this->getDefaultRole()) {
  1223. return '';
  1224. }
  1225. return 'ROLE_ACCOUNT_' . $this->getId() . '_' . $this->getDefaultRole();
  1226. }
  1227. /**
  1228. * Set hideFromInvoicing
  1229. *
  1230. * @param bool $hideFromInvoicing
  1231. *
  1232. * @return Account
  1233. */
  1234. public function setHideFromInvoicing($hideFromInvoicing)
  1235. {
  1236. $this->hide_from_invoicing = $hideFromInvoicing;
  1237. return $this;
  1238. }
  1239. /**
  1240. * Get hideFromInvoicing
  1241. *
  1242. * @return bool
  1243. */
  1244. public function getHideFromInvoicing()
  1245. {
  1246. return $this->hide_from_invoicing;
  1247. }
  1248. /**
  1249. * Set invoicePaymentTerms
  1250. *
  1251. * @param int $invoicePaymentTerms
  1252. *
  1253. * @return Account
  1254. */
  1255. public function setInvoicePaymentTerms($invoicePaymentTerms)
  1256. {
  1257. $this->invoice_payment_terms = $invoicePaymentTerms;
  1258. return $this;
  1259. }
  1260. /**
  1261. * Get invoicePaymentTerms
  1262. *
  1263. * @return int
  1264. */
  1265. public function getInvoicePaymentTerms()
  1266. {
  1267. return $this->invoice_payment_terms;
  1268. }
  1269. /**
  1270. * Get the disabled UserNotification types
  1271. *
  1272. * @return array
  1273. */
  1274. public function getDisabledNotifications(): array
  1275. {
  1276. return $this->disabled_notifications ?: [];
  1277. }
  1278. /**
  1279. * @param array $disabled_notifications
  1280. *
  1281. * @return Account
  1282. */
  1283. public function setDisabledNotifications(array $disabled_notifications): Account
  1284. {
  1285. $this->disabled_notifications = $disabled_notifications;
  1286. return $this;
  1287. }
  1288. /**
  1289. * Disable a notification
  1290. *
  1291. * @param $notification_type
  1292. *
  1293. * @return Account
  1294. */
  1295. public function disableNotification($notification_type)
  1296. {
  1297. if (!$this->disabled_notifications) {
  1298. $this->disabled_notifications = [];
  1299. }
  1300. array_push($this->disabled_notifications, $notification_type);
  1301. return $this;
  1302. }
  1303. /**
  1304. * Function to determine if the specific UserNotification is disabled for this Entity
  1305. *
  1306. * @param $notification_type
  1307. *
  1308. * @return bool
  1309. */
  1310. public function isNotificationDisabled($notification_type)
  1311. {
  1312. if (!$this->disabled_notifications) {
  1313. $this->disabled_notifications = [];
  1314. return false;
  1315. }
  1316. return in_array($notification_type, $this->disabled_notifications) ? true : false;
  1317. }
  1318. /**
  1319. * Set defaultSortingInstruction.
  1320. *
  1321. * @param SortingInstruction|null $defaultSortingInstruction
  1322. *
  1323. * @return Account
  1324. */
  1325. public function setDefaultSortingInstruction(?SortingInstruction $defaultSortingInstruction = null)
  1326. {
  1327. $this->defaultSortingInstruction = $defaultSortingInstruction;
  1328. return $this;
  1329. }
  1330. /**
  1331. * Get defaultSortingInstruction.
  1332. *
  1333. * @return SortingInstruction|null
  1334. */
  1335. public function getDefaultSortingInstruction()
  1336. {
  1337. return $this->defaultSortingInstruction;
  1338. }
  1339. /**
  1340. * Set requireMemo.
  1341. *
  1342. * @param bool $requireMemo
  1343. *
  1344. * @return Account
  1345. */
  1346. public function setRequireMemo($requireMemo)
  1347. {
  1348. $this->requireMemo = $requireMemo;
  1349. return $this;
  1350. }
  1351. /**
  1352. * Get requireMemo.
  1353. *
  1354. * @return bool
  1355. */
  1356. public function getRequireMemo()
  1357. {
  1358. return $this->requireMemo;
  1359. }
  1360. /**
  1361. * Set requirePasswordOnDownload.
  1362. *
  1363. * @param bool $requirePasswordOnDownload
  1364. *
  1365. * @return Account
  1366. */
  1367. public function setRequirePasswordOnDownload($requirePasswordOnDownload)
  1368. {
  1369. $this->require_password_on_download = $requirePasswordOnDownload;
  1370. return $this;
  1371. }
  1372. /**
  1373. * Get requirePasswordOnDownload.
  1374. *
  1375. * @return bool
  1376. */
  1377. public function getRequirePasswordOnDownload()
  1378. {
  1379. return $this->require_password_on_download;
  1380. }
  1381. /**
  1382. * Add accountSortingMemoPhrase.
  1383. *
  1384. * @param AccountSortingMemoPhrase $accountSortingMemoPhrase
  1385. *
  1386. * @return Account
  1387. */
  1388. public function addAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
  1389. {
  1390. $this->accountSortingMemoPhrases[] = $accountSortingMemoPhrase;
  1391. return $this;
  1392. }
  1393. /**
  1394. * Remove accountSortingMemoPhrase.
  1395. *
  1396. * @param AccountSortingMemoPhrase $accountSortingMemoPhrase
  1397. *
  1398. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  1399. */
  1400. public function removeAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
  1401. {
  1402. return $this->accountSortingMemoPhrases->removeElement($accountSortingMemoPhrase);
  1403. }
  1404. /**
  1405. * Get accountSortingMemoPhrases.
  1406. *
  1407. * @return Collection
  1408. */
  1409. public function getAccountSortingMemoPhrases()
  1410. {
  1411. return $this->accountSortingMemoPhrases;
  1412. }
  1413. /**
  1414. * Set matterRequestDefaults.
  1415. *
  1416. * @param MatterRequestDefaults|null $matterRequestDefaults
  1417. *
  1418. * @return Account
  1419. */
  1420. public function setMatterRequestDefaults(?MatterRequestDefaults $matterRequestDefaults = null)
  1421. {
  1422. $this->matterRequestDefaults = $matterRequestDefaults;
  1423. return $this;
  1424. }
  1425. /**
  1426. * Get matterRequestDefaults.
  1427. *
  1428. * @return MatterRequestDefaults|null
  1429. */
  1430. public function getMatterRequestDefaults()
  1431. {
  1432. return $this->matterRequestDefaults;
  1433. }
  1434. /**
  1435. * Returns the return details address.
  1436. *
  1437. * @return ContactableAddress|null
  1438. */
  1439. public function getReturnDetailsAddress(): ?ContactableAddress
  1440. {
  1441. if ($this->getOffices() && $this->getOffices()->first()) {
  1442. return $this->getOffices()->first();
  1443. }
  1444. return null;
  1445. }
  1446. /**
  1447. * Set matterCreationProcess.
  1448. *
  1449. * @param string|null $matterCreationProcess
  1450. *
  1451. * @return Account
  1452. */
  1453. public function setMatterCreationProcess($matterCreationProcess = null): Account
  1454. {
  1455. $this->matterCreationProcess = $matterCreationProcess;
  1456. return $this;
  1457. }
  1458. /**
  1459. * Set customIndexHeader.
  1460. *
  1461. * @param string|null $customIndexHeader
  1462. *
  1463. * @return Account
  1464. */
  1465. public function setCustomIndexHeader($customIndexHeader = null)
  1466. {
  1467. $this->custom_index_header = $customIndexHeader;
  1468. return $this;
  1469. }
  1470. /**
  1471. * Get customIndexHeader.
  1472. *
  1473. * @return string|null
  1474. */
  1475. public function getCustomIndexHeader()
  1476. {
  1477. return $this->custom_index_header;
  1478. }
  1479. /**
  1480. * Get matterCreationProcess.
  1481. *
  1482. * @return string|null
  1483. */
  1484. public function getMatterCreationProcess(): ?string
  1485. {
  1486. return $this->matterCreationProcess;
  1487. }
  1488. /**
  1489. * Returns true if the client has access to classic matter creation.
  1490. *
  1491. * @return bool
  1492. */
  1493. public function hasAccessToClassicMatterCreation(): bool
  1494. {
  1495. return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_CLASSIC || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL || $this->matterCreationProcess === null;
  1496. }
  1497. /**
  1498. * Returns true if the client has access to standard matter creation.
  1499. *
  1500. * @return bool
  1501. */
  1502. public function hasAccessToStandardMatterCreation(): bool
  1503. {
  1504. return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_STANDARD || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL;
  1505. }
  1506. /**
  1507. * Returns matter creations options as an array, usable as the choices for a form.
  1508. *
  1509. * @return array
  1510. */
  1511. public static function getMatterCreationProcessOptions(): array
  1512. {
  1513. $matterCreationProcessOptions = self::getConstantsWithLabelsAsChoices('MATTER_CREATION_PROCESS');
  1514. return array_flip($matterCreationProcessOptions);
  1515. }
  1516. /**
  1517. * Returns a human readable version of matterCreationProcess.
  1518. *
  1519. * @return string
  1520. */
  1521. public function getMatterCreationProcessName()
  1522. {
  1523. $options = self::getMatterCreationProcessOptions();
  1524. return $options[$this->getMatterCreationProcess()] ?? $this->getMatterCreationProcess();
  1525. }
  1526. /**
  1527. * Get the value of standardIndexHeader
  1528. *
  1529. * @return string|null
  1530. */
  1531. public function getStandardIndexHeader()
  1532. {
  1533. return $this->standardIndexHeader;
  1534. }
  1535. /**
  1536. * Set the value of standardIndexHeader
  1537. *
  1538. * @param string|null $standardIndexHeader
  1539. *
  1540. * @return self
  1541. */
  1542. public function setStandardIndexHeader($standardIndexHeader)
  1543. {
  1544. $this->standardIndexHeader = $standardIndexHeader;
  1545. return $this;
  1546. }
  1547. /**
  1548. * Set canCreateBatchAndSort.
  1549. *
  1550. * @param bool $canCreateBatchAndSort
  1551. *
  1552. * @return Account
  1553. */
  1554. public function setCanCreateBatchAndSort($canCreateBatchAndSort)
  1555. {
  1556. $this->canCreateBatchAndSort = $canCreateBatchAndSort;
  1557. return $this;
  1558. }
  1559. /**
  1560. * Get canCreateBatchAndSort.
  1561. *
  1562. * @return bool
  1563. */
  1564. public function getCanCreateBatchAndSort()
  1565. {
  1566. return $this->canCreateBatchAndSort;
  1567. }
  1568. /**
  1569. * Set matchOptIn.
  1570. *
  1571. * @param string $matchOptIn
  1572. *
  1573. * @return Account
  1574. */
  1575. public function setMatchOptIn(string $matchOptIn): self
  1576. {
  1577. $this->matchOptIn = $matchOptIn;
  1578. return $this;
  1579. }
  1580. /**
  1581. * Get matchOptIn.
  1582. *
  1583. * @return string
  1584. */
  1585. public function getMatchOptIn(): string
  1586. {
  1587. // Treat legacy nulls as an explicit "none" selection so existing rows keep their stored value
  1588. // while the UI and authorisation logic see a normalised default as per acceptance criteria.
  1589. return $this->matchOptIn ?? self::MATCH_OPT_IN_NONE;
  1590. }
  1591. /**
  1592. * Check if match is enabled for this account.
  1593. *
  1594. * @return bool
  1595. */
  1596. public function isMatchEnabled(): bool
  1597. {
  1598. $allowedArray = [
  1599. self::MATCH_OPT_IN_ALL_CLIENT_USERS,
  1600. self::MATCH_OPT_IN_SPECIFIC_USERS,
  1601. ];
  1602. return in_array($this->getMatchOptIn(), $allowedArray);
  1603. }
  1604. /**
  1605. * Check if match opt-in is set to all client users.
  1606. *
  1607. * @return bool
  1608. */
  1609. public function isMatchOptInAllClientUsers(): bool
  1610. {
  1611. return $this->matchOptIn === self::MATCH_OPT_IN_ALL_CLIENT_USERS;
  1612. }
  1613. /**
  1614. * Check if match opt-in is set to specific users.
  1615. *
  1616. * @return bool
  1617. */
  1618. public function isMatchOptInSpecificUsers(): bool
  1619. {
  1620. return $this->matchOptIn === self::MATCH_OPT_IN_SPECIFIC_USERS;
  1621. }
  1622. /**
  1623. * Get defaultMatchOptinOptions
  1624. *
  1625. * @return array
  1626. */
  1627. public static function getDefaultMatchOptinOptions(): array
  1628. {
  1629. return [
  1630. self::MATCH_OPT_IN_NONE => self::MATCH_OPT_IN_NONE__LABEL,
  1631. self::MATCH_OPT_IN_ALL_CLIENT_USERS => self::MATCH_OPT_IN_ALL_CLIENT_USERS__LABEL,
  1632. self::MATCH_OPT_IN_SPECIFIC_USERS => self::MATCH_OPT_IN_SPECIFIC_USERS__LABEL,
  1633. ];
  1634. }
  1635. /**
  1636. * Set insightsOptIn.
  1637. *
  1638. * @param string $insightsOptIn
  1639. *
  1640. * @return Account
  1641. */
  1642. public function setInsightsOptIn(string $insightsOptIn): self
  1643. {
  1644. $this->insightsOptIn = $insightsOptIn;
  1645. return $this;
  1646. }
  1647. /**
  1648. * Get insightsOptIn.
  1649. *
  1650. * @return string
  1651. */
  1652. public function getInsightsOptIn(): string
  1653. {
  1654. return $this->insightsOptIn ?? self::INSIGHTS_OPT_IN_NONE;
  1655. }
  1656. /**
  1657. * Check if MedBrief Insights is enabled for this account.
  1658. *
  1659. * @return bool
  1660. */
  1661. public function isInsightsEnabled(): bool
  1662. {
  1663. $allowedArray = [
  1664. self::INSIGHTS_OPT_IN_ALL_CLIENT_USERS,
  1665. self::INSIGHTS_OPT_IN_SPECIFIC_USERS,
  1666. ];
  1667. return in_array($this->getInsightsOptIn(), $allowedArray);
  1668. }
  1669. /**
  1670. * Check if Insights opt-in is set to all client users.
  1671. *
  1672. * @return bool
  1673. */
  1674. public function isInsightsOptInAllClientUsers(): bool
  1675. {
  1676. return $this->insightsOptIn === self::INSIGHTS_OPT_IN_ALL_CLIENT_USERS;
  1677. }
  1678. /**
  1679. * Check if Insights opt-in is set to specific users.
  1680. *
  1681. * @return bool
  1682. */
  1683. public function isInsightsOptInSpecificUsers(): bool
  1684. {
  1685. return $this->insightsOptIn === self::INSIGHTS_OPT_IN_SPECIFIC_USERS;
  1686. }
  1687. /**
  1688. * Get defaultInsightsOptInOptions.
  1689. *
  1690. * @return array
  1691. */
  1692. public static function getDefaultInsightsOptInOptions(): array
  1693. {
  1694. return [
  1695. self::INSIGHTS_OPT_IN_NONE => self::INSIGHTS_OPT_IN_NONE__LABEL,
  1696. self::INSIGHTS_OPT_IN_ALL_CLIENT_USERS => self::INSIGHTS_OPT_IN_ALL_CLIENT_USERS__LABEL,
  1697. self::INSIGHTS_OPT_IN_SPECIFIC_USERS => self::INSIGHTS_OPT_IN_SPECIFIC_USERS__LABEL,
  1698. ];
  1699. }
  1700. /**
  1701. * getAllowExpertViewUnsortedRecords
  1702. *
  1703. * @return bool
  1704. */
  1705. public function getAllowExpertViewUnsortedRecords(): bool
  1706. {
  1707. return $this->allowExpertViewUnsortedRecords;
  1708. }
  1709. /**
  1710. * @param bool $allowExpertViewUnsortedRecords
  1711. *
  1712. * @return self
  1713. */
  1714. public function setAllowExpertViewUnsortedRecords(bool $allowExpertViewUnsortedRecords): self
  1715. {
  1716. $this->allowExpertViewUnsortedRecords = $allowExpertViewUnsortedRecords;
  1717. return $this;
  1718. }
  1719. /**
  1720. * @return bool
  1721. */
  1722. public function getMatterClosureQuestionsOptional(): bool
  1723. {
  1724. return $this->matterClosureQuestionsOptional;
  1725. }
  1726. /**
  1727. * @param bool $matterClosureQuestionsOptional
  1728. *
  1729. * @return Account
  1730. */
  1731. public function setMatterClosureQuestionsOptional(bool $matterClosureQuestionsOptional): self
  1732. {
  1733. $this->matterClosureQuestionsOptional = $matterClosureQuestionsOptional;
  1734. return $this;
  1735. }
  1736. /**
  1737. * @return bool|null
  1738. *
  1739. */
  1740. public function getUseParentClinicalSectionsOnly(): ?bool
  1741. {
  1742. return $this->useParentClinicalSectionsOnly;
  1743. }
  1744. /**
  1745. * @param bool $useParentClinicalSectionsOnly
  1746. *
  1747. * @return self
  1748. *
  1749. */
  1750. public function setUseParentClinicalSectionsOnly(bool $useParentClinicalSectionsOnly): self
  1751. {
  1752. $this->useParentClinicalSectionsOnly = $useParentClinicalSectionsOnly;
  1753. return $this;
  1754. }
  1755. public function getFirm(): ?Firm
  1756. {
  1757. return $this->firm;
  1758. }
  1759. public function setFirm(?Firm $firm): self
  1760. {
  1761. $this->firm = $firm;
  1762. return $this;
  1763. }
  1764. /**
  1765. * @return bool
  1766. */
  1767. public function getHideLogoFromIndex(): bool
  1768. {
  1769. return $this->hideLogoFromIndex;
  1770. }
  1771. /**
  1772. * @param bool $hideLogoFromIndex
  1773. *
  1774. * @return self
  1775. */
  1776. public function setHideLogoFromIndex(bool $hideLogoFromIndex): self
  1777. {
  1778. $this->hideLogoFromIndex = $hideLogoFromIndex;
  1779. return $this;
  1780. }
  1781. /**
  1782. * @return array|null
  1783. *
  1784. */
  1785. public function getAllowedMatterTypes(): ?array
  1786. {
  1787. return $this->allowedMatterTypes;
  1788. }
  1789. /**
  1790. * @param array|null $allowedMatterTypes
  1791. *
  1792. * @return self
  1793. *
  1794. */
  1795. public function setAllowedMatterTypes(?array $allowedMatterTypes): self
  1796. {
  1797. $this->allowedMatterTypes = $allowedMatterTypes;
  1798. return $this;
  1799. }
  1800. /**
  1801. * @return array
  1802. */
  1803. public static function getAllowedMatterTypeOptions(): array
  1804. {
  1805. return self::getConstantsWithLabelsAsChoices('MATTER_TYPE');
  1806. }
  1807. /**
  1808. * @return Collection<int, LicenceRenewalTerm>
  1809. */
  1810. public function getLicenceRenewalTerms(): Collection
  1811. {
  1812. return $this->licenceRenewalTerms;
  1813. }
  1814. /**
  1815. * @return Collection<int, LicenceRenewalTerm>
  1816. */
  1817. public function getZeroPeriodLicenceRenewalTerms(): Collection
  1818. {
  1819. return $this->licenceRenewalTerms->filter(function ($term) {
  1820. return $term->getPeriod() === 0;
  1821. });
  1822. }
  1823. /**
  1824. * @param LicenceRenewalTerm $licenceRenewalTerm
  1825. *
  1826. * @return self
  1827. */
  1828. public function addLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
  1829. {
  1830. if (!$this->licenceRenewalTerms->contains($licenceRenewalTerm)) {
  1831. $this->licenceRenewalTerms[] = $licenceRenewalTerm;
  1832. $licenceRenewalTerm->setAccount($this);
  1833. }
  1834. return $this;
  1835. }
  1836. /**
  1837. * @param LicenceRenewalTerm $licenceRenewalTerm
  1838. *
  1839. * @return self
  1840. */
  1841. public function removeLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
  1842. {
  1843. if ($this->licenceRenewalTerms->removeElement($licenceRenewalTerm)) {
  1844. // set the owning side to null (unless already changed)
  1845. if ($licenceRenewalTerm->getAccount() === $this) {
  1846. $licenceRenewalTerm->setAccount(null);
  1847. }
  1848. }
  1849. return $this;
  1850. }
  1851. /**
  1852. * @return bool|null
  1853. */
  1854. public function isEnforceTwoFactorAuth(): ?bool
  1855. {
  1856. return $this->enforceTwoFactorAuth;
  1857. }
  1858. /**
  1859. * @param bool $enforceTwoFactorAuth
  1860. *
  1861. * @return self
  1862. */
  1863. public function setEnforceTwoFactorAuth(bool $enforceTwoFactorAuth): self
  1864. {
  1865. $this->enforceTwoFactorAuth = $enforceTwoFactorAuth;
  1866. return $this;
  1867. }
  1868. /**
  1869. * @return bool|null
  1870. */
  1871. public function isAllowTwoFactorAuthGracePeriod(): ?bool
  1872. {
  1873. return $this->allowTwoFactorAuthGracePeriod;
  1874. }
  1875. /**
  1876. * @param bool $allowTwoFactorAuthGracePeriod
  1877. *
  1878. * @return self
  1879. */
  1880. public function setAllowTwoFactorAuthGracePeriod(bool $allowTwoFactorAuthGracePeriod): self
  1881. {
  1882. $this->allowTwoFactorAuthGracePeriod = $allowTwoFactorAuthGracePeriod;
  1883. return $this;
  1884. }
  1885. /**
  1886. * Checks if the client is not liable for the disclosure fee.
  1887. *
  1888. * @return bool True if the client is not liable, false otherwise.
  1889. */
  1890. public function isClientNotLiableForDisclosureFee(): bool
  1891. {
  1892. return $this->clientNotLiableForDisclosureFee;
  1893. }
  1894. /**
  1895. * Sets whether the client is not liable for the disclosure fee.
  1896. *
  1897. * @param bool $clientNotLiableForDisclosureFee True if the client is not liable, false otherwise.
  1898. *
  1899. * @return self
  1900. */
  1901. public function setClientNotLiableForDisclosureFee(bool $clientNotLiableForDisclosureFee): self
  1902. {
  1903. $this->clientNotLiableForDisclosureFee = $clientNotLiableForDisclosureFee;
  1904. return $this;
  1905. }
  1906. /**
  1907. * Returns an array of permitted values for the country of registration field and their
  1908. * associated labels.
  1909. *
  1910. * @return array
  1911. */
  1912. public static function getCountryOfRegistrationOptions()
  1913. {
  1914. return [
  1915. self::COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES => self::COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES__LABEL,
  1916. self::COUNTRY_OF_REGISTRATION_SCOTLAND => self::COUNTRY_OF_REGISTRATION_SCOTLAND__LABEL,
  1917. self::COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND => self::COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND__LABEL,
  1918. ];
  1919. }
  1920. /**
  1921. * Get trading_name.
  1922. *
  1923. * @return string|null
  1924. */
  1925. public function getTradingName(): ?string
  1926. {
  1927. return $this->trading_name;
  1928. }
  1929. /**
  1930. * Set trading_name.
  1931. *
  1932. * @param string|null $trading_name
  1933. *
  1934. * @return self
  1935. */
  1936. public function setTradingName(?string $trading_name): self
  1937. {
  1938. $this->trading_name = $trading_name;
  1939. return $this;
  1940. }
  1941. /**
  1942. * Get company_registration_number.
  1943. *
  1944. * @return string|null
  1945. */
  1946. public function getCompanyRegistrationNumber(): ?string
  1947. {
  1948. return $this->company_registration_number;
  1949. }
  1950. /**
  1951. * Set company_registration_number.
  1952. *
  1953. * @param string|null $company_registration_number
  1954. *
  1955. * @return self
  1956. */
  1957. public function setCompanyRegistrationNumber(?string $company_registration_number): self
  1958. {
  1959. $this->company_registration_number = $company_registration_number;
  1960. return $this;
  1961. }
  1962. /**
  1963. * Get country_of_registration.
  1964. *
  1965. * @return string|null
  1966. */
  1967. public function getCountryOfRegistration(): ?string
  1968. {
  1969. return $this->country_of_registration;
  1970. }
  1971. /**
  1972. * Set country_of_registration.
  1973. *
  1974. * @param string|null $country_of_registration
  1975. *
  1976. * @return self
  1977. */
  1978. public function setCountryOfRegistration(?string $country_of_registration): self
  1979. {
  1980. $this->country_of_registration = $country_of_registration;
  1981. return $this;
  1982. }
  1983. /**
  1984. * Returns a human-readable version of the country of registration
  1985. *
  1986. * @return string
  1987. */
  1988. public function getCountryOfRegistrationName()
  1989. {
  1990. $options = self::getCountryOfRegistrationOptions();
  1991. return $options[$this->getCountryOfRegistration()] ?? $this->getCountryOfRegistration();
  1992. }
  1993. }