Vincent GUFFON 4 лет назад
Родитель
Сommit
9b5b874d4e

+ 202 - 0
src/Entity/Core/AddressPostal.php

@@ -0,0 +1,202 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Entity\Core;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Entity\Organization\OrganizationAddressPostal;
+use App\Repository\Core\AddressPostalRepository;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass=AddressPostalRepository::class)
+ */
+class AddressPostal
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=Country::class)
+     */
+    private $addressCountry;
+
+    /**
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    private $addressCity;
+
+    /**
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    private $addressOwner;
+
+    /**
+     * @ORM\Column(type="string", length=20, nullable=true)
+     */
+    private $postalCode;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $streetAddress;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $streetAddressSecond;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $streetAddressThird;
+
+    /**
+     * @ORM\Column(type="float", nullable=true)
+     */
+    private $latitude;
+
+    /**
+     * @ORM\Column(type="float", nullable=true)
+     */
+    private $longitude;
+
+    /**
+     * @ORM\OneToOne(targetEntity=OrganizationAddressPostal::class, mappedBy="addressPostal", cascade={"persist", "remove"})
+     */
+    private $organizationAddressPostal;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getAddressCountry(): ?Country
+    {
+        return $this->addressCountry;
+    }
+
+    public function setAddressCountry(?Country $addressCountry): self
+    {
+        $this->addressCountry = $addressCountry;
+
+        return $this;
+    }
+
+    public function getAddressCity(): ?string
+    {
+        return $this->addressCity;
+    }
+
+    public function setAddressCity(?string $addressCity): self
+    {
+        $this->addressCity = $addressCity;
+
+        return $this;
+    }
+
+    public function getAddressOwner(): ?string
+    {
+        return $this->addressOwner;
+    }
+
+    public function setAddressOwner(?string $addressOwner): self
+    {
+        $this->addressOwner = $addressOwner;
+
+        return $this;
+    }
+
+    public function getPostalCode(): ?string
+    {
+        return $this->postalCode;
+    }
+
+    public function setPostalCode(?string $postalCode): self
+    {
+        $this->postalCode = $postalCode;
+
+        return $this;
+    }
+
+    public function getStreetAddress(): ?string
+    {
+        return $this->streetAddress;
+    }
+
+    public function setStreetAddress(?string $streetAddress): self
+    {
+        $this->streetAddress = $streetAddress;
+
+        return $this;
+    }
+
+    public function getStreetAddressSecond(): ?string
+    {
+        return $this->streetAddressSecond;
+    }
+
+    public function setStreetAddressSecond(?string $streetAddressSecond): self
+    {
+        $this->streetAddressSecond = $streetAddressSecond;
+
+        return $this;
+    }
+
+    public function getStreetAddressThird(): ?string
+    {
+        return $this->streetAddressThird;
+    }
+
+    public function setStreetAddressThird(?string $streetAddressThird): self
+    {
+        $this->streetAddressThird = $streetAddressThird;
+
+        return $this;
+    }
+
+    public function getLatitude(): ?float
+    {
+        return $this->latitude;
+    }
+
+    public function setLatitude(?float $latitude): self
+    {
+        $this->latitude = $latitude;
+
+        return $this;
+    }
+
+    public function getLongitude(): ?float
+    {
+        return $this->longitude;
+    }
+
+    public function setLongitude(?float $longitude): self
+    {
+        $this->longitude = $longitude;
+
+        return $this;
+    }
+
+    public function getOrganizationAddressPostal(): ?OrganizationAddressPostal
+    {
+        return $this->organizationAddressPostal;
+    }
+
+    public function setOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
+    {
+        // set the owning side of the relation if necessary
+        if ($organizationAddressPostal->getAddressPostal() !== $this) {
+            $organizationAddressPostal->setAddressPostal($this);
+        }
+
+        $this->organizationAddressPostal = $organizationAddressPostal;
+
+        return $this;
+    }
+}

+ 285 - 0
src/Entity/Core/BankAccount.php

