From 21bfd01d8eaacc6c23113e46946cedcb0dc43a58 Mon Sep 17 00:00:00 2001
From: lecluse <lecluse@d57fa8bc-6af1-4de9-8b7d-78e900e231e7>
Date: Fri, 16 Oct 2015 14:59:41 +0000
Subject: [PATCH] Disciplines + Refactoring + bugs

---
 .../Assertion/ServiceAssertion.php            |  1 -
 .../Controller/DossierController.php          |  7 +-
 .../Controller/PieceJointeController.php      |  6 +-
 .../ServiceReferentielController.php          |  1 -
 .../Controller/ValidationController.php       |  2 +-
 .../src/Application/Entity/Db/Contrat.php     |  8 +-
 .../src/Application/Entity/Db/Dossier.php     |  4 +-
 .../Application/Entity/Db/TypeIntervenant.php | 16 +--
 .../Entity/Db/TypeIntervenantExterieur.php    | 97 -------------------
 .../Application/Form/Intervenant/Dossier.php  |  2 +-
 .../Form/Intervenant/DossierHydrator.php      |  8 +-
 .../Form/Service/SaisieFieldset.php           |  4 +-
 .../PeutCreerContratInitialRule.php           |  3 +-
 .../Rule/Intervenant/PossedeContratRule.php   |  6 +-
 .../Rule/Intervenant/PossedeDossierRule.php   |  7 +-
 .../src/Application/Service/Context.php       | 13 ++-
 ...AgrementCAMaisPasContratIndicateurImpl.php |  4 +-
 .../Contrat/AttenteAvenantIndicateurImpl.php  |  4 +-
 .../Contrat/AttenteContratIndicateurImpl.php  |  4 +-
 .../AttenteRetourContratIndicateurImpl.php    |  4 +-
 .../ContratAvenantDeposesIndicateurImpl.php   |  6 +-
 ...rviceApresContratAvenantIndicateurImpl.php |  6 +-
 ...teValidationDonneesPersoIndicateurImpl.php |  6 +-
 .../DonneesPersoDiffImportIndicateurImpl.php  |  6 +-
 .../src/Application/Service/PieceJointe.php   |  3 +-
 .../Service/Process/ContratProcess.php        |  5 +-
 .../Service/Process/PieceJointeProcess.php    | 10 +-
 .../Application/Service/ServiceService.php    |  4 +-
 .../Workflow/Step/EditionContratStep.php      |  2 -
 .../src/Application/View/Helper/AppLink.php   |  3 +-
 .../Intervenant/IntervenantViewHelper.php     |  2 +-
 .../view/application/index/index.phtml        |  2 +-
 .../src/Common/ORM/Filter/AnneeFilter.php     |  6 +-
 tests/OSETest/Rule/AgrementFourniRuleTest.php |  6 +-
 34 files changed, 75 insertions(+), 193 deletions(-)
 delete mode 100644 module/Application/src/Application/Entity/Db/TypeIntervenantExterieur.php

diff --git a/module/Application/src/Application/Assertion/ServiceAssertion.php b/module/Application/src/Application/Assertion/ServiceAssertion.php
index d0e6db0fd9..0fdc6bfc77 100644
--- a/module/Application/src/Application/Assertion/ServiceAssertion.php
+++ b/module/Application/src/Application/Assertion/ServiceAssertion.php
@@ -7,7 +7,6 @@ use Application\Acl\ComposanteRole;
 use Application\Acl\DrhRole;
 use Application\Acl\EtablissementRole;
 use Application\Acl\IntervenantRole;
-use Application\Entity\Db\IntervenantPermanent;
 use Application\Entity\Db\Intervenant;
 use Application\Entity\Db\Service;
 use Zend\Permissions\Acl\Acl;
diff --git a/module/Application/src/Application/Controller/DossierController.php b/module/Application/src/Application/Controller/DossierController.php
index 9724852e7e..97a7fff5fa 100644
--- a/module/Application/src/Application/Controller/DossierController.php
+++ b/module/Application/src/Application/Controller/DossierController.php
@@ -5,7 +5,7 @@ namespace Application\Controller;
 use Application\Acl\IntervenantRole;
 use Application\Controller\Plugin\Context;
 use Application\Entity\Db\Intervenant;
-use Application\Entity\Db\IntervenantExterieur;
+use Application\Entity\Db\Intervenant;
 use Application\Entity\Db\StatutIntervenant;
 use Application\Entity\Db\Listener\DossierListener;
 use Application\Entity\Db\TypeValidation;
@@ -52,7 +52,7 @@ class DossierController extends AbstractActionController implements WorkflowInte
 
 
     /**
-     * @var IntervenantExterieur
+     * @var Intervenant
      */
     private $intervenant;
 
