From 1da2648ca8177d91fd11d48f8c0b5ac092df14cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr> Date: Fri, 28 Jun 2019 14:12:49 +0200 Subject: [PATCH] =?UTF-8?q?Correctif=20pour=20tous=20les=20cas=20d'interve?= =?UTF-8?q?nants=20ayant=20un=20code=20INSEE=20contenant=2075=20et=20n?= =?UTF-8?q?=C3=A9s=20en=20Seine=20et=20Oise=20<=3D1968.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/Application/Entity/Db/Departement.php | 12 ++++++++ .../Validator/NumeroINSEEValidator.php | 28 ++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb94dcf04a..39d2481c7c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ne sont plus affichées lorsqu'on clique sur l'utilisateur en haut à droite. * Dans la fiche de service, les codes des éléments et des étapes s'affichent de nouveau (ils n'étaient plus visibles) * Lorsqu'on crée un nouveau rôle et qu'on lui ajoute des privilèges, l'application ne plante plus (problème de cache de données réglé). * Dans l'export Winpaye, le numéro INSEE est maintenant correctement formatté (il supprime les espaces en trop, et ajoute des zéros devant les clés si nécessaire) +* Dans le dossier, les Numéros INSEE avec pour département 75 sont comptés valides par rapport au département de naissance si l'intervenant est né en actuelle région parisienne avant 1968. ## Nouveautés * Nouveau script de test d'accès à la BDD depuis le script de mise à jour (./bin/ose test-bdd) diff --git a/module/Application/src/Application/Entity/Db/Departement.php b/module/Application/src/Application/Entity/Db/Departement.php index a63e2806d6..8d3a3f66b8 100755 --- a/module/Application/src/Application/Entity/Db/Departement.php +++ b/module/Application/src/Application/Entity/Db/Departement.php @@ -139,4 +139,16 @@ class Departement implements HistoriqueAwareInterface, ImportAwareInterface return $this->id; } + + + /** + * @return bool + */ + public function inIleDeFrance(): bool + { + $intCode = (int)$this->getCode(); + + return in_array($intCode, [78,91,92,93,94,95]); + } + } diff --git a/module/Application/src/Application/Validator/NumeroINSEEValidator.php b/module/Application/src/Application/Validator/NumeroINSEEValidator.php index 62a5a8da32..48c762d597 100755 --- a/module/Application/src/Application/Validator/NumeroINSEEValidator.php +++ b/module/Application/src/Application/Validator/NumeroINSEEValidator.php @@ -2,6 +2,8 @@ namespace Application\Validator; +use Application\Constants; +use Application\Entity\Db\Departement; use Application\Service\Traits\CiviliteServiceAwareTrait; use Application\Service\Traits\DepartementServiceAwareTrait; use Application\Service\Traits\PaysServiceAwareTrait; @@ -183,7 +185,7 @@ class NumeroINSEEValidator extends NumeroINSEE if (!$this->isValidDepartementFrance($value, $context)) { return false; } - }elseif ($estNeEnAlgerie) { + } elseif ($estNeEnAlgerie) { // on doit avoir un code département français valide if (!$this->isValidDepartementAlgerie($value, $context)) { return false; @@ -218,8 +220,6 @@ class NumeroINSEEValidator extends NumeroINSEE if (empty($context['departementNaissance'])) { return true; } - $departementNaissance = $this->getServiceDepartement()->get($context['departementNaissance'], true); - /* @var $departementNaissance DepartementEntity */ // Si on trouve un code de département en métropole ou outre-mer valide, // on vérifie qu'il est cohérent avec le code du département de naissance saisi @@ -228,10 +228,24 @@ class NumeroINSEEValidator extends NumeroINSEE || ($d = $this->getDepartementOutreMerValide($value)) ) { + /* @var $departementNaissance Departement */ + $departementNaissance = $this->getServiceDepartement()->get($context['departementNaissance'], true); if ($d !== $departementNaissance->getCode()) { - $this->error(self::MSG_DEPT); - - return false; + $return = false; + $dateNaissance = \DateTime::createFromFormat(Constants::DATE_FORMAT, $context['dateNaissance']); + if ($dateNaissance) { + $anneeNaissance = (int)$dateNaissance->format('Y'); + if ($anneeNaissance <= 1968) { + if ($departementNaissance->inIleDeFrance() && $d === '075') { + $return = true; + } + } + } + if (!$return) { + $this->error(self::MSG_DEPT); + + return false; + } } } // Sinon, le code département n'est pas valide else { @@ -299,7 +313,7 @@ class NumeroINSEEValidator extends NumeroINSEE if (is_numeric($departement)) { $d = (int)$departement; - if (in_array($d, [91,92,93,94,99])) { + if (in_array($d, [91, 92, 93, 94, 99])) { return '0' . (string)$departement; } } -- GitLab