@@ -0,0 +1,285 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Entity\Core;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Entity\Organization\Organization;
+use App\Repository\Core\BankAccountRepository;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * Données bancaire d'une Person ou d'une Organization
+ *
+ * @ApiResource(
+ *     itemOperations={
+ *           "get"={"security"="is_granted('BANK_ACCOUNT_READ', object)"},
+ *           "put"={"security"="is_granted('BANK_ACCOUNT_EDIT', object)"},
+ *     }
+ * )
+ * @ORM\Entity(repositoryClass=BankAccountRepository::class)
+ */
+class BankAccount
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $bankName;
+
+    /**
+     * @ORM\Column(type="string", length=11, nullable=true)
+     * @Assert\Bic(
+     *    message="invalid_bic"
+     * )
+     */
+    private $bic;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $bicInvalid;
+
+    /**
+     * @ORM\Column(type="string", length=34, nullable=true)
+     * @Assert\Iban(
+     *    message="invalid_iban"
+     * )
+     */
+    private $iban;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $ibanInvalid;
+
+    /**
+     * @ORM\Column(type="boolean", options={"default" : false})
+     */
+    private $holderIdDifferent = false;
+
+    /**
+     * 0 => jamais facturé, 1 => facturé 1 fois, 2 => facturé plusieurs fois
+     * @ORM\Column(type="integer", options={"default" : 0})
+     */
+    private $countInvoiced;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $holder;
+
+    /**
+     * @ORM\Column(type="boolean", options={"default" : false})
+     * @Assert\NotNull
+     */
+    private $principal = false;
+
+    /**
+     * @ORM\Column(type="text", nullable=true)
+     */
+    private $debitAddress;
+
+    /**
+     * @ORM\Column(type="string", length=35, nullable=true, unique=true)
+     */
+    private $rum;
+
+    /**
+     * @ORM\Column(type="date", nullable=true)
+     */
+    private $signatureDateSamplingMandate;
+
+    /**
+     * @ORM\ManyToMany(targetEntity=Organization::class, inversedBy="bankAccounts")
+     * @ORM\JoinTable(name="organization_bankaccount")
+     */
+    private $organization;
+
+    public function __construct()
+    {
+        $this->organization = new ArrayCollection();
+    }
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getBankName(): ?string
+    {
+        return $this->bankName;
+    }
+
+    public function setBankName(?string $bankName): self
+    {
+        $this->bankName = $bankName;
+
+        return $this;
+    }
+
+    public function getBic(): ?string
+    {
+        return $this->bic;
+    }
+
+    public function setBic(?string $bic): self
+    {
+        $this->bic = $bic;
+
+        return $this;
+    }
+
+    public function getBicInvalid(): ?string
+    {
+        return $this->bicInvalid;
+    }
+
+    public function setBicInvalid(?string $bicInvalid): self
+    {
+        $this->bicInvalid = $bicInvalid;
+
+        return $this;
+    }
+
+    public function getIban(): ?string
+    {
+        return $this->iban;
+    }
+
+    public function setIban(?string $iban): self
+    {
+        $this->iban = $iban;
+
+        return $this;
+    }
+
+    public function getIbanInvalid(): ?string
+    {
+        return $this->ibanInvalid;
+    }
+
+    public function setIbanInvalid(?string $ibanInvalid): self
+    {
+        $this->ibanInvalid = $ibanInvalid;
+
+        return $this;
+    }
+
+    public function getHolderIdDifferent(): ?bool
+    {
+        return $this->holderIdDifferent;
+    }
+
+    public function setHolderIdDifferent(bool $holderIdDifferent): self
+    {
+        $this->holderIdDifferent = $holderIdDifferent;
+
+        return $this;
+    }
+
+    public function getCountInvoiced(): ?int
+    {
+        return $this->countInvoiced;
+    }
+
+    public function setCountInvoiced(int $countInvoiced): self
+    {
+        $this->countInvoiced = $countInvoiced;
+
+        return $this;
+    }
+
+    public function getHolder(): ?string
+    {
+        return $this->holder;
+    }
+
+    public function setHolder(?string $holder): self
+    {
+        $this->holder = $holder;
+
+        return $this;
+    }
+
+    public function getPrincipal(): ?bool
+    {
+        return $this->principal;
+    }
+
+    public function setPrincipal(bool $principal): self
+    {
+        $this->principal = $principal;
+
+        return $this;
+    }
+
+    public function getDebitAddress(): ?string
+    {
+        return $this->debitAddress;
+    }
+
+    public function setDebitAddress(?string $debitAddress): self
+    {
+        $this->debitAddress = $debitAddress;
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|Organization[]
+     */
+    public function getOrganization(): Collection
+    {
+        return $this->organization;
+    }
+
+    public function addOrganization(Organization $organization): self
+    {
+        if (!$this->organization->contains($organization)) {
+            $this->organization[] = $organization;
+        }
+
+        return $this;
+    }
+
+    public function removeOrganization(Organization $organization): self
+    {
+        $this->organization->removeElement($organization);
+
+        return $this;
+    }
+
+    public function getRum(): ?string
+    {
+        return $this->rum;
+    }
+
+    public function setRum(?string $rum): self
+    {
+        $this->rum = $rum;
+
+        return $this;
+    }
+
+    public function getSignatureDateSamplingMandate(): ?\DateTimeInterface
+    {
+        return $this->signatureDateSamplingMandate;
+    }
+
+    public function setSignatureDateSamplingMandate(?\DateTimeInterface $signatureDateSamplingMandate): self
+    {
+        $this->signatureDateSamplingMandate = $signatureDateSamplingMandate;
+
+        return $this;
+    }
+}

