<?php
namespace Whater\Domain\Whater\Model;
use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Ramsey\Uuid\Uuid;
use Spatie\OpeningHours\OpeningHours;
use Whater\Domain\Common\Exception\InvalidUUIDException;
use Whater\Domain\Product\Model\Product;
use Whater\Domain\User\Exception\IllegalPermissionObjectException;
use Whater\Domain\User\Exception\InvalidPermissionException;
use Whater\Domain\User\Model\OrganizationLicense;
use Whater\Domain\User\Model\UserPermission;
use Whater\Domain\Whater\Exception\InvalidStripeStatusException;
use Whater\Domain\Zones\Model\Country;
use Whater\Domain\Zones\Model\CountryArea;
use Whater\Domain\Zones\Model\Town;
use Whater\Domain\Zones\Model\TownLocation;
use Whater\Domain\Zones\Model\Ubication;
/**
* Class WhaterOrganization
*
* @package Whater\Domain\Whater\Model
*/
class WhaterOrganization implements ContainsRecordedEvents
{
use EventRecorderCapabilities;
const MAN_ACT_REGIONAL_GOVERMENT = "regional_goberment";
const MAN_ACT_LOCAL_GOVERMENT = "local_goberment";
const MAN_ACT_COMUNITY = "comunity";
const MAN_ACT_CONSORTIUM = "consortium";
const MAN_ACT_MIX_MANAGEMENT = "mix_management";
const MAN_ACT_NPO = "npo";
const MAN_ACT_PROVIDER = "provider";
const MAN_ACT_INDUSTRY = "industry";
const MAN_ACT_OTHER = "other";
const REGION_SCOPE_INTERNATIONAL = "international";
const REGION_SCOPE_NATIONAL = "national";
const REGION_SCOPE_REGIONAL = "regional";
const REGION_SCOPE_LOCAL = "local";
const SPECIALIZATION_IN_WATER_VERY_HIGH = "very_high";
const SPECIALIZATION_IN_WATER_HIGH = "high";
const SPECIALIZATION_IN_WATER_MEDIUM = "medium";
const SPECIALIZATION_IN_WATER_LOW = "low";
const NUM_CUSTOMER_LESS_100 = "less_100";
const NUM_CUSTOMER_LESS_500 = "less_500";
const NUM_CUSTOMER_LESS_1000 = "less_1000";
const NUM_CUSTOMER_LESS_5000 = "less_5000";
const NUM_CUSTOMER_LESS_10000 = "less_10000";
const NUM_CUSTOMER_LESS_100000 = "less_100000";
const NUM_CUSTOMER_LESS_1000000 = "less_1000000";
const NUM_CUSTOMER_MORE_1000000 = "more_1000000";
const NUM_DELEGATIONS_LESS_5 = "less_5";
const NUM_DELEGATIONS_LESS_25 = "less_25";
const NUM_DELEGATIONS_LESS_100 = "less_100";
const NUM_DELEGATIONS_LESS_500 = "less_500";
const NUM_DELEGATIONS_MORE_500 = "more_500";
const STRIPE_CONNECT_STATUS_PENDING = "SC_PENDING";
const STRIPE_CONNECT_STATUS_CONNECTED = "SC_CONNECTED";
const STRIPE_CONNECT_STATUS_DISCONNECTED = "SC_DISCONNECTED";
/**
* @var string
*/
private $uuid;
/**
* @var string
*/
private $slug;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $description;
/**
* @var string
*/
private $details;
/**
* @var string
*/
private $urlWeb;
/**
* @var Collection
*/
private $organizationUsers;
/**
* @var Collection
*/
private $referralUsers;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var string
*/
private $publicName;
/**
* @var string
*/
private $contactPerson;
/**
* @var string
*/
private $contactEmail;
/**
* @var string
*/
private $contactPhone;
/**
* @var string
*/
private $fiscalName;
/**
* @var string
*/
private $fiscalAddress;
/**
* @var string
*/
private $marketplacePostalCode;
/**
* @var string
*/
private $marketplaceAddress;
/**
* @var string
*/
private $marketplaceCountry;
/**
* @var string
*/
private $professionalActivity;
/**
* @var string
*/
private $regionScope;
/**
* @var string
*/
private $specializationInWater;
/**
* @var string
*/
private $numberOfDelegations;
/**
* @var string
*/
private $numberOfCustomers;
/**
* @var string
*/
private $facebook = null;
/**
* @var string
*/
private $instagram = null;
/**
* @var string
*/
private $linkedin = null;
/**
* @var bool
*/
private $isPublicOrganization = null;
/**
* @var bool
*/
private $isManufracturer = null;
/**
* @var string
*/
private $organizationType = null;
/**
* @var array
*/
private $openingHours = null;
/**
* @var Country
*/
private $country;
/**
* @var Collection
*/
private $organizationLicenses;
/**
* @var Collection
*/
private $products;
/**
* @var Collection
*/
private $whaterOrganizationCodes;
/**
* @var string
*/
private $urlAnalyticals;
/**
* @var Collection
*/
private $distributionNetworksGovernment;
/**
* @var Collection
*/
private $distributionNetworksOperator;
/**
* @var Collection
*/
private $distributionNetworksCorporative;
/**
* @var Collection
*/
private $distributionNetworksUbication;
/**
* @var Collection
*/
private $whaterPointsCorporative;
/**
* @var Collection
*/
private $whaterPointsUbication;
/**
* @var Collection
*/
private $analyticals;
/**
* @var Collection
*/
private $buyerWalletOperations;
/**
* @var Collection
*/
private $sellerWalletOperations;
/**
* @var float
*/
private $currentBalance;
/**
* @var Collection
*/
private $walletLiquidationRequests;
/**
* @var string
*/
private $bankAccountOwnerName;
/**
* @var string
*/
private $bankAccountIbanNumber;
/**
* @var string
*/
private $bankAccountBicSwiftNumber;
/**
* @var string
*/
private $stripeExpressAccountId;
/**
* @var string
*/
private $stripeExpressAccountStatus;
/**
* @var string
*/
private $referralCode;
/**
* @var Collection
*/
private $ubications;
/**
* @var Collection
*/
private $towns;
/**
* @var Collection
*/
private $townLocations;
/**
* @var Collection
*/
private $whatercoinsCoupons;
/**
* @param string $whaterOrganizationId
* @param string $name
* @param string $details
* @param string $slug
* @param string $urlWeb
*/
public function __construct(
string $whaterOrganizationId = null,
string $name,
Country $country,
string $details = null,
string $slug = null,
string $urlWeb = null
) {
try {
$this->uuid = Uuid::fromString($whaterOrganizationId ?: Uuid::uuid4())->toString();
} catch (\InvalidArgumentException $e) {
throw new InvalidUUIDException();
}
$this->name = $name;
$this->publicName = $name;
$this->country = $country;
$this->slug = $slug;
$this->details = $details;
$this->whaterOrganizationCodes = new ArrayCollection();
$this->organizationUsers = new ArrayCollection();
$this->referralUsers = new ArrayCollection();
$this->organizationLicenses = new ArrayCollection();
$this->referralCode = Uuid::uuid4()->toString();
$this->distributionNetworksGovernment = new ArrayCollection();
$this->distributionNetworksOperator = new ArrayCollection();
$this->distributionNetworksCorporative = new ArrayCollection();
$this->distributionNetworksUbication = new ArrayCollection();
$this->whaterPointsCorporative = new ArrayCollection();
$this->whaterPointsUbication = new ArrayCollection();
$this->whatercoinsCoupons = new ArrayCollection();
$this->analyticals = new ArrayCollection();
$this->products = new ArrayCollection();
$this->buyerWalletOperations = new ArrayCollection();
$this->sellerWalletOperations = new ArrayCollection();
$this->ubications = new ArrayCollection();
$this->towns = new ArrayCollection();
$this->townLocations = new ArrayCollection();
$this->walletLiquidationRequests = new ArrayCollection();
$this->currentBalance = 0;
$this->urlWeb = $urlWeb;
$this->isPublicOrganization = false;
$this->isManufracturer = false;
$this->stripeExpressAccountStatus = WhaterOrganization::STRIPE_CONNECT_STATUS_PENDING;
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
public function updateOrganization(
string $name,
string $details = null,
string $urlWeb = null,
string $slug = null,
string $publicName = null,
string $contactPerson = null,
string $contactEmail = null,
string $contactPhone = null,
bool $isPublicOrganization = null,
bool $isManufracturer = null,
string $fiscalName = null,
string $fiscalAddress = null,
string $professionalActivity = null,
string $regionScope = null,
string $specializationInWater = null,
string $numberOfDelegations = null,
string $numberOfCustomers = null,
string $facebook = null,
string $instagram = null,
string $linkedin = null
) {
$this->name = $name;
$this->slug = $slug;
$this->details = $details;
$this->urlWeb = $urlWeb;
$this->publicName = $publicName;
$this->contactPerson = $contactPerson;
$this->contactEmail = $contactEmail;
$this->contactPhone = $contactPhone;
$this->isPublicOrganization = $isPublicOrganization;
$this->isManufracturer = $isManufracturer;
$this->fiscalName = $fiscalName;
$this->fiscalAddress = $fiscalAddress;
$this->professionalActivity = $professionalActivity;
$this->regionScope = $regionScope;
$this->specializationInWater = $specializationInWater;
$this->numberOfDelegations = $numberOfDelegations;
$this->numberOfCustomers = $numberOfCustomers;
$this->facebook = $facebook;
$this->instagram = $instagram;
$this->linkedin = $linkedin;
$this->updatedAt = new \DateTime();
return $this;
}
public function updateBankAccount(
string $bankAccountOwnerName = null,
string $bankAccountIbanNumber = null,
string $bankAccountBicSwiftNumber = null
) {
$this->bankAccountOwnerName = $bankAccountOwnerName;
$this->bankAccountIbanNumber = $bankAccountIbanNumber;
$this->bankAccountBicSwiftNumber = $bankAccountBicSwiftNumber;
}
public function updateMarketplaceAddress(
string $marketplaceCountry = null,
string $marketplacePostalCode = null,
string $marketplaceAddress = null
) {
$this->marketplaceCountry = $marketplaceCountry;
$this->marketplacePostalCode = $marketplacePostalCode;
$this->marketplaceAddress = $marketplaceAddress;
}
public function updateStripeExpressAccount(
string $stripeExpressAccountId = null,
string $stripeExpressAccountStatus = null
) {
if ($stripeExpressAccountStatus != null) {
$this->stripeExpressAccountId = $stripeExpressAccountId;
switch ($stripeExpressAccountStatus) {
case WhaterOrganization::STRIPE_CONNECT_STATUS_CONNECTED:
case WhaterOrganization::STRIPE_CONNECT_STATUS_PENDING:
case WhaterOrganization::STRIPE_CONNECT_STATUS_DISCONNECTED:
$this->stripeExpressAccountStatus = $stripeExpressAccountStatus;
break;
default:
throw new InvalidStripeStatusException();
}
} else {
$this->stripeExpressAccountId = null;
$this->stripeExpressAccountStatus = null;
}
}
private function updateOpeningHours(OpeningHours $openingHours)
{
$this->openingHours = $openingHours->asStructuredData();
}
private function openingHours(): OpeningHours
{
return OpeningHours::create($this->openingHours);
}
public function activeLicenses()
{
$activeLicences = [];
foreach ($this->organizationLicenses() as $organizationLicense) {
if ($organizationLicense->isActive()) {
array_push($activeLicences, $organizationLicense);
}
}
return $activeLicences;
}
public function hasActiveLicense(string $licenseScope, string $licenseType = null)
{
foreach ($this->activeLicenses() as $activeLicense) {
if ($activeLicense->licenseScope() == $licenseScope) {
if ($licenseType == null) {
return true;
} else {
if ($activeLicense->licenseType() == $licenseType) {
return true;
}
}
}
}
return false;
}
public function checkPermission(string $permissionCode, $object = null)
{
switch ($permissionCode) {
case UserPermission::PERMISSION_CREATE_PRODUCT:
if ($object != null) {
throw new IllegalPermissionObjectException();
}
if ($this->hasActiveLicense(OrganizationLicense::LICENSE_SCOPE_SELLERS)) {
return true;
}
break;
case UserPermission::PERMISSION_EDIT_PRODUCT:
if ($object == null || !($object instanceof Product)) {
throw new IllegalPermissionObjectException();
}
if ($this->hasActiveLicense(OrganizationLicense::LICENSE_SCOPE_SELLERS)) {
return true;
}
break;
case UserPermission::PERMISSION_EDIT_WHATER_POINT:
if ($object == null || !($object instanceof WhaterPoint)) {
throw new IllegalPermissionObjectException();
}
/** @var WhaterPoint $whaterpoint */
$whaterpoint = $object;
if (
$whaterpoint->responsableOrganizationUbication() != null &&
$whaterpoint->responsableOrganizationUbication()->equals($this)
) {
return true;
}
if ($whaterpoint->distributionNetwork() != null) {
$distributionNetwork = $whaterpoint->distributionNetwork();
if (
($distributionNetwork->responsableOrganizationUbication() != null && $distributionNetwork->responsableOrganizationUbication()->equals($this)) ||
($distributionNetwork->responsableOrganizationOperator() != null && $distributionNetwork->responsableOrganizationOperator()->equals($this)) ||
($distributionNetwork->responsableOrganizationCorporative() != null && $distributionNetwork->responsableOrganizationCorporative()->equals($this)) ||
($distributionNetwork->responsableOrganizationGovernment() != null && $distributionNetwork->responsableOrganizationGovernment()->equals($this))
) {
return true;
}
}
break;
case UserPermission::PERMISSION_CREATE_ANALYTICAL:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_ANALYTICAL:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_WHATER_ORGANIZATION:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_CREATE_DISTRIBUTION_NETWORK:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_DISTRIBUTION_NETWORK:
if ($object == null || !($object instanceof DistributionNetwork)) {
throw new IllegalPermissionObjectException();
}
/** @var DistributionNetwork $distributionNetwork */
$distributionNetwork = $object;
// check ownership
if (
($distributionNetwork->responsableOrganizationUbication() != null && $distributionNetwork->responsableOrganizationUbication()->equals($this)) ||
($distributionNetwork->responsableOrganizationOperator() != null && $distributionNetwork->responsableOrganizationOperator()->equals($this)) ||
($distributionNetwork->responsableOrganizationCorporative() != null && $distributionNetwork->responsableOrganizationCorporative()->equals($this)) ||
($distributionNetwork->responsableOrganizationGovernment() != null && $distributionNetwork->responsableOrganizationGovernment()->equals($this))
) {
return true;
}
break;
case UserPermission::PERMISSION_CREATE_WHATER_DEVICE:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_WHATER_DEVICE:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_COUNTRY:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_CREATE_COUNTRY_AREA:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_COUNTRY_AREA:
if ($object == null || !($object instanceof CountryArea)) {
throw new IllegalPermissionObjectException();
}
/** @var CountryArea $countryArea */
$countryArea = $object;
// check ownership (TODO)
// if ($countryArea->whaterOrganization() == null || !$countryArea->whaterOrganization()->equals($this)) {
// return false;
// }
break;
case UserPermission::PERMISSION_CREATE_TOWN:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_TOWN:
if ($object == null || !($object instanceof Town)) {
throw new IllegalPermissionObjectException();
}
/** @var Town $town */
$town = $object;
// check ownership
if ($town->whaterOrganization() != null && $town->whaterOrganization()->equals($this)) {
return true;
}
// check license
foreach ($this->activeLicenses() as $activeLicense) {
if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_COUNTRIES_COUNTRY_AREAS_AGRUPATIONS) {
foreach ($activeLicense->countries() as $country) {
if ($town->country() != null && $town->country()->equals($country)) {
return true;
}
}
foreach ($activeLicense->countryAreas() as $countryArea) {
if ($town->countryArea() != null && $town->countryArea()->equals($countryArea)) {
return true;
}
}
foreach ($activeLicense->agrupations() as $agrupation) {
foreach ($agrupation->town() as $agrupationTown) {
if ($town->equals($agrupationTown)) {
return true;
}
}
}
} else if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_TOWNS) {
foreach ($activeLicense->towns() as $licenseTown) {
if ($town->equals($licenseTown)) {
return true;
}
}
} else if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_PROFESSIONALS) {
foreach ($activeLicense->towns() as $licenseTown) {
if ($town->equals($licenseTown)) {
return true;
}
}
}
}
break;
case UserPermission::PERMISSION_CREATE_UBICATION:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_UBICATION:
if ($object == null || !($object instanceof Ubication)) {
throw new IllegalPermissionObjectException();
}
/** @var Ubication $ubication */
$ubication = $object;
// check ownership
if ($ubication->whaterOrganization() != null && $ubication->whaterOrganization()->equals($this)) {
return true;
}
// check license
foreach ($this->activeLicenses() as $activeLicense) {
if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_COUNTRIES_COUNTRY_AREAS_AGRUPATIONS) {
foreach ($activeLicense->countries() as $country) {
if ($ubication->town()->country() != null && $ubication->town()->country()->equals($country)) {
return true;
}
}
foreach ($activeLicense->countryAreas() as $countryArea) {
if ($ubication->town()->countryArea() != null && $ubication->town()->countryArea()->equals($countryArea)) {
return true;
}
}
foreach ($activeLicense->agrupations() as $agrupation) {
foreach ($agrupation->town() as $agrupationTown) {
if ($ubication->town()->equals($agrupationTown)) {
return true;
}
}
}
} else if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_TOWNS) {
foreach ($activeLicense->towns() as $licenseTown) {
if ($ubication->town()->equals($licenseTown)) {
return true;
}
}
} else if ($activeLicense->licenseScope() == OrganizationLicense::LICENSE_SCOPE_PROFESSIONALS) {
foreach ($activeLicense->towns() as $licenseTown) {
if ($ubication->town()->equals($licenseTown)) {
return true;
}
}
}
}
break;
case UserPermission::PERMISSION_CREATE_TOWN_LOCATION:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_TOWN_LOCATION:
if ($object == null || !($object instanceof TownLocation)) {
throw new IllegalPermissionObjectException();
}
/** @var TownLocation $townLocation */
$townLocation = $object;
if ($townLocation->whaterOrganization() != null && $townLocation->whaterOrganization()->equals($this)) {
return true;
}
break;
case UserPermission::PERMISSION_CREATE_DISTRICT:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_DISTRICT:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_CREATE_ESTABLISHMENT:
throw new \Exception($permissionCode . 'need code implementation!');
break;
case UserPermission::PERMISSION_EDIT_ESTABLISHMENT:
throw new \Exception($permissionCode . 'need code implementation!');
break;
default:
throw new InvalidPermissionException();
}
return false;
}
/**
* @return string
*/
public function id(): string
{
return $this->uuid;
}
/**
* @return string
*/
public function name(): string
{
return $this->name;
}
/**
* @return Country
*/
public function country(): Country
{
return $this->country;
}
/**
* @return string
*/
public function slug(): string
{
return $this->slug;
}
/**
* @return string
*/
public function urlWeb(): ?string
{
return $this->urlWeb;
}
/**
* @return bool
*/
public function isPublicOrganization(): bool
{
return $this->isPublicOrganization;
}
/**
* @return bool
*/
public function isManufracturer(): bool
{
return $this->isManufracturer;
}
/**
* @return Collection
*/
public function organizationUsers(): Collection
{
return $this->organizationUsers;
}
/**
* @return Collection
*/
public function referralUsers(): Collection
{
return $this->referralUsers;
}
/**
* @return Collection
*/
public function organizationLicenses(): Collection
{
return $this->organizationLicenses;
}
/**
* @return Collection
*/
public function distributionNetworksGovernment(): Collection
{
return $this->distributionNetworksGovernment;
}
/**
* @return Collection
*/
public function distributionNetworksOperator(): Collection
{
return $this->distributionNetworksOperator;
}
/**
* @return Collection
*/
public function distributionNetworksCorporative(): Collection
{
return $this->distributionNetworksCorporative;
}
/**
* @return Collection
*/
public function distributionNetworksUbication(): Collection
{
return $this->distributionNetworksUbication;
}
/**
* @return Collection
*/
public function whaterPointsCorporative(): Collection
{
return $this->whaterPointsCorporative;
}
/**
* @return Collection
*/
public function whaterPointsUbication(): Collection
{
return $this->whaterPointsUbication;
}
/**
* @return Collection
*/
public function whatercoinsCoupons(): Collection
{
return $this->whatercoinsCoupons;
}
/**
* @return Collection
*/
public function analyticals(): Collection
{
return $this->analyticals;
}
/**
* @return Collection
*/
public function products(): Collection
{
return $this->products;
}
/**
* Saldo disponible (ingresos por ventas - comisiones por ventas - pagos a cc )
* @return float
*/
public function currentBalance(): float
{
return $this->currentBalance;
}
/**
* @return float
* @return bool
*/
public function updateWallet()
{
$balance = 0;
foreach ($this->sellerWalletOperations() as $sellerWalletOperation) {
if ($sellerWalletOperation->checkWalletOperationChecksum()) {
$balance = $balance + $sellerWalletOperation->sellerWhaterOrganizationCoins();
}
}
foreach ($this->buyerWalletOperations() as $buyerWalletOperation) {
if ($buyerWalletOperation->checkWalletOperationChecksum()) {
$balance = $balance + $buyerWalletOperation->buyerWhaterOrganizationCoins();
}
}
$this->currentBalance = $balance;
}
/**
* @return string
*/
public function details(): ?string
{
return $this->details;
}
/**
* @return string
*/
public function publicName()
{
return $this->publicName;
}
/**
* @return string
*/
public function contactPerson()
{
return $this->contactPerson;
}
/**
* @return string
*/
public function contactEmail()
{
return $this->contactEmail;
}
/**
* @return string
*/
public function facebook()
{
return $this->facebook;
}
/**
* @return string
*/
public function instagram()
{
return $this->instagram;
}
/**
* @return string
*/
public function linkedin()
{
return $this->linkedin;
}
/**
* @return string
*/
public function contactPhone()
{
return $this->contactPhone;
}
/**
* @return string
*/
public function marketplaceCountry()
{
return $this->marketplaceCountry;
}
/**
* @return string
*/
public function marketplacePostalCode()
{
return $this->marketplacePostalCode;
}
/**
* @return string
*/
public function marketplaceAddress()
{
return $this->marketplaceAddress;
}
/**
* @return string
*/
public function fiscalName()
{
return $this->fiscalName;
}
/**
* @return string
*/
public function fiscalAddress()
{
return $this->fiscalAddress;
}
/**
* @return string
*/
public function professionalActivity()
{
return $this->professionalActivity;
}
/**
* @return string
*/
public function specializationInWater()
{
return $this->specializationInWater;
}
/**
* @return string
*/
public function regionScope()
{
return $this->regionScope;
}
/**
* @return string
*/
public function numberOfDelegations()
{
return $this->numberOfDelegations;
}
/**
* @return string
*/
public function numberOfCustomers()
{
return $this->numberOfCustomers;
}
/**
* @return string
*/
public function bankAccountOwnerName()
{
return $this->bankAccountOwnerName;
}
/**
* @return string
*/
public function bankAccountIbanNumber()
{
return $this->bankAccountIbanNumber;
}
/**
* @return string
*/
public function bankAccountBicSwiftNumber()
{
return $this->bankAccountBicSwiftNumber;
}
/**
* @return string
*/
public function stripeExpressAccountId()
{
return $this->stripeExpressAccountId;
}
/**
* @return string
*/
public function stripeExpressAccountStatus()
{
return $this->stripeExpressAccountStatus;
}
/**
* @return string
*/
public function referralCode(): ?string
{
return $this->referralCode;
}
/**
* @return \DateTime
*/
public function createdAt(): \DateTime
{
return $this->createdAt;
}
/**
* @return \DateTime
*/
public function updatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @return Collection
*/
public function whaterOrganizationCodes(): Collection
{
return $this->whaterOrganizationCodes;
}
public function hasOrganizationCode(string $code, string $externalSystem)
{
foreach ($this->whaterOrganizationCodes() as $whaterOrganizationCode) {
if (
$whaterOrganizationCode->externalSystem() == $externalSystem &&
$whaterOrganizationCode->code() == $code
) {
return true;
}
}
return false;
}
public function hasOrganizationCodeForExternalSystem(string $externalSystem)
{
foreach ($this->whaterOrganizationCodes() as $whaterOrganizationCode) {
if (
$whaterOrganizationCode->externalSystem() == $externalSystem
) {
return true;
}
}
return false;
}
/**
* @return bool
*/
public function isMarketable(): bool
{
if ($this->stripeExpressAccountStatus() != WhaterOrganization::STRIPE_CONNECT_STATUS_CONNECTED) {
return false;
}
if (!$this->hasActiveLicense(OrganizationLicense::LICENSE_SCOPE_SELLERS)) {
return false;
}
return true;
}
/**
* @return Collection
*/
public function buyerWalletOperations(): Collection
{
return $this->buyerWalletOperations;
}
/**
* @return Collection
*/
public function sellerWalletOperations(): Collection
{
return $this->sellerWalletOperations;
}
/**
* @return Collection
*/
public function walletLiquidationRequests(): Collection
{
return $this->walletLiquidationRequests;
}
/**
* @return bool
*/
public function equals(WhaterOrganization $whaterOrganization)
{
return $this->id() === $whaterOrganization->id();
}
public function __tostring()
{
return $this->publicName;
}
/**
* @return Collection
*/
public function ubications(): Collection
{
return $this->ubications;
}
/**
* @return Collection
*/
public function towns(): Collection
{
return $this->towns;
}
/**
* @return Collection
*/
public function townLocations(): Collection
{
return $this->townLocations;
}
}