backoffice/includes/common/ICotation.inc
2011-06-21 13:28:10 +00:00

302 lines
10 KiB
PHP
Raw Permalink Blame History

<?php
class ICotation {
var $reTrtAuto;
var $tabBilan;
var $tabNotation;
var $tabLibActivite;
var $tabActivite;
var $tabR;
function ICotation ($tabBilan, $retraitementAutomatique=true) {
$this->reTrtAuto = $retraitementAutomatique;
$this->tabBilan = $tabBilan;
include ('paramCotation.inc');
}
function calculProvisionsPourRisque () {
if ( !$this->reTrtAuto )
return $this->tabBilan['DP'] + $this->tabBilan['DQ'] - $this->tabBilan['X04'];
else
return (1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']);
}
function calculEBE () {
return $this->tabBilan['FC'] + $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FOB']
+ $this->tabBilan['FM'] + $this->tabBilan['FN'] - $this->tabBilan['FC'] + $this->tabBilan['FC']
- ( $this->tabBilan['FS'] + $this->tabBilan['FT'] + $this->tabBilan['FU'] + $this->tabBilan['FV'] )
- ( $this->tabBilan['FW'] - $this->tabBilan['HP'] - $this->tabBilan['HQ'] - $this->tabBilan['HP2'] - $this->tabBilan['HQ2'] )
- $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) + ( $this->tabBilan['FO'] - $this->tabBilan['FOB'] ) ;
}
function calculChiffreAffaires () {
return $this->tabBilan['FC']
+ $this->tabBilan['FF']
+ $this->tabBilan['FI']
+ $this->tabBilan['FO']
- $this->tabBilan['FOB'] ;
}
function calculMargeCommerciale () {
return $this->tabBilan['FC'] - ( $this->tabBilan['FS'] + $this->tabBilan['FT'] ) ;
}
function calculProduction () {
return $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FM'] + $this->tabBilan['FN'] ;
}
function calculValeurAjoutee () {
return $this->calculMargeCommerciale() + $this->calculProduction()
- ( $this->tabBilan['FU'] + $this->tabBilan['FV'] + $this->tabBilan['FW'] ) ;
}
function calculEBEnonCASA () {
return $this->calculValeurAjoutee() + $this->tabBilan['FO'] - $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) ;
}
function calculFondsPropresNetsCorriges() {
return $this->tabBilan['DA'] + $this->tabBilan['DC'] + $this->tabBilan['DB'] + $this->tabBilan['DD'] + $this->tabBilan['DE'] + $this->tabBilan['DF'] + $this->tabBilan['DG'] + $this->tabBilan['DK'] - (1/3*$this->tabBilan['X01'])
+ $this->tabBilan['DH'] + $this->tabBilan['DI'] + $this->tabBilan['DJ']
- $this->tabBilan['CL'] - $this->tabBilan['AB'] + $this->tabBilan['AC'] - $this->tabBilan['AA'] - $this->tabBilan['CB'] + $this->tabBilan['CC'] - $this->tabBilan['X02'] - $this->tabBilan['CM'] - $this->tabBilan['CN']
+ $this->tabBilan['DM'] + $this->tabBilan['DN']
- $this->tabBilan['X03'] + $this->calculProvisionsPourRisque() - $this->tabBilan['RAD'] ;
}
function calculDettesFinancieresBancairesBrutes () {
return $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2']
+ $this->tabBilan['DT'] - $this->tabBilan['CM3'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
+ (3/4*$this->tabBilan['YQ']) + (2/3*$this->tabBilan['YR'])
+ (3/4*$this->tabBilan['YQ2']) + (2/3*$this->tabBilan['YR2'])
+ $this->tabBilan['DV'] - $this->tabBilan['EI'] - $this->tabBilan['DVI1'] - $this->tabBilan['CM2']
+ $this->tabBilan['YS'] + $this->tabBilan['X08']
+ $this->tabBilan['EH'] + $this->tabBilan['VI1'] - ( $this->tabBilan['X20'] + $this->tabBilan['X21'] ) ;
}
function noteCapitalisation () {
if ( !$this->reTrtAuto ) {
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + $this->tabBilan['X04'] ;
$dettesFiscalesSociales = $this->tabBilan['DY'] - $this->tabBilan['DYA'];
} else {
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + 2/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']));
$dettesFiscalesSociales = $this->tabBilan['DY'] + 1/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ'])) - $this->tabBilan['DYA'] ;
}
$numerateur = $this->calculFondsPropresNetsCorriges();
$denominateur = $numerateur + $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
+ $this->tabBilan['DV'] - $this->tabBilan['DVI1'] - $this->tabBilan['EI'] + $this->tabBilan['DT'] - $this->tabBilan['CM3'] + 3/4*$this->tabBilan['YQ'] + 2/3*$this->tabBilan['YR']
+ 3/4*$this->tabBilan['YQ2'] + 2/3*$this->tabBilan['YR2']
+ $this->tabBilan['DW'] + $this->tabBilan['DX'] + $dettesFiscalesSociales
+ $autresDettesExploit + $this->tabBilan['DZ'] + $this->tabBilan['DIA'] + $this->tabBilan['ED'] + $this->tabBilan['EAB'] + $this->tabBilan['DYA']
+ $this->tabBilan['EH'] + $this->tabBilan['YS'] + $this->tabBilan['VI1'];
// + $this->tabBilan['X08']
// - $this->tabBilan['X20'] + $this->tabBilan['YS'] - $this->tabBilan['X08'];
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur* 100,'DENOMINATEUR'=>$denominateur,'NOTE'=>($numerateur* 100)/$denominateur);
}
function noteLevierEndettement () {
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
$denominateur = $this->calculFondsPropresNetsCorriges();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteCapaciteRemboursement () {
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
$denominateur = $this->calculEBE();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteCouvChargesFi () {
$numerateur = $this->calculEBE();
$denominateur = $this->tabBilan['GR'] + ( 1/4*$this->tabBilan['HP'] + 1/3*$this->tabBilan['HQ'] )
+ ( 1/4*$this->tabBilan['HP2'] + 1/3*$this->tabBilan['HQ2'] )
+ $this->tabBilan['GS']
+ $this->tabBilan['GT']
- $this->tabBilan['GJ']
- $this->tabBilan['GK']
- $this->tabBilan['GL']
- $this->tabBilan['GN']
- $this->tabBilan['GO']
- $this->tabBilan['GH']
+ $this->tabBilan['GI'] ;
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
}
function noteTresorerie () {
$numerateur = $this->tabBilan['CD'] - $this->tabBilan['CE'] + $this->tabBilan['CF'] - $this->tabBilan['CG']
- $this->tabBilan['EH'] - ( $this->tabBilan['YS'] + $this->tabBilan['X08'] ) ;
$denominateur = $this->calculChiffreAffaires();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*360/$denominateur);
}
function noteMargeExploitation () {
$numerateur = $this->calculEBE();
$denominateur = $this->calculChiffreAffaires();
if ($denominateur==0)
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*100/$denominateur);
}
function getSecteurActivite($naf) {
$nbSecteurs=count($this->tabActivite);
while (strlen($naf) > 1)
{
for ($i=1; $i<$nbSecteurs; $i++)
{
for ($j=0; isset($this->tabActivite[$i][$j]); $j++)
{
if ($this->tabActivite[$i][$j]==$naf)
// echo 'NAF '.$naf.' TROUV<55> !<br>';
return $i;
}
}
// echo 'NAF '.$naf.' non trouv<75> !<br>';
$naf=substr($naf,0,strlen($naf)-1);
}
return 17; // Secteur d'activit<69> par d<>faut si non trouv<75>
}
function getBorne($note, $borne, $secteur) {
// print_array($this->tabR[$borne][$secteur],0);
for ($j=0; $j<10; $j++)
{
$tabMinMax=explode(':',$this->tabR[$borne][$secteur][$j]);
if ($tabMinMax[0]!='') $min=$tabMinMax[0];
else $min=-1E99;
if ($tabMinMax[1]!='') $max=$tabMinMax[1];
else $max=1E99;
if ( ( $note>$min && $note<=$max ) )
{
// echo "TROUVE ++++ $note > ".$tabMinMax[0]." et $note <= ". $tabMinMax[1].'<br/>';
if ($j==0) return 3;
elseif ($j<4) return $j+4;
else return $j*2+1;
}
// echo "NOK $note < ".$tabMinMax[0]." ou $note > ". $tabMinMax[1].'<br/>';
}
return 3; // On retourne la plus basse note par d<>faut
}
function getNoteBorne($note, $borne, $secteur, $numerateur, $denominateur) {
$noteBorneBrute=$this->getBorne($note, $borne, $secteur);
switch($borne)
{
case 1:
if ($numerateur<0) return 3;
else return $noteBorneBrute;
break;
case 2:
if ($numerateur==0) return 19;
else return $noteBorneBrute;
break;
case 3:
if ($numerateur==0 && $denominateur>0) return 19;
elseif ($denominateur<0) return 3;
else return $noteBorneBrute;
break;
case 4:
if ($note<0) return 19;
else return $noteBorneBrute;
break;
default:
return $noteBorneBrute;
break;
}
}
function getNotationFin ($coteMoy) {
if( $coteMoy > 18.5 )
return 'A';
elseif( $coteMoy > 16 )
return 'B+';
elseif( $coteMoy > 14 )
return 'B';
elseif( $coteMoy > 12.5 )
return 'C+';
elseif( $coteMoy > 11 )
return 'C';
elseif( $coteMoy > 10 )
return 'C-';
elseif( $coteMoy > 9 )
return 'D+';
elseif( $coteMoy > 8 )
return 'D';
elseif( $coteMoy > 7 )
return 'D-';
elseif( $coteMoy > 6 )
return 'E+';
elseif( $coteMoy > 4.5 )
return 'E';
elseif( $coteMoy > 3 )
return 'E-';
else
return 'E--';
}
function getInfosNotation ($notation, $csv=false) {
if ($csv) {
$str =$this->tabNotation[$notation][1].';'.
$this->tabNotation[$notation][2].';'.
$this->tabNotation[$notation][3].';'.
$this->tabNotation[$notation][4].';';
return $str;
} else {
$str ='Notation : '. $this->tabNotation[$notation][0]."\r\n";
$str.='Equivalence BDF : '. $this->tabNotation[$notation][1]."\r\n";
$str.='Grades Moody\'s : '. $this->tabNotation[$notation][2]."\r\n";
$str.='Grades S&P : '. $this->tabNotation[$notation][3]."\r\n";
$str.='Probabilit<69> de d<>faillance : '. $this->tabNotation[$notation][4]." %\r\n";
return $str;
}
}
}