+ 273 - 0
src/Entity/Core/ContactPoint.php

@@ -0,0 +1,273 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Entity\Core;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Entity\Organization\Organization;
+use App\Entity\Person\Person;
+use libphonenumber\PhoneNumber;
+use App\Repository\Core\ContactPointRepository;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * Données de contact d'une Person ou d'une Organization ou d'un lieu
+ * @ApiResource(
+ *     itemOperations={
+ *           "get"={"security"="is_granted('CONTACT_POINT_READ', object)"},
+ *           "put"={"security"="is_granted('CONTACT_POINT_EDIT', object)"},
+ *     }
+ * )
+ * @ORM\Entity(repositoryClass=ContactPointRepository::class)
+ */
+class ContactPoint
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="string", length=255)
+     * @Assert\Choice(callback={"\App\Enum\Core\ContactPointTypeEnum", "toArray"}, message="invalid-choice")
+     */
+    private $contactType;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     * @Assert\Email(mode="strict", message="invalid-email-format")
+     * @Assert\Regex(pattern="/^[a-zA-Z0-9._%-]{1,64}@[a-zA-Z0-9.-]{2,249}\.[a-zA-Z]{2,6}$/", message="email-error")
+     */
+    private $email;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $emailInvalid;
+
+    /**
+     * @ORM\Column(type="phone_number", nullable=true)
+     */
+    private $faxNumber;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $faxNumberInvalid;
+
+    /**
+     * @ORM\Column(type="phone_number", nullable=true)
+     */
+    private $telphone;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $telphoneInvalid;
+
+    /**
+     * @ORM\Column(type="phone_number", nullable=true)
+     */
+    private $mobilPhone;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $mobilPhoneInvalid;
+
+    /**
+     * @ORM\ManyToMany(targetEntity=Organization::class, inversedBy="contactPoints")
+     * @ORM\JoinTable(name="organization_contactpoint")
+     */
+    private $organization;
+
+    /**
+     * @ORM\ManyToMany(targetEntity=Person::class, inversedBy="contactPoints")
+     * @ORM\JoinTable(name="person_contactpoint")
+     */
+    private $person;
+
+    public function __construct()
+    {
+        $this->organization = new ArrayCollection();
+        $this->person = new ArrayCollection();
+    }
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getContactType(): ?string
+    {
+        return $this->contactType;
+    }
+
+    public function setContactType(string $contactType): self
+    {
+        $this->contactType = $contactType;
+
+        return $this;
+    }
+
+    public function getEmail(): ?string
+    {
+        return $this->email;
+    }
+
+    public function setEmail(?string $email): self
+    {
+        $this->email = $email;
+
+        if(!is_null($this->email && !is_null($this->getEmailInvalid())))
+            $this->setEmailInvalid(null);
+
+        return $this;
+    }
+
+    public function getEmailInvalid(): ?string
+    {
+        return $this->emailInvalid;
+    }
+
+    public function setEmailInvalid(?string $emailInvalid): self
+    {
+        $this->emailInvalid = $emailInvalid;
+
+        return $this;
+    }
+
+    public function getFaxNumber(): ?PhoneNumber
+    {
+        return $this->faxNumber;
+    }
+
+    public function setFaxNumber(?PhoneNumber $faxNumber): self
+    {
+        $this->faxNumber = $faxNumber;
+
+        if(!is_null($this->faxNumber && !is_null($this->getFaxNumberInvalid())))
+            $this->setFaxNumberInvalid(null);
+
+        return $this;
+    }
+
+    public function getFaxNumberInvalid(): ?string
+    {
+        return $this->faxNumberInvalid;
+    }
+
+    public function setFaxNumberInvalid(?string $faxNumberInvalid): self
+    {
+        $this->faxNumberInvalid = $faxNumberInvalid;
+
+        return $this;
+    }
+
+    public function getTelphone(): ?PhoneNumber
+    {
+        return $this->telphone;
+    }
+
+    public function setTelphone(?PhoneNumber $telphone): self
+    {
+        $this->telphone = $telphone;
+
+        if(!is_null($this->telphone && !is_null($this->getTelphoneInvalid())))
+            $this->setTelphoneInvalid(null);
+
+        return $this;
+    }
+
+    public function getTelphoneInvalid(): ?string
+    {
+        return $this->telphoneInvalid;
+    }
+
+    public function setTelphoneInvalid(?string $telphoneInvalid): self
+    {
+        $this->telphoneInvalid = $telphoneInvalid;
+
+        return $this;
+    }
+
+    public function getMobilPhone(): ?PhoneNumber
+    {
+        return $this->mobilPhone;
+    }
+
+    public function setMobilPhone(?PhoneNumber $mobilPhone): self
+    {
+        $this->mobilPhone = $mobilPhone;
+
+        if(!is_null($this->mobilPhone && !is_null($this->getMobilPhoneInvalid())))
+            $this->setMobilPhoneInvalid(null);
+
+        return $this;
+    }
+
+    public function getMobilPhoneInvalid(): ?string
+    {
+        return $this->mobilPhoneInvalid;
+    }
+
+    public function setMobilPhoneInvalid(?string $mobilPhoneInvalid): self
+    {
+        $this->mobilPhoneInvalid = $mobilPhoneInvalid;
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|Organization[]
+     */
+    public function getOrganization(): Collection
+    {
+        return $this->organization;
+    }
+
+    public function addOrganization(Organization $organization): self
+    {
+        if (!$this->organization->contains($organization)) {
+            $this->organization[] = $organization;
+        }
+
+        return $this;
+    }
+
+    public function removeOrganization(Organization $organization): self
+    {
+        $this->organization->removeElement($organization);
+
+        return $this;
+    }
+
+    /**
+     * @return Collection|Person[]
+     */
+    public function getPerson(): Collection
+    {
+        return $this->person;
+    }
+
+    public function addPerson(Person $person): self
+    {
+        if (!$this->person->contains($person)) {
+            $this->person[] = $person;
+        }
+
+        return $this;
+    }
+
+    public function removePerson(Person $person): self
+    {
+        $this->person->removeElement($person);
+
+        return $this;
+    }
+}

