<?php
namespace MedBrief\MSR\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MedBrief\MSR\Controller\Account\Managers;
use MedBrief\MSR\Controller\Account\UserRestrictedAccounts;
use MedBrief\MSR\Entity\MatterRequest\MatterRequestDefaults;
use MedBrief\MSR\Repository\AccountRepository;
use MedBrief\MSR\Service\MatterTypeAwareInterface;
use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* collectionOperations={
* "get"={
* "access_control"="is_granted('CREATE_MATTER_REQUEST')",
* "method"="GET",
* "path"="/accounts",
* "controller"=UserRestrictedAccounts::class,
* "defaults"={"_api_receive"=false},
* "openapi_context"={
* "summary"="Retrieves all Account (Client Area) resources available.",
* "description"="Retrieves all Account (Client Area) resources available. To be used in the 'clientAreaId' field when creating a Matter Request.",
* }
* },
* "client_areas"={
* "access_control"="is_granted('CREATE_MATTER_REQUEST')",
* "method"="GET",
* "path"="/client-areas",
* "controller"=UserRestrictedAccounts::class,
* "defaults"={"_api_receive"=false},
* "normalization_context"={"groups"={"client_area:read"}},
* "openapi_context"={
* "summary"="Retrieves all Account (Client Area) resources available.",
* "description"="Retrieves all Account (Client Area) resources available. See [Client Areas](/docs/api/detail#client-areas)",
* }
* }
* },
* itemOperations={
* "get"={"access_control"="is_granted('READ', object)"},
* "managers_get"={
* "access_control"="is_granted('CREATE_MATTER_REQUEST')",
* "method"="GET",
* "path"="/accounts/{id}/managers",
* "controller"=Managers::class,
* "openapi_context"={
* "summary"="Retrieves all User resources that can be assigned as Matter Manager.",
* "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.",
* "responses"={
* "200"={
* "description"="A collection of User resources",
* "content"={
* "application/ld+json"={
* "schema"={
* "$ref"="#/components/schemas/User.jsonld-user.read"
* }
* },
* "application/json"={
* "schema"={
* "$ref"="#/components/schemas/User-user.read"
* }
* }
* }
* }
* }
* }
* },
* },
* attributes={
* "normalization_context"={"groups"={"account:read"}},
* }
* )
*
* @ORM\Table(name="account")
*
* @ORM\Entity(repositoryClass=AccountRepository::class)
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class Account implements MatterTypeAwareInterface
{
use FilterableClassConstantsTrait;
public const INVOICE_BILLING_FREQUENCY_MONTHLY = 1;
public const INVOICE_BILLING_FREQUENCY_QUARTERLY = 2;
public const INVOICE_BILLING_FREQUENCY_START_OF_MATTER = 3;
public const INVOICE_TYPE_INDIVIDUAL_MATTER = 1;
public const INVOICE_TYPE_CONSOLIDATED = 2;
// Default role options
public const DEFAULT_ROLE_ADMINISTRATOR = 'ADMINISTRATOR';
public const DEFAULT_ROLE_SUPERADMINISTRATOR = 'SUPERADMINISTRATOR';
public const DEFAULT_ROLE_PROJECTMANAGER = 'PROJECTMANAGER';
public const DEFAULT_ROLE_SORTER = 'SORTER';
// Only has access to the old matter creation form
public const MATTER_CREATION_PROCESS_CLASSIC = 'classic';
public const MATTER_CREATION_PROCESS_CLASSIC__LABEL = 'Classic';
// Only has access to the new matter creation form
public const MATTER_CREATION_PROCESS_STANDARD = 'standard';
public const MATTER_CREATION_PROCESS_STANDARD__LABEL = 'Standard';
// Has access to both the old and new matter creation form
public const MATTER_CREATION_PROCESS_ALL = 'all';
public const MATTER_CREATION_PROCESS_ALL__LABEL = 'Standard & Classic';
// Country of Registration options
public const COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES = 'england_and_wales';
public const COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES__LABEL = 'England and Wales';
public const COUNTRY_OF_REGISTRATION_SCOTLAND = 'scotland';
public const COUNTRY_OF_REGISTRATION_SCOTLAND__LABEL = 'Scotland';
public const COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND = 'northern_ireland';
public const COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND__LABEL = 'Northern Ireland';
/**
* @var ContactableAddress
*
* This field is unmapped, and is purely here for the API.
*
* @Groups({"account:read", "matter_request:read"})
*/
protected $returnDetailsAddress;
/**
* @var string
*
* @ORM\Column(name="matterCreationProcess", type="string", nullable=true)
*/
protected $matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
/**
* @var string|null
*
* @ORM\Column(name="custom_index_header", type="text", nullable=true)
*/
protected $custom_index_header;
/**
* @var string|null
*
* @ORM\Column(name="standardIndexHeader", type="text", nullable=true)
*/
protected $standardIndexHeader;
/**
* Indicates if the MedBrief logo should be hidden from the index produced.
* The scenario for this is where clients sort their own records, or a sorting standard that
* deviates from our standard sorting product.
*
* @var bool
*
* @ORM\Column(type="boolean", options={"default"=false})
*/
protected $hideLogoFromIndex = false;
/**
* @Groups({"client_area:read"})
*
* @ORM\Column(name="id", type="bigint", nullable=false)
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private ?int $id;
/**
* @Groups({"account:read", "matter_request:read", "client_area:read"})
*
* @ORM\Column(name="name", type="string", length=155, nullable=false)
*/
private ?string $name;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Domain", mappedBy="account", cascade={"all"})
*/
private $domains;
/**
* @var array|null
*
* @ORM\Column(name="allowed_license_levels", type="array", nullable=true)
*/
private $allowed_license_levels;
/**
* @var string|null
*
* @ORM\Column(name="prefix", type="string", length=25, nullable=true)
*/
private $prefix;
/**
* @var string|null
*
* @ORM\Column(name="legal_entity_name", type="text", nullable=true)
*/
private $legal_entity_name;
/**
* Sets all service requests for this client not to come up for invoicing.
*
* @var bool
*
* @ORM\Column(name="hide_from_invoicing", type="boolean", options={"default"=false})
*/
private $hide_from_invoicing;
/**
* @var string|null
*
* @ORM\Column(name="default_role", type="string", nullable=true)
*/
private $default_role;
/**
* Holds the Account's payment terms value (in days) for adjusting
* the due date on invoices automagically.
*
* @var int
*
* @ORM\Column(name="invoice_payment_terms", type="integer", nullable=true)
*/
private $invoice_payment_terms;
/**
* @var int|null
*
* @ORM\Column(name="invoice_billing_frequency", type="integer", nullable=true)
*/
private $invoice_billing_frequency;
/**
* @var int|null
*
* @ORM\Column(name="invoice_type", type="integer", nullable=true)
*/
private $invoice_type;
/**
* The different UserNotifications disabled for this Client
*
* @var array
*
* @ORM\Column(name="disabled_notifications", type="array", nullable=true)
*/
private $disabled_notifications = [];
/**
* A default sorting instruction for all the Account's sorting sessions.
* This is visible to the sorter.
*
* @var SortingInstruction
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\SortingInstruction", inversedBy="account", cascade={"persist","remove"}, orphanRemoval=true)
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="defaultSortingInstruction_id", referencedColumnName="id", unique=true)
* })
*/
private $defaultSortingInstruction;
/**
* Determines if a draft memo will be exported for the client on Sorting Session completions.
*
* @var bool
*
* @ORM\Column(name="requireMemo", type="boolean", options={"default"=false})
*/
private $requireMemo = false;
/**
* Whether to require the user to enter a password on downloading a document or folder
*
* @var bool
*
* @ORM\Column(name="require_password_on_download", type="boolean", options={"default"=false})
*/
private $require_password_on_download;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\AccountSortingMemoPhrase", mappedBy="account", cascade={"all"})
*/
private $accountSortingMemoPhrases;
/**
* @var MatterRequestDefaults
*
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\MatterRequest\MatterRequestDefaults", mappedBy="account")
*/
private $matterRequestDefaults;
/**
* @var ContactableAddress
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="billingAddress_id", referencedColumnName="id", unique=true)
* })
*/
private $billingAddress;
/**
* @var ContactableAddress
*/
private $accountsAddress;
/**
* @var ContactableAddress
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\ContactableAddress", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="physicalAddress_id", referencedColumnName="id", unique=true)
* })
*/
private $physicalAddress;
/**
* @var Collection
*
* @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\ContactableAddress", inversedBy="accounts", cascade={"persist"})
*
* @ORM\JoinTable(name="account_contactableaddress",
* joinColumns={
*
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="contactableaddress_id", referencedColumnName="id", onDelete="CASCADE")
* }
* )
*/
private $offices;
/**
* @var string
*
* @ORM\Column(name="slug", type="string")
*
* @Gedmo\Slug(fields={"name"}, updatable=false, separator="_")
*/
private $slug;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\Project", mappedBy="account", cascade={"all"})
*/
private $projects;
/**
* @var Collection
*/
private $addresses;
/**
* @var \DateTime
*
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @var string
*/
private $image;
/**
* @var string
*
* @ORM\Column(name="image_name", type="string", length=255, nullable=true)
*/
private $image_name;
/**
* Determines if an account can create/update batch requests and sort sessions.
*
* @var bool
*
* @ORM\Column(name="canCreateBatchAndSort", type="boolean", options={"default"=false})
*/
private $canCreateBatchAndSort = false;
/**
* Determines if an account can is able to use match.
*
* @var bool
*
* @ORM\Column(name="matchOptIn", type="boolean", options={"default"=false})
*/
private bool $matchOptIn = false;
/**
* Determines the default value of the same field on a Project/Matter, when a new Project is created.
*
* @var bool
*
* @ORM\Column(name="allowExpertViewUnsortedRecords", type="boolean", options={"default"=false})
*/
private $allowExpertViewUnsortedRecords = false;
/**
* Determines if the questions presented during the Matter Closure Wizard are optional.
*
* @var bool
*
* @ORM\Column(name="matterClosureQuestionsOptional", type="boolean", options={"default"=false})
*/
private $matterClosureQuestionsOptional = false;
/**
* @var bool
*
* @ORM\Column(name="useParentClinicalSectionsOnly", type="boolean")
*/
private $useParentClinicalSectionsOnly = false;
/**
* @ORM\ManyToOne(targetEntity=Firm::class, inversedBy="clientAreas")
*/
private $firm;
/**
* @Groups({"account:read", "matter_request:read"})
*
* @ORM\Column(name="allowedMatterTypes", type="array", nullable=true)
*
* @Assert\Count(
* min=1,
* minMessage = "Please select an option.",
* groups={"account:read", "matter_request:read"}
* )
*/
private array $allowedMatterTypes = [];
/**
* @ORM\OneToMany(targetEntity=LicenceRenewalTerm::class, mappedBy="account", orphanRemoval=true)
*
* @ORM\OrderBy({"effectiveDate" = "ASC"})
*
* When a new period is added, a new related service option for the same period should also be created and mapped.
*/
private ?Collection $licenceRenewalTerms;
/**
* Sets whether any client level users, or users invited to the client's
* matters should require 2FA to be enabled.
*
* @ORM\Column(type="boolean", options={"default"=false})
*/
private bool $enforceTwoFactorAuth = false;
/**
* If enabled, allows the users that are forced to enabled 2FA via the
* enforceTwoFactorAuth property to skip the requirement for the first
* two (2) logins.
*
* @ORM\Column(type="boolean", options={"default"=false})
*/
private bool $allowTwoFactorAuthGracePeriod = false;
/**
* If enabled, the account (client) is not liable for the disclosure fee,
* the Recipient Firm is liable.
*
* @ORM\Column(type="boolean", options={"default"=false})
*/
private bool $clientNotLiableForDisclosureFee = false;
/**
* @var string|null
*
* @ORM\Column(name="trading_name", type="text", nullable=true)
*
* @Assert\NotBlank(message="Trading name is required")
*/
private $trading_name = null;
/**
* @var string|null
*
* @ORM\Column(name="company_registration_number", type="string", length=255, nullable=true)
*
* @Assert\NotBlank(message="Company registration number is required")
*/
private $company_registration_number = null;
/**
* @var string|null
*
* @ORM\Column(name="country_of_registration", type="string", length=255, nullable=true)
*
* @Assert\NotBlank(message="Country of registration is required")
*/
private $country_of_registration = null;
/**
* Constructor
*/
public function __construct()
{
$this->domains = new ArrayCollection();
$this->allowed_license_levels = [];
$this->hide_from_invoicing = false;
$this->require_password_on_download = false;
$this->accountSortingMemoPhrases = new ArrayCollection();
$this->matterCreationProcess = self::MATTER_CREATION_PROCESS_CLASSIC;
$this->projects = new ArrayCollection();
$this->offices = new ArrayCollection();
$this->licenceRenewalTerms = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return Account
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Add domains
*
* @param Domain $domains
*
* @return Account
*/
public function addDomain(Domain $domains)
{
$this->domains[] = $domains;
return $this;
}
/**
* Remove domains
*
* @param Domain $domains
*/
public function removeDomain(Domain $domains)
{
$this->domains->removeElement($domains);
}
/**
* Get domains
*
* @return Collection
*/
public function getDomains()
{
return $this->domains;
}
/**
* Set slug
*
* @param string $slug
*
* @return Account
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set created
*
* @param \DateTime $created
*
* @return Account
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
*
* @return Account
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Add projects
*
* @param Project $projects
*
* @return Account
*/
public function addProject(Project $projects)
{
$this->projects[] = $projects;
return $this;
}
/**
* Remove projects
*
* @param Project $projects
*/
public function removeProject(Project $projects)
{
$this->projects->removeElement($projects);
}
/**
* Get projects
*
* @return Collection
*/
public function getProjects()
{
return $this->projects;
}
public function getArchivedProjects()
{
$criteria = Criteria::create()
->where(Criteria::expr()->gt('archive_status', 0))
->orderBy(['name' => Criteria::ASC])
;
return $this->getProjects()->matching($criteria);
}
public function getActiveProjects()
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq('status', Project::STATUS_ACTIVE))
->orderBy(['name' => Criteria::ASC])
;
return $this->getProjects()->matching($criteria);
}
public function getInactiveProjects()
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq('status', Project::STATUS_INACTIVE))
->orderBy(['name' => Criteria::ASC])
;
return $this->getProjects()->matching($criteria);
}
/**
* Set invoice_billing_frequency
*
* @param string $invoiceBillingFrequency
*
* @return Account
*/
public function setInvoiceBillingFrequency($invoiceBillingFrequency)
{
$this->invoice_billing_frequency = $invoiceBillingFrequency;
return $this;
}
/**
* Get invoice_billing_frequency
*
* @return string
*/
public function getInvoiceBillingFrequency()
{
return $this->invoice_billing_frequency;
}
/**
* Set invoice_type
*
* @param string $invoiceType
*
* @return Account
*/
public function setInvoiceType($invoiceType)
{
$this->invoice_type = $invoiceType;
return $this;
}
/**
* Get invoice_type
*
* @return string
*/
public function getInvoiceType()
{
return $this->invoice_type;
}
/**
* Set billingAddress
*
* @param ContactableAddress $billingAddress
*
* @return Account
*/
public function setBillingAddress(?ContactableAddress $billingAddress = null)
{
$this->billingAddress = $billingAddress;
return $this;
}
/**
* Get billingAddress
*
* @return ContactableAddress
*/
public function getBillingAddress()
{
return $this->billingAddress;
}
/**
* Set accountsAddress
*
* @param ContactableAddress $accountsAddress
*
* @return Account
*/
public function setAccountsAddress(?ContactableAddress $accountsAddress = null)
{
$this->accountsAddress = $accountsAddress;
return $this;
}
/**
* Get accountsAddress
*
* @return ContactableAddress
*/
public function getAccountsAddress()
{
return $this->accountsAddress;
}
/**
* Set physicalAddress
*
* @param ContactableAddress $physicalAddress
*
* @return Account
*/
public function setPhysicalAddress(?ContactableAddress $physicalAddress = null)
{
$this->physicalAddress = $physicalAddress;
return $this;
}
/**
* Get physicalAddress
*
* @return ContactableAddress
*/
public function getPhysicalAddress()
{
return $this->physicalAddress;
}
/**
* Add offices
*
* @param ContactableAddress $offices
*
* @return Account
*/
public function addOffice(ContactableAddress $offices)
{
$this->offices[] = $offices;
return $this;
}
/**
* Remove offices
*
* @param ContactableAddress $offices
*/
public function removeOffice(ContactableAddress $offices)
{
$this->offices->removeElement($offices);
}
/**
* Get offices
*
* @return Collection
*/
public function getOffices()
{
return $this->offices;
}
/**
* Returns an array of permitted values for the invoice billing frequency field and their
* associated labels,
*
* @return array
*/
public static function getInvoiceBillingFrequencyOptions()
{
return [
self::INVOICE_BILLING_FREQUENCY_MONTHLY => 'Monthly',
self::INVOICE_BILLING_FREQUENCY_QUARTERLY => 'Quarterly',
self::INVOICE_BILLING_FREQUENCY_START_OF_MATTER => 'At the start of the matter',
];
}
/**
* Returns a human readable version of the invoice billing frequency
*
* @return string
*/
public function getInvoiceBillingFrequencyName()
{
$options = self::getInvoiceBillingFrequencyOptions();
return
$options[$this->getInvoiceBillingFrequency()] ?? $this->getInvoiceBillingFrequency();
}
/**
* Returns an array of permitted values for the invoice billing frequency field and their
* associated labels,
*
* @return array
*/
public static function getInvoiceTypeOptions()
{
return [
self::INVOICE_TYPE_CONSOLIDATED => 'Consolidated',
self::INVOICE_TYPE_INDIVIDUAL_MATTER => 'Individual Matter',
];
}
/**
* Returns a human readable version of the invoice billing frequency
*
* @return string
*/
public function getInvoiceTypeName()
{
$options = self::getInvoiceTypeOptions();
return
$options[$this->getInvoiceType()] ?? $this->getInvoiceType();
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return Account
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set image
*
* @param string $image
*
* @return Account
*/
public function setImage($image)
{
if (null !== $image) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updated = new \DateTimeImmutable();
}
$this->image = $image;
return $this;
}
/**
* Indicates whether or not this user has an image
*
* @return bool
*/
public function hasImage()
{
// note that we use the imageName field because the image field will be
// populated with the gaufrette file location immediately on upload
// even if the upload fails. So if you call this function on the user
// before it is peristed it may give you a false positive.
$image = $this->getImageName();
return !empty($image);
}
/**
* Get image
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set image_name
*
* @param string $imageName
*
* @return Account
*/
public function setImageName($imageName)
{
$this->image_name = $imageName;
return $this;
}
/**
* Get image_name
*
* @return string
*/
public function getImageName()
{
return $this->image_name;
}
/**
* Set allowedLicenseLevels
*
* @param array $allowedLicenseLevels
*
* @return Account
*/
public function setAllowedLicenseLevels($allowedLicenseLevels)
{
$this->allowed_license_levels = $allowedLicenseLevels;
return $this;
}
/**
* Get allowedLicenseLevels
*
* @return array
*/
public function getAllowedLicenseLevels()
{
if ($this->allowed_license_levels === null) {
return [];
}
return $this->allowed_license_levels;
}
/**
* Set prefix
*
* @param string $prefix
*
* @return Account
*/
public function setPrefix($prefix)
{
$this->prefix = strtoupper($prefix);
return $this;
}
/**
* Get prefix
*
* @return string
*/
public function getPrefix()
{
return strtoupper($this->prefix);
}
/**
* Set legalEntityName
*
* @param string $legalEntityName
*
* @return Account
*/
public function setLegalEntityName($legalEntityName)
{
$this->legal_entity_name = $legalEntityName;
return $this;
}
/**
* Get legalEntityName
*
* @return string
*/
public function getLegalEntityName()
{
return $this->legal_entity_name;
}
/**
* Set defaultRole
*
* @param string $defaultRole
*
* @return Account
*/
public function setDefaultRole($defaultRole)
{
$this->default_role = $defaultRole;
return $this;
}
/**
* Get defaultRole
*
* @return string
*/
public function getDefaultRole()
{
return $this->default_role;
}
/**
* Get defaultRoleOptions
*
* @return array
*/
public static function getDefaultRoleOptions()
{
return [
self::DEFAULT_ROLE_ADMINISTRATOR => 'Client Administrator',
self::DEFAULT_ROLE_SUPERADMINISTRATOR => 'Client Super Administrator',
self::DEFAULT_ROLE_PROJECTMANAGER => 'Client Project Manager',
self::DEFAULT_ROLE_SORTER => 'Sorter',
];
}
/**
* Get DefaultRoleLabel
*
* @return string
*/
public function getDefaultRoleLabel()
{
$options = self::getDefaultRoleOptions();
return $options[$this->getDefaultRole()] ?? '';
}
/**
* Get DefaultRoleLabel
*
* @return string
*/
public function getDefaultRoleAsRole()
{
if (!$this->getDefaultRole()) {
return '';
}
return 'ROLE_ACCOUNT_' . $this->getId() . '_' . $this->getDefaultRole();
}
/**
* Set hideFromInvoicing
*
* @param bool $hideFromInvoicing
*
* @return Account
*/
public function setHideFromInvoicing($hideFromInvoicing)
{
$this->hide_from_invoicing = $hideFromInvoicing;
return $this;
}
/**
* Get hideFromInvoicing
*
* @return bool
*/
public function getHideFromInvoicing()
{
return $this->hide_from_invoicing;
}
/**
* Set invoicePaymentTerms
*
* @param int $invoicePaymentTerms
*
* @return Account
*/
public function setInvoicePaymentTerms($invoicePaymentTerms)
{
$this->invoice_payment_terms = $invoicePaymentTerms;
return $this;
}
/**
* Get invoicePaymentTerms
*
* @return int
*/
public function getInvoicePaymentTerms()
{
return $this->invoice_payment_terms;
}
/**
* Get the disabled UserNotification types
*
* @return array
*/
public function getDisabledNotifications(): array
{
return $this->disabled_notifications ?: [];
}
/**
* @param array $disabled_notifications
*
* @return Account
*/
public function setDisabledNotifications(array $disabled_notifications): Account
{
$this->disabled_notifications = $disabled_notifications;
return $this;
}
/**
* Disable a notification
*
* @param $notification_type
*
* @return Account
*/
public function disableNotification($notification_type)
{
if (!$this->disabled_notifications) {
$this->disabled_notifications = [];
}
array_push($this->disabled_notifications, $notification_type);
return $this;
}
/**
* Function to determine if the specific UserNotification is disabled for this Entity
*
* @param $notification_type
*
* @return bool
*/
public function isNotificationDisabled($notification_type)
{
if (!$this->disabled_notifications) {
$this->disabled_notifications = [];
return false;
}
return in_array($notification_type, $this->disabled_notifications) ? true : false;
}
/**
* Set defaultSortingInstruction.
*
* @param SortingInstruction|null $defaultSortingInstruction
*
* @return Account
*/
public function setDefaultSortingInstruction(?SortingInstruction $defaultSortingInstruction = null)
{
$this->defaultSortingInstruction = $defaultSortingInstruction;
return $this;
}
/**
* Get defaultSortingInstruction.
*
* @return SortingInstruction|null
*/
public function getDefaultSortingInstruction()
{
return $this->defaultSortingInstruction;
}
/**
* Set requireMemo.
*
* @param bool $requireMemo
*
* @return Account
*/
public function setRequireMemo($requireMemo)
{
$this->requireMemo = $requireMemo;
return $this;
}
/**
* Get requireMemo.
*
* @return bool
*/
public function getRequireMemo()
{
return $this->requireMemo;
}
/**
* Set requirePasswordOnDownload.
*
* @param bool $requirePasswordOnDownload
*
* @return Account
*/
public function setRequirePasswordOnDownload($requirePasswordOnDownload)
{
$this->require_password_on_download = $requirePasswordOnDownload;
return $this;
}
/**
* Get requirePasswordOnDownload.
*
* @return bool
*/
public function getRequirePasswordOnDownload()
{
return $this->require_password_on_download;
}
/**
* Add accountSortingMemoPhrase.
*
* @param AccountSortingMemoPhrase $accountSortingMemoPhrase
*
* @return Account
*/
public function addAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
{
$this->accountSortingMemoPhrases[] = $accountSortingMemoPhrase;
return $this;
}
/**
* Remove accountSortingMemoPhrase.
*
* @param AccountSortingMemoPhrase $accountSortingMemoPhrase
*
* @return bool TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeAccountSortingMemoPhrase(AccountSortingMemoPhrase $accountSortingMemoPhrase)
{
return $this->accountSortingMemoPhrases->removeElement($accountSortingMemoPhrase);
}
/**
* Get accountSortingMemoPhrases.
*
* @return Collection
*/
public function getAccountSortingMemoPhrases()
{
return $this->accountSortingMemoPhrases;
}
/**
* Set matterRequestDefaults.
*
* @param MatterRequestDefaults|null $matterRequestDefaults
*
* @return Account
*/
public function setMatterRequestDefaults(?MatterRequestDefaults $matterRequestDefaults = null)
{
$this->matterRequestDefaults = $matterRequestDefaults;
return $this;
}
/**
* Get matterRequestDefaults.
*
* @return MatterRequestDefaults|null
*/
public function getMatterRequestDefaults()
{
return $this->matterRequestDefaults;
}
/**
* Returns the return details address.
*
* @return ContactableAddress|null
*/
public function getReturnDetailsAddress(): ?ContactableAddress
{
if ($this->getOffices() && $this->getOffices()->first()) {
return $this->getOffices()->first();
}
return null;
}
/**
* Set matterCreationProcess.
*
* @param string|null $matterCreationProcess
*
* @return Account
*/
public function setMatterCreationProcess($matterCreationProcess = null): Account
{
$this->matterCreationProcess = $matterCreationProcess;
return $this;
}
/**
* Set customIndexHeader.
*
* @param string|null $customIndexHeader
*
* @return Account
*/
public function setCustomIndexHeader($customIndexHeader = null)
{
$this->custom_index_header = $customIndexHeader;
return $this;
}
/**
* Get customIndexHeader.
*
* @return string|null
*/
public function getCustomIndexHeader()
{
return $this->custom_index_header;
}
/**
* Get matterCreationProcess.
*
* @return string|null
*/
public function getMatterCreationProcess(): ?string
{
return $this->matterCreationProcess;
}
/**
* Returns true if the client has access to classic matter creation.
*
* @return bool
*/
public function hasAccessToClassicMatterCreation(): bool
{
return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_CLASSIC || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL || $this->matterCreationProcess === null;
}
/**
* Returns true if the client has access to standard matter creation.
*
* @return bool
*/
public function hasAccessToStandardMatterCreation(): bool
{
return $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_STANDARD || $this->matterCreationProcess === self::MATTER_CREATION_PROCESS_ALL;
}
/**
* Returns matter creations options as an array, usable as the choices for a form.
*
* @return array
*/
public static function getMatterCreationProcessOptions(): array
{
$matterCreationProcessOptions = self::getConstantsWithLabelsAsChoices('MATTER_CREATION_PROCESS');
return array_flip($matterCreationProcessOptions);
}
/**
* Returns a human readable version of matterCreationProcess.
*
* @return string
*/
public function getMatterCreationProcessName()
{
$options = self::getMatterCreationProcessOptions();
return $options[$this->getMatterCreationProcess()] ?? $this->getMatterCreationProcess();
}
/**
* Get the value of standardIndexHeader
*
* @return string|null
*/
public function getStandardIndexHeader()
{
return $this->standardIndexHeader;
}
/**
* Set the value of standardIndexHeader
*
* @param string|null $standardIndexHeader
*
* @return self
*/
public function setStandardIndexHeader($standardIndexHeader)
{
$this->standardIndexHeader = $standardIndexHeader;
return $this;
}
/**
* Set canCreateBatchAndSort.
*
* @param bool $canCreateBatchAndSort
*
* @return Account
*/
public function setCanCreateBatchAndSort($canCreateBatchAndSort)
{
$this->canCreateBatchAndSort = $canCreateBatchAndSort;
return $this;
}
/**
* Get canCreateBatchAndSort.
*
* @return bool
*/
public function getCanCreateBatchAndSort()
{
return $this->canCreateBatchAndSort;
}
/**
* Set matchOptIn.
*
* @param bool $matchOptIn
*
* @return Account
*/
public function setMatchOptIn(bool $matchOptIn): self
{
$this->matchOptIn = $matchOptIn;
return $this;
}
/**
* Get matchOptIn.
*
* @return bool
*/
public function getMatchOptIn(): bool
{
return $this->matchOptIn;
}
/**
* getAllowExpertViewUnsortedRecords
*
* @return bool
*/
public function getAllowExpertViewUnsortedRecords(): bool
{
return $this->allowExpertViewUnsortedRecords;
}
/**
* @param bool $allowExpertViewUnsortedRecords
*
* @return self
*/
public function setAllowExpertViewUnsortedRecords(bool $allowExpertViewUnsortedRecords): self
{
$this->allowExpertViewUnsortedRecords = $allowExpertViewUnsortedRecords;
return $this;
}
/**
* @return bool
*/
public function getMatterClosureQuestionsOptional(): bool
{
return $this->matterClosureQuestionsOptional;
}
/**
* @param bool $matterClosureQuestionsOptional
*
* @return Account
*/
public function setMatterClosureQuestionsOptional(bool $matterClosureQuestionsOptional): self
{
$this->matterClosureQuestionsOptional = $matterClosureQuestionsOptional;
return $this;
}
/**
* @return bool|null
*
*/
public function getUseParentClinicalSectionsOnly(): ?bool
{
return $this->useParentClinicalSectionsOnly;
}
/**
* @param bool $useParentClinicalSectionsOnly
*
* @return self
*
*/
public function setUseParentClinicalSectionsOnly(bool $useParentClinicalSectionsOnly): self
{
$this->useParentClinicalSectionsOnly = $useParentClinicalSectionsOnly;
return $this;
}
public function getFirm(): ?Firm
{
return $this->firm;
}
public function setFirm(?Firm $firm): self
{
$this->firm = $firm;
return $this;
}
/**
* @return bool
*/
public function getHideLogoFromIndex(): bool
{
return $this->hideLogoFromIndex;
}
/**
* @param bool $hideLogoFromIndex
*
* @return self
*/
public function setHideLogoFromIndex(bool $hideLogoFromIndex): self
{
$this->hideLogoFromIndex = $hideLogoFromIndex;
return $this;
}
/**
* @return array|null
*
*/
public function getAllowedMatterTypes(): ?array
{
return $this->allowedMatterTypes;
}
/**
* @param array|null $allowedMatterTypes
*
* @return self
*
*/
public function setAllowedMatterTypes(?array $allowedMatterTypes): self
{
$this->allowedMatterTypes = $allowedMatterTypes;
return $this;
}
/**
* @return array
*/
public static function getAllowedMatterTypeOptions(): array
{
return self::getConstantsWithLabelsAsChoices('MATTER_TYPE');
}
/**
* @return Collection<int, LicenceRenewalTerm>
*/
public function getLicenceRenewalTerms(): Collection
{
return $this->licenceRenewalTerms;
}
/**
* @return Collection<int, LicenceRenewalTerm>
*/
public function getZeroPeriodLicenceRenewalTerms(): Collection
{
return $this->licenceRenewalTerms->filter(function ($term) {
return $term->getPeriod() === 0;
});
}
/**
* @param LicenceRenewalTerm $licenceRenewalTerm
*
* @return self
*/
public function addLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
{
if (!$this->licenceRenewalTerms->contains($licenceRenewalTerm)) {
$this->licenceRenewalTerms[] = $licenceRenewalTerm;
$licenceRenewalTerm->setAccount($this);
}
return $this;
}
/**
* @param LicenceRenewalTerm $licenceRenewalTerm
*
* @return self
*/
public function removeLicenceRenewalTerm(LicenceRenewalTerm $licenceRenewalTerm): self
{
if ($this->licenceRenewalTerms->removeElement($licenceRenewalTerm)) {
// set the owning side to null (unless already changed)
if ($licenceRenewalTerm->getAccount() === $this) {
$licenceRenewalTerm->setAccount(null);
}
}
return $this;
}
/**
* @return bool|null
*/
public function isEnforceTwoFactorAuth(): ?bool
{
return $this->enforceTwoFactorAuth;
}
/**
* @param bool $enforceTwoFactorAuth
*
* @return self
*/
public function setEnforceTwoFactorAuth(bool $enforceTwoFactorAuth): self
{
$this->enforceTwoFactorAuth = $enforceTwoFactorAuth;
return $this;
}
/**
* @return bool|null
*/
public function isAllowTwoFactorAuthGracePeriod(): ?bool
{
return $this->allowTwoFactorAuthGracePeriod;
}
/**
* @param bool $allowTwoFactorAuthGracePeriod
*
* @return self
*/
public function setAllowTwoFactorAuthGracePeriod(bool $allowTwoFactorAuthGracePeriod): self
{
$this->allowTwoFactorAuthGracePeriod = $allowTwoFactorAuthGracePeriod;
return $this;
}
/**
* Checks if the client is not liable for the disclosure fee.
*
* @return bool True if the client is not liable, false otherwise.
*/
public function isClientNotLiableForDisclosureFee(): bool
{
return $this->clientNotLiableForDisclosureFee;
}
/**
* Sets whether the client is not liable for the disclosure fee.
*
* @param bool $clientNotLiableForDisclosureFee True if the client is not liable, false otherwise.
*
* @return self
*/
public function setClientNotLiableForDisclosureFee(bool $clientNotLiableForDisclosureFee): self
{
$this->clientNotLiableForDisclosureFee = $clientNotLiableForDisclosureFee;
return $this;
}
/**
* Returns an array of permitted values for the country of registration field and their
* associated labels.
*
* @return array
*/
public static function getCountryOfRegistrationOptions()
{
return [
self::COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES => self::COUNTRY_OF_REGISTRATION_ENGLAND_AND_WALES__LABEL,
self::COUNTRY_OF_REGISTRATION_SCOTLAND => self::COUNTRY_OF_REGISTRATION_SCOTLAND__LABEL,
self::COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND => self::COUNTRY_OF_REGISTRATION_NORTHERN_IRELAND__LABEL,
];
}
/**
* Get trading_name.
*
* @return string|null
*/
public function getTradingName(): ?string
{
return $this->trading_name;
}
/**
* Set trading_name.
*
* @param string|null $trading_name
*
* @return self
*/
public function setTradingName(?string $trading_name): self
{
$this->trading_name = $trading_name;
return $this;
}
/**
* Get company_registration_number.
*
* @return string|null
*/
public function getCompanyRegistrationNumber(): ?string
{
return $this->company_registration_number;
}
/**
* Set company_registration_number.
*
* @param string|null $company_registration_number
*
* @return self
*/
public function setCompanyRegistrationNumber(?string $company_registration_number): self
{
$this->company_registration_number = $company_registration_number;
return $this;
}
/**
* Get country_of_registration.
*
* @return string|null
*/
public function getCountryOfRegistration(): ?string
{
return $this->country_of_registration;
}
/**
* Set country_of_registration.
*
* @param string|null $country_of_registration
*
* @return self
*/
public function setCountryOfRegistration(?string $country_of_registration): self
{
$this->country_of_registration = $country_of_registration;
return $this;
}
/**
* Returns a human-readable version of the country of registration
*
* @return string
*/
public function getCountryOfRegistrationName()
{
$options = self::getCountryOfRegistrationOptions();
return $options[$this->getCountryOfRegistration()] ?? $this->getCountryOfRegistration();
}
}