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. /**
  113. * @var ContactableAddress
  114. *
  115. * This field is unmapped, and is purely here for the API.
  116. *
  117. * @Groups({"account:read", "matter_request:read"})
  118. */
  119. protected $returnDetailsAddress;
  120. /**
  121. * @var string
  122. *
  123. * @ORM\Column(name="matterCreationProcess", type="string", nullable=true)
  124. */
  125. protected $matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
  126. /**
  127. * @var string|null
  128. *
  129. * @ORM\Column(name="custom_index_header", type="text", nullable=true)
  130. */
  131. protected $custom_index_header;
  132. /**
  133. * @var string|null
  134. *
  135. * @ORM\Column(name="standardIndexHeader", type="text", nullable=true)
  136. */
  137. protected $standardIndexHeader;
  138. /**
  139. * Indicates if the MedBrief logo should be hidden from the index produced.
  140. * The scenario for this is where clients sort their own records, or a sorting standard that
  141. * deviates from our standard sorting product.
  142. *
  143. * @var bool
  144. *
  145. * @ORM\Column(type="boolean", options={"default"=false})
  146. */
  147. protected $hideLogoFromIndex = false;
  148. /**
  149. * @Groups({"client_area:read"})
  150. *
  151. * @ORM\Column(name="id", type="bigint", nullable=false)
  152. *
  153. * @ORM\Id
  154. *
  155. * @ORM\GeneratedValue(strategy="IDENTITY")
  156. */
  157. private ?int $id;
  158. /**
  159. * @Groups({"account:read", "matter_request:read", "client_area:read"})
  160. *
  161. * @ORM\Column(name="name", type="string", length=155, nullable=false)
  162. */
  163. private ?string $name;
  164. /**
  165. * @var Collection
  166. *
  167. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Domain", mappedBy="account", cascade={"all"})
  168. */
  169. private $domains;
  170. /**
  171. * @var array|null
  172. *
  173. * @ORM\Column(name="allowed_license_levels", type="array", nullable=true)
  174. */
  175. private $allowed_license_levels;
  176. /**
  177. * @var string|null
  178. *
  179. * @ORM\Column(name="prefix", type="string", length=25, nullable=true)
  180. */
  181. private $prefix;
  182. /**
  183. * @var string|null
  184. *
  185. * @ORM\Column(name="legal_entity_name", type="text", nullable=true)
  186. */
  187. private $legal_entity_name;
  188. /**
  189. * Sets all service requests for this client not to come up for invoicing.
  190. *
  191. * @var bool
  192. *
  193. * @ORM\Column(name="hide_from_invoicing", type="boolean", options={"default"=false})
  194. */
  195. private $hide_from_invoicing;
  196. /**
  197. * @var string|null
  198. *
  199. * @ORM\Column(name="default_role", type="string", nullable=true)
  200. */
  201. private $default_role;
  202. /**
  203. * Holds the Account's payment terms value (in days) for adjusting
  204. * the due date on invoices automagically.
  205. *
  206. * @var int
  207. *
  208. * @ORM\Column(name="invoice_payment_terms", type="integer", nullable=true)
  209. */
  210. private $invoice_payment_terms;
  211. /**
  212. * @var int|null
  213. *
  214. * @ORM\Column(name="invoice_billing_frequency", type="integer", nullable=true)
  215. */
  216. private $invoice_billing_frequency;
  217. /**
  218. * @var int|null
  219. *
  220. * @ORM\Column(name="invoice_type", type="integer", nullable=true)
  221. */
  222. private $invoice_type;
  223. /**
  224. * The different UserNotifications disabled for this Client
  225. *
  226. * @var array
  227. *
  228. * @ORM\Column(name="disabled_notifications", type="array", nullable=true)
  229. */
  230. private $disabled_notifications = [];
  231. /**
  232. * A default sorting instruction for all the Account's sorting sessions.
  233. * This is visible to the sorter.
  234. *
  235. * @var SortingInstruction
  236. *
  237. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\SortingInstruction", inversedBy="account", cascade={"persist","remove"}, orphanRemoval=true)
  238. *
  239. * @ORM\JoinColumns({
  240. *
  241. * @ORM\JoinColumn(name="defaultSortingInstruction_id", referencedColumnName="id", unique=true)
  242. * })
  243. */
  244. private $defaultSortingInstruction;
  245. /**
  246. * Determines if a draft memo will be exported for the client on Sorting Session completions.
  247. *
  248. * @var bool
  249. *
  250. * @ORM\Column(name="requireMemo", type="boolean", options={"default"=false})
  251. */
  252. private $requireMemo = false;
  253. /**
  254. * Whether to require the user to enter a password on downloading a document or folder
  255. *
  256. * @var bool
  257. *
  258. * @ORM\Column(name="require_password_on_download", type="boolean", options={"default"=false})
  259. */
  260. private $require_password_on_download;
  261. /**
  262. * @var ArrayCollection
  263. *
  264. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\AccountSortingMemoPhrase", mappedBy="account", cascade={"all"})
  265. */
  266. private $accountSortingMemoPhrases;
  267. /**
  268. * @var MatterRequestDefaults
  269. *
  270. * @Groups({"account:read", "matter_request:read"})
  271. *
  272. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\MatterRequestDefaults", mappedBy="account")
  273. */
  274. private $matterRequestDefaults;
  275. /**
  276. * @var ContactableAddress
  277. *
  278. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
  279. *
  280. * @ORM\JoinColumns({
  281. *
  282. * @ORM\JoinColumn(name="billingAddress_id", referencedColumnName="id", unique=true)
  283. * })
  284. */
  285. private $billingAddress;
  286. /**
  287. * @var ContactableAddress
  288. */
  289. private $accountsAddress;
  290. /**
  291. * @var ContactableAddress
  292. *
  293. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
  294. *
  295. * @ORM\JoinColumns({
  296. *
  297. * @ORM\JoinColumn(name="physicalAddress_id", referencedColumnName="id", unique=true)
  298. * })
  299. */
  300. private $physicalAddress;
  301. /**
  302. * @var Collection
  303. *
  304. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\ContactableAddress", inversedBy="accounts", cascade={"persist"})
  305. *
  306. * @ORM\JoinTable(name="account_contactableaddress",
  307. * joinColumns={
  308. *
  309. * @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE")
  310. * },
  311. * inverseJoinColumns={
  312. * @ORM\JoinColumn(name="contactableaddress_id", referencedColumnName="id", onDelete="CASCADE")
  313. * }
  314. * )
  315. */
  316. private $offices;
  317. /**
  318. * @var string
  319. *
  320. * @ORM\Column(name="slug", type="string")
  321. *
  322. * @Gedmo\Slug(fields={"name"}, updatable=false, separator="_")
  323. */
  324. private $slug;
  325. /**
  326. * @var \DateTime
  327. *
  328. * @ORM\Column(name="created", type="datetime")
  329. *
  330. * @Gedmo\Timestampable(on="create")
  331. */
  332. private $created;
  333. /**
  334. * @var \DateTime
  335. *
  336. * @ORM\Column(name="updated", type="datetime")
  337. *
  338. * @Gedmo\Timestampable(on="update")
  339. */
  340. private $updated;
  341. /**
  342. * @var Collection
  343. *
  344. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Project", mappedBy="account", cascade={"all"})
  345. */
  346. private $projects;
  347. /**
  348. * @var Collection
  349. */
  350. private $addresses;
  351. /**
  352. * @var \DateTime
  353. *
  354. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  355. */
  356. private $deletedAt;
  357. /**
  358. * @var string
  359. */
  360. private $image;
  361. /**
  362. * @var string
  363. *
  364. * @ORM\Column(name="image_name", type="string", length=255, nullable=true)
  365. */
  366. private $image_name;
  367. /**
  368. * Determines if an account can create/update batch requests and sort sessions.
  369. *
  370. * @var bool
  371. *
  372. * @ORM\Column(name="canCreateBatchAndSort", type="boolean", options={"default"=false})
  373. */
  374. private $canCreateBatchAndSort = false;
  375. /**
  376. * Determines the default value of the same field on a Project/Matter, when a new Project is created.
  377. *
  378. * @var bool
  379. *
  380. * @ORM\Column(name="allowExpertViewUnsortedRecords", type="boolean", options={"default"=false})
  381. */
  382. private $allowExpertViewUnsortedRecords = false;
  383. /**
  384. * Determines if the questions presented during the Matter Closure Wizard are optional.
  385. *
  386. * @var bool
  387. *
  388. * @ORM\Column(name="matterClosureQuestionsOptional", type="boolean", options={"default"=false})
  389. */
  390. private $matterClosureQuestionsOptional = false;
  391. /**
  392. * @var bool
  393. *
  394. * @ORM\Column(name="useParentClinicalSectionsOnly", type="boolean")
  395. */
  396. private $useParentClinicalSectionsOnly = false;
  397. /**
  398. * @ORM\ManyToOne(targetEntity=Firm::class, inversedBy="clientAreas")
  399. */
  400. private $firm;
  401. /**
  402. * @Groups({"account:read", "matter_request:read"})
  403. *
  404. * @ORM\Column(name="allowedMatterTypes", type="array", nullable=true)
  405. *
  406. * @Assert\Count(
  407. * min=1,
  408. * minMessage = "Please select an option.",
  409. * groups={"account:read", "matter_request:read"}
  410. * )
  411. */
  412. private array $allowedMatterTypes = [];
  413. /**
  414. * @ORM\OneToMany(targetEntity=LicenceRenewalTerm::class, mappedBy="account", orphanRemoval=true)
  415. *
  416. * @ORM\OrderBy({"effectiveDate" = "ASC"})
  417. *
  418. * When a new period is added, a new related service option for the same period should also be created and mapped.
  419. */
  420. private ?Collection $licenceRenewalTerms;
  421. /**
  422. * Sets whether any client level users, or users invited to the client's
  423. * matters should require 2FA to be enabled.
  424. *
  425. * @ORM\Column(type="boolean", options={"default"=false})
  426. */
  427. private bool $enforceTwoFactorAuth = false;
  428. /**
  429. * If enabled, allows the users that are forced to enabled 2FA via the
  430. * enforceTwoFactorAuth property to skip the requirement for the first
  431. * two (2) logins.
  432. *
  433. * @ORM\Column(type="boolean", options={"default"=false})
  434. */
  435. private bool $allowTwoFactorAuthGracePeriod = false;
  436. /**
  437. * If enabled, the account (client) is not liable for the disclosure fee,
  438. * the Recipient Firm is liable.
  439. *
  440. * @ORM\Column(type="boolean", options={"default"=false})
  441. */
  442. private bool $clientNotLiableForDisclosureFee = false;
  443. /**
  444. * Constructor
  445. */
  446. public function __construct()
  447. {
  448. $this->domains = new ArrayCollection();
  449. $this->allowed_license_levels = [];
  450. $this->hide_from_invoicing = false;
  451. $this->require_password_on_download = false;
  452. $this->accountSortingMemoPhrases = new ArrayCollection();
  453. $this->matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
  454. $this->projects = new ArrayCollection();
  455. $this->offices = new ArrayCollection();
  456. $this->licenceRenewalTerms = new ArrayCollection();
  457. }
  458. public function __toString()
  459. {
  460. return $this->getName();
  461. }
  462. /**
  463. * Get id
  464. *
  465. * @return int
  466. */
  467. public function getId()
  468. {
  469. return $this->id;
  470. }
  471. /**
  472. * Set name
  473. *
  474. * @param string $name
  475. *
  476. * @return Account
  477. */
  478. public function setName($name)
  479. {
  480. $this->name = $name;
  481. return $this;
  482. }
  483. /**
  484. * Get name
  485. *
  486. * @return string
  487. */
  488. public function getName()
  489. {
  490. return $this->name;
  491. }
  492. /**
  493. * Add domains
  494. *
  495. * @param Domain $domains
  496. *
  497. * @return Account
  498. */
  499. public function addDomain(Domain $domains)
  500. {
  501. $this->domains[] = $domains;
  502. return $this;
  503. }
  504. /**
  505. * Remove domains
  506. *
  507. * @param Domain $domains
  508. */
  509. public function removeDomain(Domain $domains)
  510. {
  511. $this->domains->removeElement($domains);
  512. }
  513. /**
  514. * Get domains
  515. *
  516. * @return Collection
  517. */
  518. public function getDomains()
  519. {
  520. return $this->domains;
  521. }
  522. /**
  523. * Set slug
  524. *
  525. * @param string $slug
  526. *
  527. * @return Account
  528. */
  529. public function setSlug($slug)
  530. {
  531. $this->slug = $slug;
  532. return $this;
  533. }
  534. /**
  535. * Get slug
  536. *
  537. * @return string
  538. */
  539. public function getSlug()
  540. {
  541. return $this->slug;
  542. }
  543. /**
  544. * Set created
  545. *
  546. * @param \DateTime $created
  547. *
  548. * @return Account
  549. */
  550. public function setCreated($created)
  551. {
  552. $this->created = $created;
  553. return $this;
  554. }
  555. /**
  556. * Get created
  557. *
  558. * @return \DateTime
  559. */
  560. public function getCreated()
  561. {
  562. return $this->created;
  563. }
  564. /**
  565. * Set updated
  566. *
  567. * @param \DateTime $updated
  568. *
  569. * @return Account
  570. */
  571. public function setUpdated($updated)
  572. {
  573. $this->updated = $updated;
  574. return $this;
  575. }
  576. /**
  577. * Get updated
  578. *
  579. * @return \DateTime
  580. */
  581. public function getUpdated()
  582. {
  583. return $this->updated;
  584. }
  585. /**
  586. * Add projects
  587. *
  588. * @param Project $projects
  589. *
  590. * @return Account
  591. */
  592. public function addProject(Project $projects)
  593. {
  594. $this->projects[] = $projects;
  595. return $this;
  596. }
  597. /**
  598. * Remove projects
  599. *
  600. * @param Project $projects
  601. */
  602. public function removeProject(Project $projects)
  603. {
  604. $this->projects->removeElement($projects);
  605. }
  606. /**
  607. * Get projects
  608. *
  609. * @return Collection
  610. */
  611. public function getProjects()
  612. {
  613. return $this->projects;
  614. }
  615. public function getArchivedProjects()
  616. {
  617. $criteria = Criteria::create()
  618. ->where(Criteria::expr()->gt('archive_status', 0))
  619. ->orderBy(['name' => Criteria::ASC])
  620. ;
  621. return $this->getProjects()->matching($criteria);
  622. }
  623. public function getActiveProjects()
  624. {
  625. $criteria = Criteria::create()
  626. ->where(Criteria::expr()->eq('status', Project::STATUS_ACTIVE))
  627. ->orderBy(['name' => Criteria::ASC])
  628. ;
  629. return $this->getProjects()->matching($criteria);
  630. }
  631. public function getInactiveProjects()
  632. {
  633. $criteria = Criteria::create()
  634. ->where(Criteria::expr()->eq('status', Project::STATUS_INACTIVE))
  635. ->orderBy(['name' => Criteria::ASC])
  636. ;
  637. return $this->getProjects()->matching($criteria);
  638. }
  639. /**
  640. * Set invoice_billing_frequency
  641. *
  642. * @param string $invoiceBillingFrequency
  643. *
  644. * @return Account
  645. */
  646. public function setInvoiceBillingFrequency($invoiceBillingFrequency)
  647. {
  648. $this->invoice_billing_frequency = $invoiceBillingFrequency;
  649. return $this;
  650. }
  651. /**
  652. * Get invoice_billing_frequency
  653. *
  654. * @return string
  655. */
  656. public function getInvoiceBillingFrequency()
  657. {
  658. return $this->invoice_billing_frequency;
  659. }
  660. /**
  661. * Set invoice_type
  662. *
  663. * @param string $invoiceType
  664. *
  665. * @return Account
  666. */
  667. public function setInvoiceType($invoiceType)
  668. {
  669. $this->invoice_type = $invoiceType;
  670. return $this;
  671. }
  672. /**
  673. * Get invoice_type
  674. *
  675. * @return string
  676. */
  677. public function getInvoiceType()
  678. {
  679. return $this->invoice_type;
  680. }
  681. /**
  682. * Set billingAddress
  683. *
  684. * @param ContactableAddress $billingAddress
  685. *
  686. * @return Account
  687. */
  688. public function setBillingAddress(?ContactableAddress $billingAddress = null)
  689. {
  690. $this->billingAddress = $billingAddress;
  691. return $this;
  692. }
  693. /**
  694. * Get billingAddress
  695. *
  696. * @return ContactableAddress
  697. */
  698. public function getBillingAddress()
  699. {
  700. return $this->billingAddress;
  701. }
  702. /**
  703. * Set accountsAddress
  704. *
  705. * @param ContactableAddress $accountsAddress
  706. *
  707. * @return Account
  708. */
  709. public function setAccountsAddress(?ContactableAddress $accountsAddress = null)
  710. {
  711. $this->accountsAddress = $accountsAddress;
  712. return $this;
  713. }
  714. /**
  715. * Get accountsAddress
  716. *
  717. * @return ContactableAddress
  718. */
  719. public function getAccountsAddress()
  720. {
  721. return $this->accountsAddress;
  722. }
  723. /**
  724. * Set physicalAddress
  725. *
  726. * @param ContactableAddress $physicalAddress
  727. *
  728. * @return Account
  729. */
  730. public function setPhysicalAddress(?ContactableAddress $physicalAddress = null)
  731. {
  732. $this->physicalAddress = $physicalAddress;
  733. return $this;
  734. }
  735. /**
  736. * Get physicalAddress
  737. *
  738. * @return ContactableAddress
  739. */
  740. public function getPhysicalAddress()
  741. {
  742. return $this->physicalAddress;
  743. }
  744. /**
  745. * Add offices
  746. *
  747. * @param ContactableAddress $offices
  748. *
  749. * @return Account
  750. */
  751. public function addOffice(ContactableAddress $offices)
  752. {
  753. $this->offices[] = $offices;
  754. return $this;
  755. }
  756. /**
  757. * Remove offices
  758. *
  759. * @param ContactableAddress $offices
  760. */
  761. public function removeOffice(ContactableAddress $offices)
  762. {
  763. $this->offices->removeElement($offices);
  764. }
  765. /**
  766. * Get offices
  767. *
  768. * @return Collection
  769. */
  770. public function getOffices()
  771. {
  772. return $this->offices;
  773. }
  774. /**
  775. * Returns an array of permitted values for the invoice billing frequency field and their
  776. * associated labels,
  777. *
  778. * @return array
  779. */
  780. public static function getInvoiceBillingFrequencyOptions()
  781. {
  782. return [
  783. self::INVOICE_BILLING_FREQUENCY_MONTHLY => 'Monthly',
  784. self::INVOICE_BILLING_FREQUENCY_QUARTERLY => 'Quarterly',
  785. self::INVOICE_BILLING_FREQUENCY_START_OF_MATTER => 'At the start of the matter',
  786. ];
  787. }
  788. /**
  789. * Returns a human readable version of the invoice billing frequency
  790. *
  791. * @return string
  792. */
  793. public function getInvoiceBillingFrequencyName()
  794. {
  795. $options = self::getInvoiceBillingFrequencyOptions();
  796. return
  797. $options[$this->getInvoiceBillingFrequency()] ?? $this->getInvoiceBillingFrequency();
  798. }
  799. /**
  800. * Returns an array of permitted values for the invoice billing frequency field and their
  801. * associated labels,
  802. *
  803. * @return array
  804. */
  805. public static function getInvoiceTypeOptions()
  806. {
  807. return [
  808. self::INVOICE_TYPE_CONSOLIDATED => 'Consolidated',
  809. self::INVOICE_TYPE_INDIVIDUAL_MATTER => 'Individual Matter',
  810. ];
  811. }
  812. /**
  813. * Returns a human readable version of the invoice billing frequency
  814. *
  815. * @return string
  816. */
  817. public function getInvoiceTypeName()
  818. {
  819. $options = self::getInvoiceTypeOptions();
  820. return
  821. $options[$this->getInvoiceType()] ?? $this->getInvoiceType();
  822. }
  823. /**
  824. * Set deletedAt
  825. *
  826. * @param \DateTime $deletedAt
  827. *
  828. * @return Account
  829. */
  830. public function setDeletedAt($deletedAt)
  831. {
  832. $this->deletedAt = $deletedAt;
  833. return $this;
  834. }
  835. /**
  836. * Get deletedAt
  837. *
  838. * @return \DateTime
  839. */
  840. public function getDeletedAt()
  841. {
  842. return $this->deletedAt;
  843. }
  844. /**
  845. * Set image
  846. *
  847. * @param string $image
  848. *
  849. * @return Account
  850. */
  851. public function setImage($image)
  852. {
  853. if (null !== $image) {
  854. // It is required that at least one field changes if you are using doctrine
  855. // otherwise the event listeners won't be called and the file is lost
  856. $this->updated = new \DateTimeImmutable();
  857. }
  858. $this->image = $image;
  859. return $this;
  860. }
  861. /**
  862. * Indicates whether or not this user has an image
  863. *
  864. * @return bool
  865. */
  866. public function hasImage()
  867. {
  868. // note that we use the imageName field because the image field will be
  869. // populated with the gaufrette file location immediately on upload
  870. // even if the upload fails. So if you call this function on the user
  871. // before it is peristed it may give you a false positive.
  872. $image = $this->getImageName();
  873. return !empty($image);
  874. }
  875. /**
  876. * Get image
  877. *
  878. * @return string
  879. */
  880. public function getImage()
  881. {
  882. return $this->image;
  883. }
  884. /**
  885. * Set image_name
  886. *
  887. * @param string $imageName
  888. *
  889. * @return Account
  890. */
  891. public function setImageName($imageName)
  892. {
  893. $this->image_name = $imageName;
  894. return $this;
  895. }
  896. /**
  897. * Get image_name
  898. *
  899. * @return string
  900. */
  901. public function getImageName()
  902. {
  903. return $this->image_name;
  904. }
  905. /**
  906. * Set allowedLicenseLevels
  907. *
  908. * @param array $allowedLicenseLevels
  909. *
  910. * @return Account
  911. */
  912. public function setAllowedLicenseLevels($allowedLicenseLevels)
  913. {
  914. $this->allowed_license_levels = $allowedLicenseLevels;
  915. return $this;
  916. }
  917. /**
  918. * Get allowedLicenseLevels
  919. *
  920. * @return array
  921. */
  922. public function getAllowedLicenseLevels()
  923. {
  924. if ($this->allowed_license_levels === null) {
  925. return [];
  926. }
  927. return $this->allowed_license_levels;
  928. }
  929. /**
  930. * Set prefix
  931. *
  932. * @param string $prefix
  933. *
  934. * @return Account
  935. */
  936. public function setPrefix($prefix)
  937. {
  938. $this->prefix = strtoupper($prefix);
  939. return $this;
  940. }
  941. /**
  942. * Get prefix
  943. *
  944. * @return string
  945. */
  946. public function getPrefix()
  947. {
  948. return strtoupper($this->prefix);
  949. }
  950. /**
  951. * Set legalEntityName
  952. *
  953. * @param string $legalEntityName
  954. *
  955. * @return Account
  956. */
  957. public function setLegalEntityName($legalEntityName)
  958. {
  959. $this->legal_entity_name = $legalEntityName;
  960. return $this;
  961. }
  962. /**
  963. * Get legalEntityName
  964. *
  965. * @return string
  966. */
  967. public function getLegalEntityName()
  968. {
  969. return $this->legal_entity_name;
  970. }
  971. /**
  972. * Set defaultRole
  973. *
  974. * @param string $defaultRole
  975. *
  976. * @return Account
  977. */
  978. public function setDefaultRole($defaultRole)
  979. {
  980. $this->default_role = $defaultRole;
  981. return $this;
  982. }
  983. /**
  984. * Get defaultRole
  985. *
  986. * @return string
  987. */
  988. public function getDefaultRole()
  989. {
  990. return $this->default_role;
  991. }
  992. /**
  993. * Get defaultRoleOptions
  994. *
  995. * @return array
  996. */
  997. public static function getDefaultRoleOptions()
  998. {
  999. return [
  1000. self::DEFAULT_ROLE_ADMINISTRATOR => 'Client Administrator',
  1001. self::DEFAULT_ROLE_SUPERADMINISTRATOR => 'Client Super Administrator',
  1002. self::DEFAULT_ROLE_PROJECTMANAGER => 'Client Project Manager',
  1003. self::DEFAULT_ROLE_SORTER => 'Sorter',
  1004. ];
  1005. }
  1006. /**
  1007. * Get DefaultRoleLabel
  1008. *
  1009. * @return string
  1010. */
  1011. public function getDefaultRoleLabel()
  1012. {
  1013. $options = self::getDefaultRoleOptions();
  1014. return $options[$this->getDefaultRole()] ?? '';
  1015. }
  1016. /**
  1017. * Get DefaultRoleLabel
  1018. *
  1019. * @return string
  1020. */
  1021. public function getDefaultRoleAsRole()
  1022. {
  1023. if (!$this->getDefaultRole()) {
  1024. return '';
  1025. }
  1026. return 'ROLE_ACCOUNT_' . $this->getId() . '_' . $this->getDefaultRole();
  1027. }
  1028. /**
  1029. * Set hideFromInvoicing
  1030. *
  1031. * @param bool $hideFromInvoicing
  1032. *
  1033. * @return Account
  1034. */
  1035. public function setHideFromInvoicing($hideFromInvoicing)
  1036. {
  1037. $this->hide_from_invoicing = $hideFromInvoicing;
  1038. return $this;
  1039. }
  1040. /**
  1041. * Get hideFromInvoicing
  1042. *
  1043. * @return bool
  1044. */
  1045. public function getHideFromInvoicing()
  1046. {
  1047. return $this->hide_from_invoicing;
  1048. }
  1049. /**
  1050. * Set invoicePaymentTerms
  1051. *
  1052. * @param int $invoicePaymentTerms
  1053. *
  1054. * @return Account
  1055. */
  1056. public function setInvoicePaymentTerms($invoicePaymentTerms)
  1057. {
  1058. $this->invoice_payment_terms = $invoicePaymentTerms;
  1059. return $this;
  1060. }
  1061. /**
  1062. * Get invoicePaymentTerms
  1063. *
  1064. * @return int
  1065. */
  1066. public function getInvoicePaymentTerms()
  1067. {
  1068. return $this->invoice_payment_terms;
  1069. }
  1070. /**
  1071. * Get the disabled UserNotification types
  1072. *
  1073. * @return array
  1074. */
  1075. public function getDisabledNotifications(): array
  1076. {
  1077. return $this->disabled_notifications ?: [];
  1078. }
  1079. /**
  1080. * @param array $disabled_notifications
  1081. *
  1082. * @return Account
  1083. */
  1084. public function setDisabledNotifications(array $disabled_notifications): Account
  1085. {
  1086. $this->disabled_notifications = $disabled_notifications;
  1087. return $this;
  1088. }
  1089. /**
  1090. * Disable a notification
  1091. *
  1092. * @param $notification_type
  1093. *
  1094. * @return Account
  1095. */
  1096. public function disableNotification($notification_type)
  1097. {
  1098. if (!$this->disabled_notifications) {
  1099. $this->disabled_notifications = [];
  1100. }
  1101. array_push($this->disabled_notifications, $notification_type);
  1102. return $this;
  1103. }
  1104. /**
  1105. * Function to determine if the specific UserNotification is disabled for this Entity
  1106. *
  1107. * @param $notification_type
  1108. *
  1109. * @return bool
  1110. */
  1111. public function isNotificationDisabled($notification_type)
  1112. {
  1113. if (!$this->disabled_notifications) {
  1114. $this->disabled_notifications = [];
  1115. return false;
  1116. }
  1117. return in_array($notification_type, $this->disabled_notifications) ? true : false;
  1118. }
  1119. /**
  1120. * Set defaultSortingInstruction.
  1121. *
  1122. * @param SortingInstruction|null $defaultSortingInstruction
  1123. *
  1124. * @return Account
  1125. */
  1126. public function setDefaultSortingInstruction(?SortingInstruction $defaultSortingInstruction = null)
  1127. {
  1128. $this->defaultSortingInstruction = $defaultSortingInstruction;
  1129. return $this;
  1130. }
  1131. /**
  1132. * Get defaultSortingInstruction.
  1133. *
  1134. * @return SortingInstruction|null
  1135. */
  1136. public function getDefaultSortingInstruction()
  1137. {
  1138. return $this->defaultSortingInstruction;
  1139. }
  1140. /**
  1141. * Set requireMemo.
  1142. *
  1143. * @param bool $requireMemo
  1144. *
  1145. * @return Account
  1146. */
  1147. public function setRequireMemo($requireMemo)
  1148. {
  1149. $this->requireMemo = $requireMemo;
  1150. return $this;
  1151. }
  1152. /**
  1153. * Get requireMemo.
  1154. *
  1155. * @return bool
  1156. */
  1157. public function getRequireMemo()
  1158. {
  1159. return $this->requireMemo;
  1160. }
  1161. /**
  1162. * Set requirePasswordOnDownload.
  1163. *
  1164. * @param bool $requirePasswordOnDownload
  1165. *
  1166. * @return Account
  1167. */
  1168. public function setRequirePasswordOnDownload($requirePasswordOnDownload)
  1169. {
  1170. $this->require_password_on_download = $requirePasswordOnDownload;
  1171. return $this;
  1172. }
  1173. /**
  1174. * Get requirePasswordOnDownload.
  1175. *
  1176. * @return bool
  1177. */
  1178. public function getRequirePasswordOnDownload()
  1179. {
  1180. return $this->require_password_on_download;
  1181. }
  1182. /**
  1183. * Add accountSortingMemoPhrase.
  1184. *
  1185. * @param AccountSortingMemoPhrase $accountSortingMemoPhrase
  1186. *
  1187. * @return Account
  1188. */
  1189. public function addAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
  1190. {
  1191. $this->accountSortingMemoPhrases[] = $accountSortingMemoPhrase;
  1192. return $this;
  1193. }
  1194. /**
  1195. * Remove accountSortingMemoPhrase.
  1196. *
  1197. * @param AccountSortingMemoPhrase $accountSortingMemoPhrase
  1198. *
  1199. * @return bool TRUE if this collection contained the specified element, FALSE otherwise.
  1200. */
  1201. public function removeAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
  1202. {
  1203. return $this->accountSortingMemoPhrases->removeElement($accountSortingMemoPhrase);
  1204. }
  1205. /**
  1206. * Get accountSortingMemoPhrases.
  1207. *
  1208. * @return Collection
  1209. */
  1210. public function getAccountSortingMemoPhrases()
  1211. {
  1212. return $this->accountSortingMemoPhrases;
  1213. }
  1214. /**
  1215. * Set matterRequestDefaults.
  1216. *
  1217. * @param MatterRequestDefaults|null $matterRequestDefaults
  1218. *
  1219. * @return Account
  1220. */
  1221. public function setMatterRequestDefaults(?MatterRequestDefaults $matterRequestDefaults = null)
  1222. {
  1223. $this->matterRequestDefaults = $matterRequestDefaults;
  1224. return $this;
  1225. }
  1226. /**
  1227. * Get matterRequestDefaults.
  1228. *
  1229. * @return MatterRequestDefaults|null
  1230. */
  1231. public function getMatterRequestDefaults()
  1232. {
  1233. return $this->matterRequestDefaults;
  1234. }
  1235. /**
  1236. * Returns the return details address.
  1237. *
  1238. * @return ContactableAddress|null
  1239. */
  1240. public function getReturnDetailsAddress(): ?ContactableAddress
  1241. {
  1242. if ($this->getOffices() && $this->getOffices()->first()) {
  1243. return $this->getOffices()->first();
  1244. }
  1245. return null;
  1246. }
  1247. /**
  1248. * Set matterCreationProcess.
  1249. *
  1250. * @param string|null $matterCreationProcess
  1251. *
  1252. * @return Account
  1253. */
  1254. public function setMatterCreationProcess($matterCreationProcess = null): Account
  1255. {
  1256. $this->matterCreationProcess = $matterCreationProcess;
  1257. return $this;
  1258. }
  1259. /**
  1260. * Set customIndexHeader.
  1261. *
  1262. * @param string|null $customIndexHeader
  1263. *
  1264. * @return Account
  1265. */
  1266. public function setCustomIndexHeader($customIndexHeader = null)
  1267. {
  1268. $this->custom_index_header = $customIndexHeader;
  1269. return $this;
  1270. }
  1271. /**
  1272. * Get customIndexHeader.
  1273. *
  1274. * @return string|null
  1275. */
  1276. public function getCustomIndexHeader()
  1277. {
  1278. return $this->custom_index_header;
  1279. }
  1280. /**
  1281. * Get matterCreationProcess.
  1282. *
  1283. * @return string|null
  1284. */
  1285. public function getMatterCreationProcess(): ?string
  1286. {
  1287. return $this->matterCreationProcess;
  1288. }
  1289. /**
  1290. * Returns true if the client has access to classic matter creation.
  1291. *
  1292. * @return bool
  1293. */
  1294. public function hasAccessToClassicMatterCreation(): bool
  1295. {
  1296. return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_CLASSIC || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL || $this->matterCreationProcess === null;
  1297. }
  1298. /**
  1299. * Returns true if the client has access to standard matter creation.
  1300. *
  1301. * @return bool
  1302. */
  1303. public function hasAccessToStandardMatterCreation(): bool
  1304. {
  1305. return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_STANDARD || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL;
  1306. }
  1307. /**
  1308. * Returns matter creations options as an array, usable as the choices for a form.
  1309. *
  1310. * @return array
  1311. */
  1312. public static function getMatterCreationProcessOptions(): array
  1313. {
  1314. $matterCreationProcessOptions = self::getConstantsWithLabelsAsChoices('MATTER_CREATION_PROCESS');
  1315. return array_flip($matterCreationProcessOptions);
  1316. }
  1317. /**
  1318. * Returns a human readable version of matterCreationProcess.
  1319. *
  1320. * @return string
  1321. */
  1322. public function getMatterCreationProcessName()
  1323. {
  1324. $options = self::getMatterCreationProcessOptions();
  1325. return $options[$this->getMatterCreationProcess()] ?? $this->getMatterCreationProcess();
  1326. }
  1327. /**
  1328. * Get the value of standardIndexHeader
  1329. *
  1330. * @return string|null
  1331. */
  1332. public function getStandardIndexHeader()
  1333. {
  1334. return $this->standardIndexHeader;
  1335. }
  1336. /**
  1337. * Set the value of standardIndexHeader
  1338. *
  1339. * @param string|null $standardIndexHeader
  1340. *
  1341. * @return self
  1342. */
  1343. public function setStandardIndexHeader($standardIndexHeader)
  1344. {
  1345. $this->standardIndexHeader = $standardIndexHeader;
  1346. return $this;
  1347. }
  1348. /**
  1349. * Set canCreateBatchAndSort.
  1350. *
  1351. * @param bool $canCreateBatchAndSort
  1352. *
  1353. * @return Account
  1354. */
  1355. public function setCanCreateBatchAndSort($canCreateBatchAndSort)
  1356. {
  1357. $this->canCreateBatchAndSort = $canCreateBatchAndSort;
  1358. return $this;
  1359. }
  1360. /**
  1361. * Get canCreateBatchAndSort.
  1362. *
  1363. * @return bool
  1364. */
  1365. public function getCanCreateBatchAndSort()
  1366. {
  1367. return $this->canCreateBatchAndSort;
  1368. }
  1369. /**
  1370. * getAllowExpertViewUnsortedRecords
  1371. *
  1372. * @return bool
  1373. */
  1374. public function getAllowExpertViewUnsortedRecords(): bool
  1375. {
  1376. return $this->allowExpertViewUnsortedRecords;
  1377. }
  1378. /**
  1379. * @param bool $allowExpertViewUnsortedRecords
  1380. *
  1381. * @return self
  1382. */
  1383. public function setAllowExpertViewUnsortedRecords(bool $allowExpertViewUnsortedRecords): self
  1384. {
  1385. $this->allowExpertViewUnsortedRecords = $allowExpertViewUnsortedRecords;
  1386. return $this;
  1387. }
  1388. /**
  1389. * @return bool
  1390. */
  1391. public function getMatterClosureQuestionsOptional(): bool
  1392. {
  1393. return $this->matterClosureQuestionsOptional;
  1394. }
  1395. /**
  1396. * @param bool $matterClosureQuestionsOptional
  1397. *
  1398. * @return Account
  1399. */
  1400. public function setMatterClosureQuestionsOptional(bool $matterClosureQuestionsOptional): self
  1401. {
  1402. $this->matterClosureQuestionsOptional = $matterClosureQuestionsOptional;
  1403. return $this;
  1404. }
  1405. /**
  1406. * @return bool|null
  1407. *
  1408. */
  1409. public function getUseParentClinicalSectionsOnly(): ?bool
  1410. {
  1411. return $this->useParentClinicalSectionsOnly;
  1412. }
  1413. /**
  1414. * @param bool $useParentClinicalSectionsOnly
  1415. *
  1416. * @return self
  1417. *
  1418. */
  1419. public function setUseParentClinicalSectionsOnly(bool $useParentClinicalSectionsOnly): self
  1420. {
  1421. $this->useParentClinicalSectionsOnly = $useParentClinicalSectionsOnly;
  1422. return $this;
  1423. }
  1424. public function getFirm(): ?Firm
  1425. {
  1426. return $this->firm;
  1427. }
  1428. public function setFirm(?Firm $firm): self
  1429. {
  1430. $this->firm = $firm;
  1431. return $this;
  1432. }
  1433. /**
  1434. * @return bool
  1435. */
  1436. public function getHideLogoFromIndex(): bool
  1437. {
  1438. return $this->hideLogoFromIndex;
  1439. }
  1440. /**
  1441. * @param bool $hideLogoFromIndex
  1442. *
  1443. * @return self
  1444. */
  1445. public function setHideLogoFromIndex(bool $hideLogoFromIndex): self
  1446. {
  1447. $this->hideLogoFromIndex = $hideLogoFromIndex;
  1448. return $this;
  1449. }
  1450. /**
  1451. * @return array|null
  1452. *
  1453. */
  1454. public function getAllowedMatterTypes(): ?array
  1455. {
  1456. return $this->allowedMatterTypes;
  1457. }
  1458. /**
  1459. * @param array|null $allowedMatterTypes
  1460. *
  1461. * @return self
  1462. *
  1463. */
  1464. public function setAllowedMatterTypes(?array $allowedMatterTypes): self
  1465. {
  1466. $this->allowedMatterTypes = $allowedMatterTypes;
  1467. return $this;
  1468. }
  1469. /**
  1470. * @return array
  1471. */
  1472. public static function getAllowedMatterTypeOptions(): array
  1473. {
  1474. return self::getConstantsWithLabelsAsChoices('MATTER_TYPE');
  1475. }
  1476. /**
  1477. * @return Collection<int, LicenceRenewalTerm>
  1478. */
  1479. public function getLicenceRenewalTerms(): Collection
  1480. {
  1481. return $this->licenceRenewalTerms;
  1482. }
  1483. /**
  1484. * @return Collection<int, LicenceRenewalTerm>
  1485. */
  1486. public function getZeroPeriodLicenceRenewalTerms(): Collection
  1487. {
  1488. return $this->licenceRenewalTerms->filter(function ($term) {
  1489. return $term->getPeriod() === 0;
  1490. });
  1491. }
  1492. /**
  1493. * @param LicenceRenewalTerm $licenceRenewalTerm
  1494. *
  1495. * @return self
  1496. */
  1497. public function addLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
  1498. {
  1499. if (!$this->licenceRenewalTerms->contains($licenceRenewalTerm)) {
  1500. $this->licenceRenewalTerms[] = $licenceRenewalTerm;
  1501. $licenceRenewalTerm->setAccount($this);
  1502. }
  1503. return $this;
  1504. }
  1505. /**
  1506. * @param LicenceRenewalTerm $licenceRenewalTerm
  1507. *
  1508. * @return self
  1509. */
  1510. public function removeLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
  1511. {
  1512. if ($this->licenceRenewalTerms->removeElement($licenceRenewalTerm)) {
  1513. // set the owning side to null (unless already changed)
  1514. if ($licenceRenewalTerm->getAccount() === $this) {
  1515. $licenceRenewalTerm->setAccount(null);
  1516. }
  1517. }
  1518. return $this;
  1519. }
  1520. /**
  1521. * @return bool|null
  1522. */
  1523. public function isEnforceTwoFactorAuth(): ?bool
  1524. {
  1525. return $this->enforceTwoFactorAuth;
  1526. }
  1527. /**
  1528. * @param bool $enforceTwoFactorAuth
  1529. *
  1530. * @return self
  1531. */
  1532. public function setEnforceTwoFactorAuth(bool $enforceTwoFactorAuth): self
  1533. {
  1534. $this->enforceTwoFactorAuth = $enforceTwoFactorAuth;
  1535. return $this;
  1536. }
  1537. /**
  1538. * @return bool|null
  1539. */
  1540. public function isAllowTwoFactorAuthGracePeriod(): ?bool
  1541. {
  1542. return $this->allowTwoFactorAuthGracePeriod;
  1543. }
  1544. /**
  1545. * @param bool $allowTwoFactorAuthGracePeriod
  1546. *
  1547. * @return self
  1548. */
  1549. public function setAllowTwoFactorAuthGracePeriod(bool $allowTwoFactorAuthGracePeriod): self
  1550. {
  1551. $this->allowTwoFactorAuthGracePeriod = $allowTwoFactorAuthGracePeriod;
  1552. return $this;
  1553. }
  1554. /**
  1555. * Checks if the client is not liable for the disclosure fee.
  1556. *
  1557. * @return bool True if the client is not liable, false otherwise.
  1558. */
  1559. public function isClientNotLiableForDisclosureFee(): bool
  1560. {
  1561. return $this->clientNotLiableForDisclosureFee;
  1562. }
  1563. /**
  1564. * Sets whether the client is not liable for the disclosure fee.
  1565. *
  1566. * @param bool $clientNotLiableForDisclosureFee True if the client is not liable, false otherwise.
  1567. *
  1568. * @return self
  1569. */
  1570. public function setClientNotLiableForDisclosureFee(bool $clientNotLiableForDisclosureFee): self
  1571. {
  1572. $this->clientNotLiableForDisclosureFee = $clientNotLiableForDisclosureFee;
  1573. return $this;
  1574. }
  1575. }