@@ -76,7 +76,6 @@ class DossierController extends AbstractActionController implements WorkflowInte
     {
         $this->em()->getFilters()->enable('historique')->init([
             'Application\Entity\Db\Intervenant',
-            'Application\Entity\Db\IntervenantExterieur',
             'Application\Entity\Db\Validation',
             'Application\Entity\Db\TypeValidation',
             'Application\Entity\Db\Dossier',
@@ -127,7 +126,7 @@ class DossierController extends AbstractActionController implements WorkflowInte
         }
         
         // refetch intervenant avec jointure sur dossier (et respect de l'historique)
-        $qb = $this->em()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("i")
+        $qb = $this->em()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("i")
                 ->select("i, d")
                 ->leftJoin("i.dossier", "d")
                 ->andWhere("i = :i")
diff --git a/module/Application/src/Application/Controller/PieceJointeController.php b/module/Application/src/Application/Controller/PieceJointeController.php
index b42c710b9d..7c6e82a27e 100644
--- a/module/Application/src/Application/Controller/PieceJointeController.php
+++ b/module/Application/src/Application/Controller/PieceJointeController.php
@@ -5,7 +5,7 @@ namespace Application\Controller;
 use Application\Assertion\FichierAssertion;
 use Application\Assertion\PieceJointeAssertion;
 use Application\Entity\Db\Fichier;
-use Application\Entity\Db\IntervenantExterieur;
+use Application\Entity\Db\Intervenant;
 use Application\Entity\Db\PieceJointe;
 use Application\Entity\Db\TypePieceJointe;
 use Application\Entity\Db\TypePieceJointeStatut;
@@ -89,7 +89,7 @@ class PieceJointeController extends AbstractActionController implements Workflow
     {
         $this->initFilters();
 
-        if (!$this->getIntervenant() instanceof IntervenantExterieur) {
+        if ($this->getIntervenant()->estPermanent()) {
             throw new MessageException("Les pièces justificatives ne concernent que les intervenants extérieurs.");
         }
 
@@ -469,7 +469,7 @@ class PieceJointeController extends AbstractActionController implements Workflow
 
 
     /**
-     * @var IntervenantExterieur
+     * @var Intervenant
      */
     private $intervenant;
 
diff --git a/module/Application/src/Application/Controller/ServiceReferentielController.php b/module/Application/src/Application/Controller/ServiceReferentielController.php
index 37af990fbd..23f6121607 100644
--- a/module/Application/src/Application/Controller/ServiceReferentielController.php
+++ b/module/Application/src/Application/Controller/ServiceReferentielController.php
@@ -11,7 +11,6 @@ use Application\Service\Traits\VolumeHoraireReferentielAwareTrait;
 use Zend\Mvc\Controller\AbstractActionController;
 use Common\Exception\MessageException;
 use Application\Exception\DbException;
-use Application\Entity\Db\IntervenantPermanent;
 use Application\Entity\Service\Recherche;
 use Application\Service\Traits\ContextAwareTrait;
 
diff --git a/module/Application/src/Application/Controller/ValidationController.php b/module/Application/src/Application/Controller/ValidationController.php
index 01b6409c0c..6dee96956f 100644
--- a/module/Application/src/Application/Controller/ValidationController.php
+++ b/module/Application/src/Application/Controller/ValidationController.php
@@ -59,7 +59,7 @@ class ValidationController extends AbstractActionController
     private $isReferentiel;
 
     /**
-     * @var \Application\Entity\Db\IntervenantExterieur
+     * @var \Application\Entity\Db\Intervenant
      */
     private $intervenant;
 
diff --git a/module/Application/src/Application/Entity/Db/Contrat.php b/module/Application/src/Application/Entity/Db/Contrat.php
index 48b6ccd0d6..7e07b0f674 100644
--- a/module/Application/src/Application/Entity/Db/Contrat.php
+++ b/module/Application/src/Application/Entity/Db/Contrat.php
@@ -24,7 +24,7 @@ class Contrat implements HistoriqueAwareInterface, ResourceInterface
     private $typeContrat;
 
     /**
-     * @var \Application\Entity\Db\IntervenantExterieur
+     * @var \Application\Entity\Db\Intervenant
      */
     private $intervenant;
 
@@ -226,11 +226,11 @@ class Contrat implements HistoriqueAwareInterface, ResourceInterface
     /**
      * Set intervenant
      *
-     * @param \Application\Entity\Db\IntervenantExterieur $intervenant
+     * @param \Application\Entity\Db\Intervenant $intervenant
      *
      * @return self
      */
-    public function setIntervenant(\Application\Entity\Db\IntervenantExterieur $intervenant = null)
+    public function setIntervenant(\Application\Entity\Db\Intervenant $intervenant = null)
     {
         $this->intervenant = $intervenant;
 
@@ -242,7 +242,7 @@ class Contrat implements HistoriqueAwareInterface, ResourceInterface
     /**
      * Get intervenant
      *
-     * @return \Application\Entity\Db\IntervenantExterieur
+     * @return \Application\Entity\Db\Intervenant
      */
     public function getIntervenant()
     {
diff --git a/module/Application/src/Application/Entity/Db/Dossier.php b/module/Application/src/Application/Entity/Db/Dossier.php
index 3683412b2e..bb921c7fc6 100644
--- a/module/Application/src/Application/Entity/Db/Dossier.php
+++ b/module/Application/src/Application/Entity/Db/Dossier.php
@@ -553,10 +553,10 @@ class Dossier implements HistoriqueAwareInterface
         
     /**
      * 
-     * @param \Application\Entity\Db\IntervenantExterieur $intervenant
+     * @param \Application\Entity\Db\Intervenant $intervenant
      * @return \Application\Entity\Db\Dossier
      */
-    public function fromIntervenant(IntervenantExterieur $intervenant)
+    public function fromIntervenant(Intervenant $intervenant)
     {
         $this
                 ->setNomUsuel($intervenant->getNomUsuel())
diff --git a/module/Application/src/Application/Entity/Db/TypeIntervenant.php b/module/Application/src/Application/Entity/Db/TypeIntervenant.php
index 21706ef555..e79b29b968 100644
--- a/module/Application/src/Application/Entity/Db/TypeIntervenant.php
+++ b/module/Application/src/Application/Entity/Db/TypeIntervenant.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Application\Entity\Db;
+
 use UnicaenApp\Entity\HistoriqueAwareInterface;
 use UnicaenApp\Entity\HistoriqueAwareTrait;
 
@@ -9,12 +10,10 @@ use UnicaenApp\Entity\HistoriqueAwareTrait;
  */
 class TypeIntervenant implements HistoriqueAwareInterface
 {
-    use HistoriqueAwareTrait;
+    CONST CODE_PERMANENT = 'P';
+    CONST CODE_EXTERIEUR = 'E';
 
-    public $classToCode = [
-        'Application\Entity\Db\IntervenantPermanent' => 'P',
-        'Application\Entity\Db\IntervenantExterieur' => 'E',
-    ];
+    use HistoriqueAwareTrait;
 
     /**
      * @var string
@@ -101,13 +100,6 @@ class TypeIntervenant implements HistoriqueAwareInterface
 
 
 
-    CONST CODE_PERMANENT = 'P';
-    CONST CODE_EXTERIEUR = 'E';
-    CONST TYPE_PERMANENT = 1;
-    CONST TYPE_EXTERIEUR = 2;
-
-
-
     /**
      * Retourne la représentation littérale de cet objet.
      *
diff --git a/module/Application/src/Application/Entity/Db/TypeIntervenantExterieur.php b/module/Application/src/Application/Entity/Db/TypeIntervenantExterieur.php
deleted file mode 100644
index 5520780398..0000000000
--- a/module/Application/src/Application/Entity/Db/TypeIntervenantExterieur.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-namespace Application\Entity\Db;
-use UnicaenApp\Entity\HistoriqueAwareInterface;
-use UnicaenApp\Entity\HistoriqueAwareTrait;
-
-/**
- * TypeIntervenantExterieur
- */
-class TypeIntervenantExterieur implements HistoriqueAwareInterface
-{
-    use HistoriqueAwareTrait;
-
-    /**
-     * @var string
-     */
-    protected $libelle;
-
-    /**
-     * @var float
-     */
-    protected $limiteHeuresComplementaires;
-
-    /**
-     * @var integer
-     */
-    protected $id;
-
-
-
-    /**
-     * Set libelle
-     *
-     * @param string $libelle
-     *
-     * @return TypeIntervenantExterieur
-     */
-    public function setLibelle($libelle)
-    {
-        $this->libelle = $libelle;
-
-        return $this;
-    }
-
-
-
-    /**
-     * Get libelle
-     *
-     * @return string
-     */
-    public function getLibelle()
-    {
-        return $this->libelle;
-    }
-
-
-
-    /**
-     * Set limiteHeuresComplementaires
-     *
-     * @param float $limiteHeuresComplementaires
-     *
-     * @return TypeIntervenantExterieur
-     */
-    public function setLimiteHeuresComplementaires($limiteHeuresComplementaires)
-    {
-        $this->limiteHeuresComplementaires = $limiteHeuresComplementaires;
-
-        return $this;
-    }
-
-
-
-    /**
-     * Get limiteHeuresComplementaires
-     *
-     * @return float
-     */
-    public function getLimiteHeuresComplementaires()
-    {
-        return $this->limiteHeuresComplementaires;
-    }
-
-
-
-    /**
-     * Get id
-     *
-     * @return integer
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-
-}
diff --git a/module/Application/src/Application/Form/Intervenant/Dossier.php b/module/Application/src/Application/Form/Intervenant/Dossier.php
index 60746c6ae2..e099666289 100644
--- a/module/Application/src/Application/Form/Intervenant/Dossier.php
+++ b/module/Application/src/Application/Form/Intervenant/Dossier.php
@@ -62,7 +62,7 @@ class Dossier extends Form implements ServiceLocatorAwareInterface
     public function bind($object, $flags = FormInterface::VALUES_NORMALIZED)
     {
         if ($object->estPermanent()) {
-            throw new LogicException("Ce formulaire ne peut être bindé qu'à un IntervenantExterieur.");
+            throw new LogicException("Ce formulaire ne peut être bindé qu'à un vacataire.");
         }
 
         return parent::bind($object, $flags);
diff --git a/module/Application/src/Application/Form/Intervenant/DossierHydrator.php b/module/Application/src/Application/Form/Intervenant/DossierHydrator.php
index 3f527c0d54..334f15e9b9 100644
--- a/module/Application/src/Application/Form/Intervenant/DossierHydrator.php
+++ b/module/Application/src/Application/Form/Intervenant/DossierHydrator.php
@@ -2,7 +2,7 @@
 namespace Application\Form\Intervenant;
 
 use Application\Entity\Db\Dossier as DossierEntity;
-use Application\Entity\Db\IntervenantExterieur;
+use Application\Entity\Db\Intervenant;
 use Application\Entity\Db\StatutIntervenant;
 use Zend\Stdlib\Hydrator\HydratorInterface;
 
@@ -25,8 +25,8 @@ class DossierHydrator implements HydratorInterface
      * Hydrate $object with the provided $data.
      *
      * @param  array $data
-     * @param  IntervenantExterieur $intervenant
-     * @return IntervenantExterieur
+     * @param  Intervenant $intervenant
+     * @return Intervenant
      */
     public function hydrate(array $data, $intervenant)
     {
@@ -47,7 +47,7 @@ class DossierHydrator implements HydratorInterface
     /**
      * Extract values from an object
      *
-     * @param  IntervenantExterieur $intervenant
+     * @param  Intervenant $intervenant
      * @return array
      */
     public function extract($intervenant)
diff --git a/module/Application/src/Application/Form/Service/SaisieFieldset.php b/module/Application/src/Application/Form/Service/SaisieFieldset.php
index 4a87d43ba8..64498b0b44 100644
--- a/module/Application/src/Application/Form/Service/SaisieFieldset.php
+++ b/module/Application/src/Application/Form/Service/SaisieFieldset.php
@@ -10,7 +10,7 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait;
 use Application\Acl\ComposanteRole;
 use Application\Acl\IntervenantRole;
 use Zend\InputFilter\InputFilterProviderInterface;
-use Application\Entity\Db\IntervenantExterieur;
+
 
 /**
  * Description of SaisieFieldset
@@ -70,7 +70,7 @@ class SaisieFieldset extends Fieldset implements InputFilterProviderInterface, S
             $this->add($intervenant);
         }
 
-        if (!($identityRole instanceof IntervenantRole && $identityRole->getIntervenant() instanceof IntervenantExterieur)){
+        if (!($identityRole instanceof IntervenantRole && !$identityRole->getIntervenant()->estPermanent())){
             $this->add([
                 'type'       => 'Radio',
                 'name'       => 'interne-externe',
diff --git a/module/Application/src/Application/Rule/Intervenant/PeutCreerContratInitialRule.php b/module/Application/src/Application/Rule/Intervenant/PeutCreerContratInitialRule.php
index 2c302da035..03ba6d4956 100644
--- a/module/Application/src/Application/Rule/Intervenant/PeutCreerContratInitialRule.php
+++ b/module/Application/src/Application/Rule/Intervenant/PeutCreerContratInitialRule.php
@@ -3,7 +3,6 @@
 namespace Application\Rule\Intervenant;
 
 use Application\Entity\Db\Contrat;
-use Application\Entity\Db\IntervenantExterieur;
 use Application\Entity\Db\TypeContrat;
 use Application\Entity\Db\Validation;
 use Application\Entity\Db\VolumeHoraire;
@@ -63,7 +62,7 @@ class PeutCreerContratInitialRule extends PeutCreerContratAbstractRule
     
     public function isRelevant()
     {
-        return $this->getIntervenant() instanceof IntervenantExterieur;
+        return !$this->getIntervenant()->estPermanent();
     }
     
     /**
diff --git a/module/Application/src/Application/Rule/Intervenant/PossedeContratRule.php b/module/Application/src/Application/Rule/Intervenant/PossedeContratRule.php
index 88ea83208f..f403dfe4f7 100644
--- a/module/Application/src/Application/Rule/Intervenant/PossedeContratRule.php
+++ b/module/Application/src/Application/Rule/Intervenant/PossedeContratRule.php
@@ -2,10 +2,8 @@
 
 namespace Application\Rule\Intervenant;
 
-use Application\Entity\Db\IntervenantExterieur;
 use Application\Traits\StructureAwareTrait;
 use Application\Traits\TypeContratAwareTrait;
-use Common\Exception\LogicException;
 use Doctrine\ORM\QueryBuilder;
 
 /**
@@ -68,7 +66,7 @@ class PossedeContratRule extends AbstractIntervenantRule
     public function getQueryBuilder()
     {
         $qb = $this->getServiceIntervenant()->getEntityManager()->createQueryBuilder()
-                ->from("Application\Entity\Db\IntervenantExterieur", "i")
+                ->from("Application\Entity\Db\Intervenant", "i")
                 ->select("i.id")
                 ->join("i.contrat", "c");
 
@@ -97,7 +95,7 @@ class PossedeContratRule extends AbstractIntervenantRule
     public function isRelevant()
     {
         if ($this->getIntervenant()) {
-            return $this->getIntervenant() instanceof IntervenantExterieur;
+            return !$this->getIntervenant()->estPermanent();
         }
 
         return true;
diff --git a/module/Application/src/Application/Rule/Intervenant/PossedeDossierRule.php b/module/Application/src/Application/Rule/Intervenant/PossedeDossierRule.php
index 13b8cf8c55..8a67c6714e 100644
--- a/module/Application/src/Application/Rule/Intervenant/PossedeDossierRule.php
+++ b/module/Application/src/Application/Rule/Intervenant/PossedeDossierRule.php
@@ -2,7 +2,6 @@
 
 namespace Application\Rule\Intervenant;
 
-use Application\Entity\Db\IntervenantExterieur;
 use Common\Exception\LogicException;
 
 /**
@@ -71,13 +70,13 @@ class PossedeDossierRule extends AbstractIntervenantRule
     public function getQueryBuilder()
     {
         $em = $this->getServiceIntervenant()->getEntityManager();
-        $qb = $em->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("i")
+        $qb = $em->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("i")
                 ->select("i.id")
                 ->join("i.dossier", "d");
 
         if ($this->getIntervenant()) {
-            if (!$this->getIntervenant() instanceof IntervenantExterieur) {
-                throw new LogicException("L'intervenant spécifié doit être un IntervenantExterieur.");
+            if ($this->getIntervenant()->estPermanent()) {
+                throw new LogicException("L'intervenant spécifié doit être un vacataire.");
             }
 
             $qb->andWhere("i = " . $this->getIntervenant()->getId());
diff --git a/module/Application/src/Application/Service/Context.php b/module/Application/src/Application/Service/Context.php
index 3a87b4c403..12ac2c2c32 100644
--- a/module/Application/src/Application/Service/Context.php
+++ b/module/Application/src/Application/Service/Context.php
@@ -8,7 +8,6 @@ use Application\Entity\Db\Annee         as AnneeEntity;
 use Application\Entity\Db\Structure     as StructureEntity;
 use \DateTime;
 use Zend\Session\Container;
-use \Application\Interfaces\StructureAwareInterface;
 
 /**
  * Service fournissant les différents contextes de fonctionnement de l'application.
@@ -17,12 +16,12 @@ use \Application\Interfaces\StructureAwareInterface;
  */
 class Context extends AbstractService
 {
-    use Traits\EtablissementAwareTrait,
-        Traits\AnneeAwareTrait,
-        Traits\IntervenantAwareTrait,
-        Traits\ParametresAwareTrait,
-        Traits\StructureAwareTrait
-    ;
+    use Traits\EtablissementAwareTrait;
+    use Traits\AnneeAwareTrait;
+    use Traits\IntervenantAwareTrait;
+    use Traits\ParametresAwareTrait;
+    use Traits\StructureAwareTrait;
+
 
     /**
      * selectedIdentityRole
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/AgrementCAMaisPasContratIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/AgrementCAMaisPasContratIndicateurImpl.php
index eebce4fd89..8337485616 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/AgrementCAMaisPasContratIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/AgrementCAMaisPasContratIndicateurImpl.php
@@ -39,9 +39,9 @@ class AgrementCAMaisPasContratIndicateurImpl extends AbstractIntervenantResultIn
     protected function getQueryBuilder()
     {
         // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
                 ->join("int.statut", "st", Join::WITH, "st.peutAvoirContrat = 1")
                 ->join("int.agrement", "a")
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteAvenantIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteAvenantIndicateurImpl.php
index 1b609d4d7a..4f27fcb19c 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteAvenantIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteAvenantIndicateurImpl.php
@@ -39,9 +39,9 @@ class AttenteAvenantIndicateurImpl extends AbstractIntervenantResultIndicateurIm
     protected function getQueryBuilder()
     {
         // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.statut", "st", Join::WITH, "st.peutAvoirContrat = 1")
             ->join("int.service", "s")
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteContratIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteContratIndicateurImpl.php
index e0fb3ba1ec..44837d1fa4 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteContratIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteContratIndicateurImpl.php
@@ -39,9 +39,9 @@ class AttenteContratIndicateurImpl extends AbstractIntervenantResultIndicateurIm
     protected function getQueryBuilder()
     {
         // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.statut", "st", Join::WITH, "st.peutAvoirContrat = 1")
             ->join("int.service", "s")
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteRetourContratIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteRetourContratIndicateurImpl.php
index 7455adb2f0..3ddffb33d1 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/AttenteRetourContratIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/AttenteRetourContratIndicateurImpl.php
@@ -69,7 +69,7 @@ class AttenteRetourContratIndicateurImpl extends AbstractIntervenantResultIndica
      */
     protected function getQueryBuilder()
     {
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.contrat", "c")
             ->andWhere("int.annee = :annee")
@@ -85,7 +85,7 @@ class AttenteRetourContratIndicateurImpl extends AbstractIntervenantResultIndica
     protected function initQueryBuilder(QueryBuilder $qb)
     {
         // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
         $qb
             ->join("c.typeContrat", "tc", Join::WITH, "tc.code = :codeTypeContrat")
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/ContratAvenantDeposesIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/ContratAvenantDeposesIndicateurImpl.php
index a261bb7f57..edee7be668 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/ContratAvenantDeposesIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/ContratAvenantDeposesIndicateurImpl.php
@@ -138,10 +138,10 @@ class ContratAvenantDeposesIndicateurImpl extends AbstractIntervenantResultIndic
      */
     protected function getQueryBuilder()
     {
-        // INDISPENSABLE si plusieurs requêtes successives sur IntervenantExterieur !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.contrat", "c", Join::WITH, "1 = pasHistorise(c)")
             ->join("c.fichier", "f", Join::WITH, "1 = pasHistorise(f)")
diff --git a/module/Application/src/Application/Service/Indicateur/Contrat/SaisieServiceApresContratAvenantIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Contrat/SaisieServiceApresContratAvenantIndicateurImpl.php
index 59eabf5281..08808bf263 100644
--- a/module/Application/src/Application/Service/Indicateur/Contrat/SaisieServiceApresContratAvenantIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Contrat/SaisieServiceApresContratAvenantIndicateurImpl.php
@@ -37,10 +37,10 @@ class SaisieServiceApresContratAvenantIndicateurImpl extends AbstractIntervenant
      */
     protected function getQueryBuilder()
     {
-        // INDISPENSABLE si plusieurs requêtes successives sur IntervenantExterieur !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.contrat", "c")
             ->join("int.service", "s")
diff --git a/module/Application/src/Application/Service/Indicateur/Dossier/AttenteValidationDonneesPersoIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Dossier/AttenteValidationDonneesPersoIndicateurImpl.php
index 35a426c12b..f822f0c50a 100644
--- a/module/Application/src/Application/Service/Indicateur/Dossier/AttenteValidationDonneesPersoIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Dossier/AttenteValidationDonneesPersoIndicateurImpl.php
@@ -37,10 +37,10 @@ class AttenteValidationDonneesPersoIndicateurImpl extends AbstractIntervenantRes
      */
     protected function getQueryBuilder()
     {
-        // INDISPENSABLE si plusieurs requêtes successives sur IntervenantExterieur !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.statut", "st", Join::WITH, "st.peutSaisirDossier = 1")
             ->andWhere("int.annee = :annee")
diff --git a/module/Application/src/Application/Service/Indicateur/Dossier/DonneesPersoDiffImportIndicateurImpl.php b/module/Application/src/Application/Service/Indicateur/Dossier/DonneesPersoDiffImportIndicateurImpl.php
index 605d82d5c8..b67e163f8a 100644
--- a/module/Application/src/Application/Service/Indicateur/Dossier/DonneesPersoDiffImportIndicateurImpl.php
+++ b/module/Application/src/Application/Service/Indicateur/Dossier/DonneesPersoDiffImportIndicateurImpl.php
@@ -35,10 +35,10 @@ class DonneesPersoDiffImportIndicateurImpl extends AbstractIntervenantResultIndi
      */
     protected function getQueryBuilder()
     {
-        // INDISPENSABLE si plusieurs requêtes successives sur IntervenantExterieur !
-        $this->getEntityManager()->clear('Application\Entity\Db\IntervenantExterieur');
+        // INDISPENSABLE si plusieurs requêtes successives sur Intervenant !
+        $this->getEntityManager()->clear('Application\Entity\Db\Intervenant');
         
-        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\IntervenantExterieur')->createQueryBuilder("int");
+        $qb = $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant')->createQueryBuilder("int");
         $qb
             ->join("int.statut", "st", Join::WITH, "st.peutSaisirDossier = 1")
             ->join("int.vIndicDiffDossier", "vidd")
diff --git a/module/Application/src/Application/Service/PieceJointe.php b/module/Application/src/Application/Service/PieceJointe.php
index 7d4fe92566..dc1cbed643 100644
--- a/module/Application/src/Application/Service/PieceJointe.php
+++ b/module/Application/src/Application/Service/PieceJointe.php
@@ -6,7 +6,6 @@ use Doctrine\ORM\QueryBuilder;
 use Application\Entity\Db\TypePieceJointe as TypePieceJointeEntity;
 use Application\Entity\Db\PieceJointe as PieceJointeEntity;
 use Application\Entity\Db\Fichier as FichierEntity;
-use Application\Entity\Db\IntervenantExterieur as IntervenantExterieurEntity;
 use Application\Entity\Db\Intervenant as IntervenantEntity;
 use Application\Entity\Db\TypeValidation as TypeValidationEntity;
 use Application\Assertion\PieceJointeAssertion;
@@ -120,7 +119,7 @@ EOS;
      * @param boolean $deleteFiles Supprimer les fichiers après création de la PJ$
      * @return PieceJointeEntity[]
      */
-    public function ajouterFichiers($files, IntervenantExterieurEntity $intervenant, TypePieceJointeEntity $type, $deleteFiles = true)
+    public function ajouterFichiers($files, IntervenantEntity $intervenant, TypePieceJointeEntity $type, $deleteFiles = true)
     {
         if (!$files) {
            throw new \Common\Exception\LogicException("Aucune donnée sur les fichiers spécifiée.");
diff --git a/module/Application/src/Application/Service/Process/ContratProcess.php b/module/Application/src/Application/Service/Process/ContratProcess.php
index 413cedfcb8..af7b0127e0 100644
--- a/module/Application/src/Application/Service/Process/ContratProcess.php
+++ b/module/Application/src/Application/Service/Process/ContratProcess.php
@@ -2,22 +2,19 @@
 
 namespace Application\Service\Process;
 
-use Application\Acl\ComposanteRole;
 use Application\Entity\Db\TypeContrat;
 use Application\Entity\Db\TypeValidation;
 use Application\Rule\Intervenant\PeutCreerAvenantRule;
 use Application\Rule\Intervenant\PeutCreerContratInitialRule;
 use Application\Service\AbstractService;
-use Application\Service\Contrat as ContratService;
 use Application\Traits\IntervenantAwareTrait;
-use Common\Exception\LogicException;
 use Common\Exception\RuntimeException;
 use Application\Entity\Db\Contrat;
 
 /**
  * Workflow de création des contrats et avenants.
  *
- * @method \Application\Entity\Db\IntervenantExterieur getIntervenant() Description
+ * @method \Application\Entity\Db\Intervenant getIntervenant() Description
  * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
  */
 class ContratProcess extends AbstractService
diff --git a/module/Application/src/Application/Service/Process/PieceJointeProcess.php b/module/Application/src/Application/Service/Process/PieceJointeProcess.php
index 4bbb9f8e4a..d655500f37 100644
--- a/module/Application/src/Application/Service/Process/PieceJointeProcess.php
+++ b/module/Application/src/Application/Service/Process/PieceJointeProcess.php
@@ -3,7 +3,7 @@
 namespace Application\Service\Process;
 
 use Application\Entity\Db\Dossier;
-use Application\Entity\Db\IntervenantExterieur;
+use Application\Entity\Db\Intervenant;
 use Application\Entity\Db\PieceJointe;
 use Application\Entity\Db\StatutIntervenant;
 use Application\Entity\Db\TypePieceJointe;
@@ -145,17 +145,17 @@ class PieceJointeProcess extends AbstractService
     }
 
     /**
-     * @var IntervenantExterieur
+     * @var Intervenant
      */
     private $intervenant;
 
     /**
      *
-     * @param IntervenantExterieur $intervenant
+     * @param Intervenant $intervenant
      * @return \Application\Service\DossierProcess
      * @throws AucuneAFournirException
      */
-    public function setIntervenant(IntervenantExterieur $intervenant)
+    public function setIntervenant(Intervenant $intervenant)
     {
         $this->intervenant = $intervenant;
 
@@ -174,7 +174,7 @@ class PieceJointeProcess extends AbstractService
     }
 
     /**
-     * @return IntervenantExterieur
+     * @return Intervenant
      */
     public function getIntervenant()
     {
diff --git a/module/Application/src/Application/Service/ServiceService.php b/module/Application/src/Application/Service/ServiceService.php
index 7abde173ff..9487662d52 100644
--- a/module/Application/src/Application/Service/ServiceService.php
+++ b/module/Application/src/Application/Service/ServiceService.php
@@ -478,7 +478,7 @@ class ServiceService extends AbstractEntityService
     /**
      * Retourne la liste des services selon l'étape donnée
      *
-     * @param string            $statutInterv "Application\Entity\Db\IntervenantPermanent" ou "Application\Entity\Db\IntervenantExterieur"
+     * @param TypeIntervenantEntity $typeIntervenant
      * @param QueryBuilder|null $queryBuilder
      *
      * @return QueryBuilder
@@ -1250,7 +1250,7 @@ class ServiceService extends AbstractEntityService
 
     public function canHaveMotifNonPaiement(ServiceEntity $service, $runEx = false)
     {
-        if ($service->getIntervenant() instanceof \Application\Entity\Db\IntervenantExterieur) {
+        if (!$service->getIntervenant()->estPermanent()) {
             return $this->cannotDoThat("Un intervenant vacataire ne peut pas avoir de motif de non paiement", $runEx);
         }
         if ($this->getServiceContext()->getSelectedIdentityRole() instanceof \Application\Acl\IntervenantRole) {
diff --git a/module/Application/src/Application/Service/Workflow/Step/EditionContratStep.php b/module/Application/src/Application/Service/Workflow/Step/EditionContratStep.php
index 16918589e3..23fe775faa 100644
--- a/module/Application/src/Application/Service/Workflow/Step/EditionContratStep.php
+++ b/module/Application/src/Application/Service/Workflow/Step/EditionContratStep.php
@@ -2,8 +2,6 @@
 
 namespace Application\Service\Workflow\Step;
 
-use Application\Acl\IntervenantPermanentRole;
-use Application\Acl\IntervenantExterieurRole;
 use Application\Acl\ComposanteRole;
 use Application\Acl\IntervenantRole;
 
diff --git a/module/Application/src/Application/View/Helper/AppLink.php b/module/Application/src/Application/View/Helper/AppLink.php
index c79d4fdb26..ce1470f6f6 100644
--- a/module/Application/src/Application/View/Helper/AppLink.php
+++ b/module/Application/src/Application/View/Helper/AppLink.php
@@ -1,6 +1,7 @@
 <?php
 namespace Application\View\Helper;
 
+use Application\Entity\Db\Traits\AnneeAwareTrait;
 use Zend\I18n\View\Helper\AbstractTranslatorHelper;
 use Zend\Mvc\Router\RouteMatch;
 use Zend\Mvc\Router\RouteStackInterface;
@@ -19,7 +20,7 @@ use Zend\Form\Element\Select;
  */
 class AppLink extends AbstractTranslatorHelper
 {
-    use \Application\Traits\AnneeAwareTrait;
+    use AnneeAwareTrait;
 
     /**
      * @var string
diff --git a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php
index 576a054247..28354d4070 100644
--- a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php
+++ b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php
@@ -85,7 +85,7 @@ class IntervenantViewHelper extends AbstractHtmlElement
         ];
 
         /* @deprecated en attendant la fusion des types d'intervenants... */
-        if ($entity instanceof \Application\Entity\Db\IntervenantExterieur) {
+        if (!$entity->estPermanent()) {
             $vars['identite']['Situation familiale'] = $entity->getSituationFamiliale() ?: "(Inconnue)";
         }
 
diff --git a/module/Application/view/application/index/index.phtml b/module/Application/view/application/index/index.phtml
index d66f10c482..df11c597d7 100755
--- a/module/Application/view/application/index/index.phtml
+++ b/module/Application/view/application/index/index.phtml
@@ -29,7 +29,7 @@ echo $this->messenger()->addMessagesFromFlashMessenger();
                     $wf = $this->workflow($intervenant, $role)->getWorkflow();
                     if ($wf->getSteps()) {
                         $step = $wf->getCurrentStep() ?: $wf->getLastStep();
-                        /* @var $wf \Application\Service\Workflow\WorkflowIntervenantExterieur */
+                        /* @var $wf \Application\Service\Workflow\WorkflowIntervenant */
                         $url   = $wf->getStepUrl($step);
                         $label = $this->translate($step->getLabel($role));
 
diff --git a/module/Common/src/Common/ORM/Filter/AnneeFilter.php b/module/Common/src/Common/ORM/Filter/AnneeFilter.php
index 926c60545f..56202f5f66 100644
--- a/module/Common/src/Common/ORM/Filter/AnneeFilter.php
+++ b/module/Common/src/Common/ORM/Filter/AnneeFilter.php
@@ -2,6 +2,8 @@
 
 namespace Common\ORM\Filter;
 
+use Application\Entity\Db\Etape;
+use Application\Entity\Db\Interfaces\AnneeAwareInterface;
 use Application\Service\Traits\ContextAwareTrait;
 use Doctrine\ORM\Mapping\ClassMetaData;
 use Application\Entity\Db\Annee;
@@ -22,9 +24,9 @@ class AnneeFilter extends AbstractFilter
     public function addFilterConstraint(ClassMetaData $targetEntity, $targetTableAlias)
     {
         if (isset($this->enabledEntities[$targetEntity->name])) {
-            if ($targetEntity->name == Application\Entity\Db\Etape::class) {
+            if ($targetEntity->name == Etape::class) {
                 return $this->addEtapeFilterConstraint($targetTableAlias);
-            } elseif ($targetEntity->reflClass->implementsInterface(Application\Entity\Db\Interfaces\AnneeAwareInterface::class)) {
+            } elseif ($targetEntity->reflClass->implementsInterface(AnneeAwareInterface::class)) {
                 return $targetTableAlias . '.ANNEE_ID = ' . $this->getServiceContext()->getAnnee()->getId();
             }
         }
diff --git a/tests/OSETest/Rule/AgrementFourniRuleTest.php b/tests/OSETest/Rule/AgrementFourniRuleTest.php
index 631c7947f1..685141b490 100644
--- a/tests/OSETest/Rule/AgrementFourniRuleTest.php
+++ b/tests/OSETest/Rule/AgrementFourniRuleTest.php
@@ -3,8 +3,6 @@
 namespace OSETest\Rule;
 
 use Application\Entity\Db\Intervenant;
-use Application\Entity\Db\IntervenantExterieur;
-use Application\Entity\Db\IntervenantPermanent;
 use Application\Entity\Db\StatutIntervenant;
 use Application\Entity\Db\TypeAgrement;
 use Application\Entity\Db\TypeAgrementStatut;
@@ -27,12 +25,12 @@ class AgrementFourniRuleTest extends BaseRuleTest
     protected $rule;
     
     /**
-     * @var IntervenantExterieur 
+     * @var Intervenant
      */
     private $ie;
     
     /**
-     * @var IntervenantPermanent
+     * @var Intervenant
      */
     private $ip;
     
-- 
GitLab