+ 41 - 0
src/Entity/Core/Country.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Entity\Core;
+
+use App\Repository\Core\CountryRepository;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass=CountryRepository::class)
+ */
+class Country
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="string", length=255)
+     */
+    private $name;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getName(): ?string
+    {
+        return $this->name;
+    }
+
+    public function setName(string $name): self
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+}

+ 83 - 0
src/Entity/Organization/OrganizationAddressPostal.php

@@ -0,0 +1,83 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Entity\Organization;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Entity\Core\AddressPostal;
+use App\Repository\Organization\OrganizationAddressPostalRepository;
+use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * @ApiResource()
+ * @ORM\Entity(repositoryClass=OrganizationAddressPostalRepository::class)
+ */
+class OrganizationAddressPostal
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=Organization::class, inversedBy="organizationAddressPostals")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $organization;
+
+    /**
+     * @ORM\OneToOne(targetEntity=AddressPostal::class, inversedBy="organizationAddressPostal", cascade={"persist", "remove"})
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $addressPostal;
+
+    /**
+     * @ORM\Column(type="string", length=255)
+     * @Assert\Choice(callback={"AppBundle\Enum\Core\AddressPostalTypeEnum", "toArray"})
+     */
+    private $type;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getOrganization(): ?Organization
+    {
+        return $this->organization;
+    }
+
+    public function setOrganization(?Organization $organization): self
+    {
+        $this->organization = $organization;
+
+        return $this;
+    }
+
+    public function getAddressPostal(): ?AddressPostal
+    {
+        return $this->addressPostal;
+    }
+
+    public function setAddressPostal(AddressPostal $addressPostal): self
+    {
+        $this->addressPostal = $addressPostal;
+
+        return $this;
+    }
+
+    public function getType(): ?string
+    {
+        return $this->type;
+    }
+
+    public function setType(string $type): self
+    {
+        $this->type = $type;
+
+        return $this;
+    }
+}

