Fix SituationJuridique lorsque Absorption / Dissolution si annonces

après 1 an alors on ne flag pas
This commit is contained in:
Michael RICOIS 2017-01-05 14:07:27 +01:00
parent 7db57802b6
commit 6b3bec9fd7

View File

@ -1701,7 +1701,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$identite = $result;
}
}
if (count($identite)>0) {
if (count($identite) > 0) {
// --- Actif
$identite['Actif'] = 1;
if (array_key_exists('insEVE', $identite)) {
@ -1743,11 +1743,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
}
rsort($tabDates);
$dateProcol = str_replace('-', '', $tabDates[0])*1;
if ($this->dureePlan>0 && date('Ymd')<$this->finPlan) {
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
$identite['SituationJuridique'] = 'PL';
}
// Plan révolu
elseif ($this->dureePlan>0 && date('Ymd')>=$this->finPlan) {
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
$identite['SituationJuridique'] = '';
}
// Appel de jugement
@ -1758,9 +1758,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
else {
$identite['SituationJuridique'] = 'P';
}
} elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
}
// Absorption
elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
$identite['SituationJuridique'] = 'A';
} elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
}
// Dissolution
elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
$identite['SituationJuridique'] = 'D';
}
// Fin Situation Juridique
@ -2568,91 +2572,123 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
if ($this->debug) {
file_put_contents('procol.log', "=== Situation Juridique ===\n");
}
$tabProcol = $this->getAnnoncesLegales($siren, 0, 'P', false);
if (count($tabProcol) > 0) {
$tabAnn = $this->getAnnoncesLegales($siren, 0, '', false, false);
if (count($tabAnn) > 0) {
// Date de dernière mise à jour
$tabDates = array();
foreach ($tabProcol as $iProcol => $procol) {
$tabDates[] = $procol['dateJugement'];
foreach ($tabAnn as $iAnn => $ann) {
$tabDates[] = $ann['dateInsertionSD'];
}
rsort($tabDates);
$dateProcol = str_replace('-', '', $tabDates[0])*1;
// Plan
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
if ($this->debug) {
file_put_contents('procol.log', "Plan (PL) : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = 'PL';
}
// Plan révolu
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
if ($this->debug) {
file_put_contents('procol.log', "Plan revolu : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = '';
}
// Appel de jugement
elseif ($this->appelJugement) {
$tabRet['SituationJuridique'] = 'PA';
}
// Jugement de cloture après LJ
elseif ($this->SituationCloture) {
if ($this->debug) {
file_put_contents('procol.log', "Cloture (CL) "."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = 'CL';
}
// En cours de procédure
else {
if ($this->debug) {
file_put_contents('procol.log', "Procol (P) "."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = 'P';
$tabRet['dateMajANN'] = Metier_Util_Date::dateT('Y-m-d', 'Y-m-d', $tabDates[0]);
if ($tabRet['dateMajANN'] == '--') {
$tabRet['dateMajANN'] = '';
} else {
$dateAnnLastCompare = DateTime::createFromFormat('Y-m-d', $tabRet['dateMajANN']);
}
// RAZ SituationJuridique si cutoff plus récent que dernière procol
$stmt = $this->conn->executeQuery("SELECT encours, scoreSolv, scoreDir, scoreConf, DATE(dateInsert)*1 AS dateInsert, DATE(dateUpdate)*1 AS dateUpdate FROM jo.scores_cutoff WHERE siren=$siren");
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($result['scoreSolv'] > 0) {
//Tri des dates de procol
$tabDates = array();
foreach ($tabProcol as $iProcol=>$procol) {
$tabDates[] = $procol['dateJugement'];
// Procol
$tabProcol = $this->getAnnoncesLegales($siren, 0, 'P', false);
if (count($tabProcol) > 0) {
$tabDates = array();
foreach ($tabProcol as $iProcol => $procol) {
$tabDates[] = $procol['dateJugement'];
}
rsort($tabDates);
$dateProcol = str_replace('-', '', $tabDates[0])*1;
// Plan
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
if ($this->debug) {
file_put_contents('procol.log', "Plan (PL) : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
}
rsort($tabDates);
$dateProcol = str_replace('-', '', $tabDates[0])*1;
if ($result['dateUpdate'] > $result['dateInsert']) {
$dateMaj = str_replace('-', '', $result['dateUpdate']);
} else {
$dateMaj = str_replace('-', '', $result['dateInsert']);
$tabRet['SituationJuridique'] = 'PL';
}
// Plan révolu
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
if ($this->debug) {
file_put_contents('procol.log', "Plan revolu : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
}
if ($dateProcol <= $dateMaj) {
$tabRet['SituationJuridique'] = '';
$tabRet['SituationJuridique'] = '';
}
// Appel de jugement
elseif ($this->appelJugement) {
$tabRet['SituationJuridique'] = 'PA';
}
// Jugement de cloture après LJ
elseif ($this->SituationCloture) {
if ($this->debug) {
file_put_contents('procol.log', "Cloture (CL) "."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = 'CL';
}
// En cours de procédure
else {
if ($this->debug) {
file_put_contents('procol.log', "Procol (P) "."\n", FILE_APPEND);
}
$tabRet['SituationJuridique'] = 'P';
}
// RAZ SituationJuridique si cutoff plus récent que dernière procol
$stmt = $this->conn->executeQuery("SELECT encours, scoreSolv, scoreDir, scoreConf, DATE(dateInsert)*1 AS dateInsert, DATE(dateUpdate)*1 AS dateUpdate FROM jo.scores_cutoff WHERE siren=$siren");
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($result['scoreSolv'] > 0) {
//Tri des dates de procol
$tabDates = array();
foreach ($tabProcol as $iProcol => $procol) {
$tabDates[] = $procol['dateJugement'];
}
rsort($tabDates);
$dateProcol = str_replace('-', '', $tabDates[0])*1;
if ($result['dateUpdate'] > $result['dateInsert']) {
$dateMaj = str_replace('-', '', $result['dateUpdate']);
} else {
$dateMaj = str_replace('-', '', $result['dateInsert']);
}
if ($dateProcol <= $dateMaj) {
$tabRet['SituationJuridique'] = '';
}
}
}
}
// Absorption
if ($identite['SituationJuridique'] == '') {
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'A', false);
$nbAnn = count($tabAnn);
if (count($tabAnn) > 0) {
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
$dateAnnCompare->add(new DateInterval('P364D'));
if ($dateAnnCompare >= $dateAnnLastCompare) {
$tabRet['SituationJuridique'] = 'A';
}
}
}
// Dissolution
if ($identite['SituationJuridique'] == '') {
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'D', false);
$nbAnn = count($tabAnn);
if (count($tabAnn) > 0) {
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
$dateAnnCompare->add(new DateInterval('P364D'));
if ($dateAnnCompare >= $dateAnnLastCompare) {
$tabRet['SituationJuridique'] = 'D';
}
}
}
} elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
$tabRet['SituationJuridique'] = 'A';
} elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
$tabRet['SituationJuridique'] = 'D';
}
if ($this->debug) {
file_put_contents('procol.log', "SituationJuridique = ".$tabRet['SituationJuridique']."\n", FILE_APPEND);
}
// Fin Situation Juridique
// Date de dernière mise à jour
$tabAnn = $this->getAnnoncesLegales($siren, 0, '', false, false);
$tabDates=array();
foreach ($tabAnn as $iAnn=>$ann) {
$tabDates[] = $ann['dateInsertionSD'];
}
rsort($tabDates);
$tabRet['dateMajANN'] = Metier_Util_Date::dateT('Y-m-d', 'Y-m-d', $tabDates[0]);
if ($tabRet['dateMajANN'] == '--') {
$tabRet['dateMajANN'] = '';
}
$timer['getAnnoncesLegales']=microtime(true);
$timer['getAnnoncesLegales'] = microtime(true);
}
if (($tabInsee['CJ'] > 0 && $tabInsee['CJ'] < 20