Defaillance
This commit is contained in:
parent
f9a25ce1bd
commit
3a2c27ede9
@ -2784,149 +2784,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
));
|
||||
}
|
||||
|
||||
// --- Situation Juridique
|
||||
if (intval($siren) > 100) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "=== Situation Juridique ===\n");
|
||||
}
|
||||
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, '', false, false);
|
||||
|
||||
if (count($tabAnn) > 0) {
|
||||
// Date de dernière mise à jour
|
||||
$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'] = '';
|
||||
} else {
|
||||
$dateAnnLastCompare = DateTime::createFromFormat('Y-m-d', $tabRet['dateMajANN']);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
$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';
|
||||
}
|
||||
|
||||
// RAZ SituationJuridique si cutoff plus récent que dernière procol
|
||||
try {
|
||||
$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'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
if ($this->logger !== null) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Absorption
|
||||
if ($identite['SituationJuridique'] == '') {
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'A', false);
|
||||
$nbAnn = count($tabAnn);
|
||||
if ($nbAnn > 0) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "DETECTION ABSORPTION\n", FILE_APPEND);
|
||||
}
|
||||
$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';
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Entreprise absorbée\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dissolution
|
||||
if ($identite['SituationJuridique'] == '') {
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'D', false);
|
||||
$nbAnn = count($tabAnn);
|
||||
if ($nbAnn > 0) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "DETECTION DISSOLUTION\n", FILE_APPEND);
|
||||
}
|
||||
$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';
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Entreprise dissolue\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "SituationJuridique = ".$tabRet['SituationJuridique']."\n", FILE_APPEND);
|
||||
}
|
||||
$timer['getAnnoncesLegales'] = microtime(true);
|
||||
} // Fin Situation Juridique
|
||||
|
||||
if (($tabInsee['CJ'] > 0 && $tabInsee['CJ'] < 20
|
||||
|| $tabInsee['CJ'] > 999 && $tabInsee['CJ'] < 2000) && $tabInsee['DIR_FCT']=='') {
|
||||
$tabRet['dir1Titre'] = self::$tabFct['PP'];
|
||||
@ -3459,10 +3316,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
// On signal que l'entreprise est radié du RCS
|
||||
else {
|
||||
$tabRet['EntActiveRCS'] = 0;
|
||||
// On signal que l'entreprise est radié du RCS
|
||||
if ($tabRet['SituationJuridique'] == '') {
|
||||
$tabRet['SituationJuridique'] = 'RR';
|
||||
}
|
||||
}
|
||||
|
||||
// Spécificité EIRL
|
||||
@ -3592,10 +3445,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
// On signal que l'entreprise est radié du RCS
|
||||
else {
|
||||
$tabRet['EntActiveRCS'] = 0;
|
||||
// On signal que l'entreprise est radié du RCS
|
||||
if ($tabRet['SituationJuridique'] == '') {
|
||||
$tabRet['SituationJuridique'] = 'RR';
|
||||
}
|
||||
}
|
||||
|
||||
$tabRet['NomCommercial'] = $rmEntrep['nomCommercial'];
|
||||
@ -3615,19 +3464,20 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$tabRet['dir1Code'] = '1050';
|
||||
}
|
||||
|
||||
if ($accesDist &&
|
||||
if ($accesDist
|
||||
// Département couvert par Infogreffe
|
||||
!in_array($tabRet['Dept'], array(57, 67, 68, 97, 98, 99)) &&
|
||||
&& !in_array($tabRet['Dept'], array(57, 67, 68, 97, 98, 99)) &&
|
||||
// Forme Juridique présente au greffe
|
||||
(in_array($tabInsee['CJ'], array(1100,1200,1300,1700,9900)) ||
|
||||
($tabInsee['CJ']>=3100 && $tabInsee['CJ']<=3299) ||
|
||||
($tabInsee['CJ']>=4100 && $tabInsee['CJ']<=4199) ||
|
||||
($tabInsee['CJ']>=5100 && $tabInsee['CJ']<=5899) ||
|
||||
($tabInsee['CJ']>=6100 && $tabInsee['CJ']<=6599) ||
|
||||
preg_match('/EIRL/', $nom) || preg_match('/EIRL/', $nom2) ||
|
||||
preg_match('/EIRL/', $tabRet['Sigle']) || preg_match('/EIRL/', $tabRet['Enseigne']) ||
|
||||
preg_match('/EIRL/', $tabRet['Adresse']) || preg_match('/EIRL/', $tabRet['Adresse2'])
|
||||
)
|
||||
(in_array($tabInsee['CJ'], array(1100, 1200, 1300, 1700, 9900))
|
||||
|| ($tabInsee['CJ']>=3100 && $tabInsee['CJ']<=3299)
|
||||
|| ($tabInsee['CJ']>=4100 && $tabInsee['CJ']<=4199)
|
||||
|| ($tabInsee['CJ']>=5100 && $tabInsee['CJ']<=5899)
|
||||
|| ($tabInsee['CJ']>=6100 && $tabInsee['CJ']<=6599)
|
||||
|| preg_match('/EIRL/', $nom) || preg_match('/EIRL/', $nom2)
|
||||
|| preg_match('/EIRL/', $tabRet['Sigle'])
|
||||
|| preg_match('/EIRL/', $tabRet['Enseigne'])
|
||||
|| preg_match('/EIRL/', $tabRet['Adresse'])
|
||||
|| preg_match('/EIRL/', $tabRet['Adresse2']) )
|
||||
&& ($tabInsee['CJ']==1700 || // Agents commerciaux (uniquement au Greffes RSAC)
|
||||
$tabRet['numRC']=='' || // Numéro de RCS absent = Anomalie (<à3%)
|
||||
$tabRet['Tribunal']=='' || // Tribunal absent = anomalie
|
||||
@ -3659,12 +3509,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
if (str_replace('-', '', $tabRet['dateImmat'])*1 == 0) {
|
||||
$tabRet['dateImmat'] = $etabG['DateCreation'];
|
||||
}
|
||||
|
||||
if (str_replace('-', '', $tabRet['dateRad'])*1==0) {
|
||||
$tabRet['dateRad'] = $etabG['DateRadiation'];
|
||||
if (str_replace('-', '', $tabRet['dateRad'])*1 > 0 && $tabRet['SituationJuridique'] == '') {
|
||||
$tabRet['SituationJuridique'] = 'RR';
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/[A-Z]/i', substr($tabRet['AutreId'], 2, 2)) || $tabRet['AutreId']=='') {
|
||||
$tabRet['AutreId'] = $etabG['NumRC2'];
|
||||
}
|
||||
@ -3677,9 +3526,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$tabRad = $this->getAnnoncesLegales($siren, 0, 'R');
|
||||
// Il y a au moins une annonce de radiation au Bodacc
|
||||
if (count($tabRad) > 0) {
|
||||
if ($tabRet['SituationJuridique'] == '') {
|
||||
$tabRet['SituationJuridique'] = 'RP';
|
||||
}
|
||||
$dateEff = str_replace('-', '', $tabRad[0]['dateEffet'])*1;
|
||||
$dateJug = str_replace('-', '', $tabRad[0]['dateJugement'])*1;
|
||||
$datePar = str_replace('-', '', $tabRad[0]['DateParution'])*1;
|
||||
@ -3822,6 +3668,78 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$timer['infosBoursieres'] = microtime(true);
|
||||
}
|
||||
|
||||
// --- Situation Juridique
|
||||
$situation = '';
|
||||
if (intval($siren) > 100) {
|
||||
$annoncesList = $this->getAnnoncesLegales($siren);
|
||||
$annoncesNb = count($annoncesList);
|
||||
$detect = new Metier_Defaillance_Detect();
|
||||
$detect->setEvenNb($annoncesNb);
|
||||
$detect->setFJ($tabInsee['CJ']);
|
||||
$detect->setInseeActif($tabInsee['ACTIF']);
|
||||
$detect->setEtabActif($nbEtab);
|
||||
if ($tabRet['numGreffe']*1 > 0) {
|
||||
$detect->setGreffe(1);
|
||||
}
|
||||
$detect->setRcsActif($tabRet['EntActiveRCS']);
|
||||
if (isset($entrep['numRM'])) {
|
||||
$detect->setRM(1);
|
||||
}
|
||||
$detect->setBilanCloture($tabRet['bilanDate']);
|
||||
if (isset($tabRet['dateRad'])) {
|
||||
$detect->setGreffeRadiation($tabRet['dateRad']);
|
||||
}
|
||||
if ($annoncesNb > 0) {
|
||||
// Parcours annonces
|
||||
$tabJugements = array();
|
||||
foreach ($annoncesList as $i => $ann) {
|
||||
$date = str_replace('-','', $ann['dateJugement']);
|
||||
if (intval($date) == 0) {
|
||||
$date = str_replace('-','', $ann['dateEffet']);
|
||||
}
|
||||
if (intval($date) == 0) {
|
||||
$date = str_replace('-','', $ann['dateParution']);
|
||||
}
|
||||
if (!empty($date)) {
|
||||
$tabJugements[$date] = $ann;
|
||||
}
|
||||
}
|
||||
ksort($tabJugements);
|
||||
foreach ($tabJugements as $ann) {
|
||||
$annFormat = new stdClass();
|
||||
$date = str_replace('-', '', $ann['dateJugement']);
|
||||
if (intval($date) == 0) {
|
||||
$date = str_replace('-', '', $ann['dateEffet']);
|
||||
}
|
||||
$annFormat->date = $date;
|
||||
$annFormat->code = $ann['evenements'][0]['CodeEven'];
|
||||
$annFormat->txt = $ann['texteAnnonce'];
|
||||
|
||||
$detect->parse($annFormat);
|
||||
$situation = $detect->getSituation();
|
||||
|
||||
// Date de radiation
|
||||
if ($situation == 'RP') {
|
||||
$timeline = $detect->getTimeline();
|
||||
$last = end($timeline);
|
||||
$tabRet['dateRad'] = $last->DateStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabRet['SituationJuridique'] = $situation;
|
||||
// Fin Situation Juridique
|
||||
|
||||
// Date de dernière mise à jour
|
||||
if ($annoncesNb > 0) {
|
||||
$annonceLast = end($annoncesList);
|
||||
$tabRet['dateMajANN'] = Metier_Util_Date::dateT('Y-m-d', 'Y-m-d', $annonceLast['dateInsertionSD']);
|
||||
if ($tabRet['dateMajANN'] == '--') {
|
||||
$tabRet['dateMajANN'] = '';
|
||||
}
|
||||
}
|
||||
$timer['getAnnoncesLegales'] = microtime(true);
|
||||
}
|
||||
|
||||
// Date de dernière mise à jour
|
||||
$lastMaj = str_replace('-', '', $tabRet['DateMajINSEE'])*1;
|
||||
if (str_replace('-', '', $tabRet['DateMajRCS'])*1 > $lastMaj) {
|
||||
|
@ -3521,6 +3521,25 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$timer['infosInfogreffes'] = microtime(true);
|
||||
}
|
||||
|
||||
// Si il n'y a aucun établissement actif et qu'on est radié au RCS : on part chercher la dernière annonce de Radiation au Bodacc
|
||||
if ($entrep['dateRadNum'] == 0 && ($nbEtab*1 == 0 || isset($entrep['numGreffe']) && $entrep['actif'] == 0)) {
|
||||
$tabRad = $this->getAnnoncesLegales($siren, 0, 'R');
|
||||
// Il y a au moins une annonce de radiation au Bodacc
|
||||
if (count($tabRad) > 0) {
|
||||
$dateEff = str_replace('-', '', $tabRad[0]['dateEffet'])*1;
|
||||
$dateJug = str_replace('-', '', $tabRad[0]['dateJugement'])*1;
|
||||
$datePar = str_replace('-', '', $tabRad[0]['DateParution'])*1;
|
||||
if ($dateEff > 0) {
|
||||
$tabRet['dateRad'] = $dateEff;
|
||||
} elseif ($dateJug > 0) {
|
||||
$tabRet['dateRad'] = $dateJug;
|
||||
} elseif ($datePar > 0) {
|
||||
$tabRet['dateRad'] = $datePar;
|
||||
}
|
||||
}
|
||||
$timer['infosRadiation'] = microtime(true);
|
||||
}
|
||||
|
||||
// Eléments Financiers en provenance du dernier Bilan
|
||||
try {
|
||||
$stmt = $this->conn->executeQuery("SELECT siren, dateExercice, dureeExercice, monnaie,
|
||||
|
Loading…
Reference in New Issue
Block a user