+ 114 - 0
src/Entity/Organization/OrganizationLicence.php

@@ -0,0 +1,114 @@
+<?php
+
+namespace App\Entity\Organization;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Entity\Access\Access;
+use App\Repository\Organization\OrganizationLicenceRepository;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ApiResource()
+ * @ORM\Entity(repositoryClass=OrganizationLicenceRepository::class)
+ */
+class OrganizationLicence
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=Organization::class, inversedBy="organizationLicences")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $organization;
+
+    /**
+     * @ORM\ManyToOne(targetEntity=Access::class, inversedBy="organizationLicences")
+     * @ORM\JoinColumn(nullable=false)
+     */
+    private $licensee;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $licenceNumber;
+
+    /**
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $categorie;
+
+    /**
+     * @ORM\Column(type="date", nullable=true)
+     */
+    private $validityDate;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function getOrganization(): ?Organization
+    {
+        return $this->organization;
+    }
+
+    public function setOrganization(?Organization $organization): self
+    {
+        $this->organization = $organization;
+
+        return $this;
+    }
+
+    public function getLicensee(): ?Access
+    {
+        return $this->licensee;
+    }
+
+    public function setLicensee(?Access $licensee): self
+    {
+        $this->licensee = $licensee;
+
+        return $this;
+    }
+
+    public function getLicenceNumber(): ?string
+    {
+        return $this->licenceNumber;
+    }
+
+    public function setLicenceNumber(?string $licenceNumber): self
+    {
+        $this->licenceNumber = $licenceNumber;
+
+        return $this;
+    }
+
+    public function getCategorie(): ?string
+    {
+        return $this->categorie;
+    }
+
+    public function setCategorie(?string $categorie): self
+    {
+        $this->categorie = $categorie;
+
+        return $this;
+    }
+
+    public function getValidityDate(): ?\DateTimeInterface
+    {
+        return $this->validityDate;
+    }
+
+    public function setValidityDate(?\DateTimeInterface $validityDate): self
+    {
+        $this->validityDate = $validityDate;
+
+        return $this;
+    }
+}

+ 50 - 0
src/Repository/Core/AddressPostalRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Core;
+
+use App\Entity\Core\AddressPostal;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method AddressPostal|null find($id, $lockMode = null, $lockVersion = null)
+ * @method AddressPostal|null findOneBy(array $criteria, array $orderBy = null)
+ * @method AddressPostal[]    findAll()
+ * @method AddressPostal[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class AddressPostalRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, AddressPostal::class);
+    }
+
+    // /**
+    //  * @return AddressPostal[] Returns an array of AddressPostal objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('a')
+            ->andWhere('a.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('a.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?AddressPostal
+    {
+        return $this->createQueryBuilder('a')
+            ->andWhere('a.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/Core/BankAccountRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Core;
+
+use App\Entity\Core\BankAccount;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method BankAccount|null find($id, $lockMode = null, $lockVersion = null)
+ * @method BankAccount|null findOneBy(array $criteria, array $orderBy = null)
+ * @method BankAccount[]    findAll()
+ * @method BankAccount[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class BankAccountRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, BankAccount::class);
+    }
+
+    // /**
+    //  * @return BankAccount[] Returns an array of BankAccount objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('b')
+            ->andWhere('b.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('b.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?BankAccount
+    {
+        return $this->createQueryBuilder('b')
+            ->andWhere('b.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/Core/ContactPointRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Core;
+
+use App\Entity\Core\ContactPoint;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method ContactPoint|null find($id, $lockMode = null, $lockVersion = null)
+ * @method ContactPoint|null findOneBy(array $criteria, array $orderBy = null)
+ * @method ContactPoint[]    findAll()
+ * @method ContactPoint[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class ContactPointRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, ContactPoint::class);
+    }
+
+    // /**
+    //  * @return ContactPoint[] Returns an array of ContactPoint objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('c')
+            ->andWhere('c.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('c.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?ContactPoint
+    {
+        return $this->createQueryBuilder('c')
+            ->andWhere('c.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/Core/CountryRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Core;
+
+use App\Entity\Core\Country;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method Country|null find($id, $lockMode = null, $lockVersion = null)
+ * @method Country|null findOneBy(array $criteria, array $orderBy = null)
+ * @method Country[]    findAll()
+ * @method Country[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class CountryRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, Country::class);
+    }
+
+    // /**
+    //  * @return Country[] Returns an array of Country objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('c')
+            ->andWhere('c.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('c.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?Country
+    {
+        return $this->createQueryBuilder('c')
+            ->andWhere('c.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/Organization/OrganizationAddressPostalRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Organization;
+
+use App\Entity\Organization\OrganizationAddressPostal;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method OrganizationAddressPostal|null find($id, $lockMode = null, $lockVersion = null)
+ * @method OrganizationAddressPostal|null findOneBy(array $criteria, array $orderBy = null)
+ * @method OrganizationAddressPostal[]    findAll()
+ * @method OrganizationAddressPostal[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class OrganizationAddressPostalRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, OrganizationAddressPostal::class);
+    }
+
+    // /**
+    //  * @return OrganizationAddressPostal[] Returns an array of OrganizationAddressPostal objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('o')
+            ->andWhere('o.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('o.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?OrganizationAddressPostal
+    {
+        return $this->createQueryBuilder('o')
+            ->andWhere('o.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 50 - 0
src/Repository/Organization/OrganizationLicenceRepository.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Repository\Organization;
+
+use App\Entity\Organization\OrganizationLicence;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+/**
+ * @method OrganizationLicence|null find($id, $lockMode = null, $lockVersion = null)
+ * @method OrganizationLicence|null findOneBy(array $criteria, array $orderBy = null)
+ * @method OrganizationLicence[]    findAll()
+ * @method OrganizationLicence[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class OrganizationLicenceRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, OrganizationLicence::class);
+    }
+
+    // /**
+    //  * @return OrganizationLicence[] Returns an array of OrganizationLicence objects
+    //  */
+    /*
+    public function findByExampleField($value)
+    {
+        return $this->createQueryBuilder('o')
+            ->andWhere('o.exampleField = :val')
+            ->setParameter('val', $value)
+            ->orderBy('o.id', 'ASC')
+            ->setMaxResults(10)
+            ->getQuery()
+            ->getResult()
+        ;
+    }
+    */
+
+    /*
+    public function findOneBySomeField($value): ?OrganizationLicence
+    {
+        return $this->createQueryBuilder('o')
+            ->andWhere('o.exampleField = :val')
+            ->setParameter('val', $value)
+            ->getQuery()
+            ->getOneOrNullResult()
+        ;
+    }
+    */
+}

+ 62 - 0
src/Security/Voter/ContactPointVoter.php

@@ -0,0 +1,62 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Security\Voter;
+
+use App\Entity\Access\Access;
+use App\Entity\Core\ContactPoint;
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Core\Authorization\Voter\Voter;
+use Symfony\Component\Security\Core\Security;
+use Symfony\Component\Security\Core\User\UserInterface;
+
+class ContactPointVoter extends Voter
+{
+    private Security $security;
+
+    public function __construct(Security $security)
+    {
+        $this->security = $security;
+    }
+
+    protected function supports($attribute, $subject): bool
+    {
+        return in_array($attribute, ['CONTACT_POINT_READ', 'CONTACT_POINT_EDIT'])
+            && $subject instanceof ContactPoint;
+    }
+
+    /**
+     * @param string $attribute
+     * @param mixed $subject
+     * @param TokenInterface $token
+     * @return bool
+     */
+    protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
+    {
+        /** @var Access $user */
+        $user = $token->getUser();
+        // if the user is anonymous, do not grant access
+        if (!$user instanceof UserInterface) {
+            return false;
+        }
+
+        switch ($attribute) {
+            case 'CONTACT_POINT_READ':
+                if($subject->getOrganization()->count() === 1){
+                    return $this->security->isGranted('ROLE_ORGANIZATION_VIEW')
+                        && $subject->getOrganization()->current()->getId() === $user->getOrganization()->getId();
+                }
+                break;
+            case 'CONTACT_POINT_EDIT':
+                if($subject->getOrganization()->count() === 1){
+                    return $this->security->isGranted('ROLE_ORGANIZATION')
+                        && $subject->getOrganization()->current()->getId() === $user->getOrganization()->getId();
+                }
+                break;
+        }
+
+        return false;
+    }
+
+
+}