380 lines
8.0 KiB
PHP
Raw Normal View History

2011-07-04 10:00:22 +00:00
<?php
class Scores_Finance_Liasse
2011-07-04 10:00:22 +00:00
{
2011-07-04 10:00:22 +00:00
protected $postes = array();
protected $info = array();
2011-07-08 09:13:28 +00:00
protected $div;
protected $unit = array (
'E' => 1,
'K' => 1000,
'M' => 1000000,
);
2011-07-08 09:13:28 +00:00
public function __construct($liasse, $unit = 'K')
2011-07-04 10:00:22 +00:00
{
2011-07-08 09:13:28 +00:00
$this->div = $this->unit[$unit];
2011-07-04 10:00:22 +00:00
$this->setData($liasse);
}
2011-07-04 10:00:22 +00:00
protected function setData($data)
{
$this->info = array(
'dateFraicheBilan' => $data->DATE_FRAICHE_BILAN,
'dateCloture' => $data->DATE_CLOTURE,
'dateCloturePre' => $data->DATE_CLOTURE_PRE,
'dureeMois' => $data->DUREE_MOIS,
'dureeMoisPre' => $data->DUREE_MOIS_PRE,
'monnaie' => $data->MONNAIE,
'monnaieOri' => $data->MONNAIE_ORI,
'monnaieLivUnite' => $data->MONNAIE_LIV_UNITE,
'consolide' => $data->CONSOLIDE,
'source' => $data->SOURCE,
);
2014-02-13 14:41:39 +00:00
$postesData = array();
foreach ( $data->POSTES->item as $element ) {
$postesData[$element->id] = $element->val;
}
//Transformation Simplifié en Normal
if ( $data->CONSOLIDE == 'S'){
$postesData = $this->bilanSimplifie2Normal($postesData);
}
2011-07-04 10:00:22 +00:00
//Affectaction des postes
2014-02-13 14:41:39 +00:00
foreach ($postesData as $id => $val){
2013-10-04 12:41:24 +00:00
if (in_array($element->id, array(
'YP', 'YP1', '376', // Effectifs 2033 et 2050
'M2G', 'M2H', // Autres effectifs
'ZK', 'ZK1', // Taux
'IJ', 'JG', 'JH', 'JJ', 'ZR', // pour holding/ste mere
2014-02-13 14:41:39 +00:00
'XP' // numero de centre de gestion agréé
2013-10-04 12:41:24 +00:00
)))
{
2014-02-13 14:41:39 +00:00
$this->postes[$id] = number_format($val, 0, '', ' ');
} else {
2014-02-13 14:41:39 +00:00
$this->postes[$id] = $this->dMontant($val);
}
2011-07-08 09:13:28 +00:00
}
2011-07-04 10:00:22 +00:00
}
public function getInfo($key)
{
return $this->info[$key];
}
2011-07-04 10:00:22 +00:00
public function getPostes()
{
return $this->postes;
}
2011-07-08 09:13:28 +00:00
protected function dMontant($montant)
{
2013-05-15 07:29:13 +00:00
return number_format($montant/$this->div, 0, '', ' ');
2011-07-08 09:13:28 +00:00
}
function bilanSimplifie2Normal($bilanRS)
{
$tabBS2BN = array(
2014-03-14 10:42:09 +00:00
//2033 ACTIF PASSIF
'AH' => '010',
'AI' => '012',
'AI1' => '013',
'AI2' => 'N00',
2013-10-04 12:41:24 +00:00
2014-03-14 10:42:09 +00:00
'AJ' => '014',
'AK' => '016',
'AK1' => '017',
'AK2' => 'N01',
2013-10-04 12:41:24 +00:00
2014-03-14 10:42:09 +00:00
'AT' => '028',
'AU' => '030',
'AU1' => '031',
'AU2' => 'N02',
'BH' => '040',
'BI' => '042',
'BI1' => '043',
'BI2' => 'N03',
'BJ' => '044',
'BK' => '048',
'BK1' => '049',
'BK2' => 'N04',
'BL' => '050',
'BM' => '052',
'BM1' => '053',
'BM2' => 'N05',
'BT' => '060',
'BU' => '062',
'BU1' => '063',
'BU2' => 'N06',
'BV' => '064',
'BW' => '066',
'BW1' => '067',
'BW2' => 'N07',
'BX' => '068',
'BY' => '070',
'BY1' => '071',
'BY2' => 'N08',
'BZ' => '072',
'CA' => '074',
'CA1' => '075',
'CA2' => 'N09',
'CD' => '080',
'CE' => '082',
'CE1' => '083',
'CE2' => 'N10',
'CF' => '084',
'CG' => '086',
'CG1' => '087',
'CG2' => 'N11',
'CH' => '092',
'CI' => '094',
'CI1' => '095',
'CI2' => 'N13',
'CJ' => '096',
'CK' => '098',
'CK1' => '099',
'CK2' => 'N14',
'CO' => '110',
'1A' => '112',
'1A1' => '113',
'1A2' => 'N15',
'DA' => '120',
'DA1' => 'N16',
'DC' => '124',
'DC1' => 'N17',
2014-03-14 10:42:09 +00:00
'DD' => '126',
'DD1' => 'N18',
2014-03-14 10:42:09 +00:00
'DF' => '130',
'DF1' => 'N19',
2014-03-14 10:42:09 +00:00
'DG' => '132',
'DG1' => 'N20',
2014-03-14 10:42:09 +00:00
'DH' => '134',
'DH1' => 'N21',
2014-03-14 10:42:09 +00:00
'DI' => '136',
'DI1' => 'N22',
2014-03-14 10:42:09 +00:00
'DK' => '140',
'DK1' => 'N23',
2014-03-14 10:42:09 +00:00
'DL' => '142',
'DL1' => 'N24',
2014-03-14 10:42:09 +00:00
'DR' => '154',
'DR1' => 'N25',
2014-03-14 10:42:09 +00:00
'DU' => '156',
'DU1' => 'N26',
2014-03-14 10:42:09 +00:00
'DW' => '164',
'DW1' => 'N27',
2014-03-14 10:42:09 +00:00
'DX' => '166',
'DX1' => 'N28',
2014-03-14 10:42:09 +00:00
'EA' => '172',
'EA1' => 'N29',
2014-03-14 10:42:09 +00:00
'EB' => '174',
'EB1' => 'N30',
2014-03-14 10:42:09 +00:00
'EC' => '176',
'EC1' => 'N31',
2014-03-14 10:42:09 +00:00
'EE' => '180',
'EE1' => 'N32',
2014-03-14 10:42:09 +00:00
'EH' => '156-195',
//2033 CDR
'FA' => '210-209',
'FB' => '209',
'FC' => '210',
'FC1' => 'N33',
2014-03-14 10:42:09 +00:00
'FD' => '214-215',
'FE' => '215',
'FF' => '214',
'FF1' => 'N34',
2014-03-14 10:42:09 +00:00
'FG' => '218-217',
2014-03-14 10:42:09 +00:00
'FH' => '217',
'FI' => '218',
'FI1' => 'N35',
2014-03-14 10:42:09 +00:00
'FJ' => '210+214+218-209-215-217',
2014-03-14 10:42:09 +00:00
'FK' => '209+215+217',
'FL' => '210+214+218',
'FL1' => 'N33+N34+N35',
'FM' => '222',
'FM1' => 'N36',
2014-03-14 10:42:09 +00:00
'FN' => '224',
'FN1' => 'N37',
2014-03-14 10:42:09 +00:00
'FO' => '226',
'FO1' => 'N38',
2014-03-14 10:42:09 +00:00
'FQ' => '230',
'FQ1' => 'N39',
2014-03-14 10:42:09 +00:00
'FR' => '232',
'FR1' => 'N40',
2014-03-14 10:42:09 +00:00
'FS' => '234',
'FS1' => 'N41',
2014-03-14 10:42:09 +00:00
'FT' => '236',
'FT1' => 'N42',
2014-03-14 10:42:09 +00:00
'FU' => '238',
'FU1' => 'N43',
2014-03-14 10:42:09 +00:00
'FV' => '240',
'FV1' => 'N44',
2014-03-14 10:42:09 +00:00
'FW' => '242',
'FW1' => 'N45',
2014-03-14 10:42:09 +00:00
'FX' => '244',
'FX1' => 'N46',
2014-03-14 10:42:09 +00:00
'FY' => '250',
'FY1' => 'N47',
2014-03-14 10:42:09 +00:00
'FZ' => '252',
'FZ1' => 'N48',
2014-03-14 10:42:09 +00:00
'GA' => '254',
'GA1' => 'N49',
2014-03-14 10:42:09 +00:00
'GE' => '262',
'GE1' => 'N51',
2014-03-14 10:42:09 +00:00
'GF' => '264',
'GF1' => 'N52',
2014-03-14 10:42:09 +00:00
'GG' => '270',
'GG1' => 'N53',
2014-03-14 10:42:09 +00:00
'GP' => '280',
'GP1' => 'N54',
2014-03-14 10:42:09 +00:00
'GU' => '294',
'GU1' => 'N56',
2014-03-14 10:42:09 +00:00
'GV' => '280-294', //GP-GU
'GV1' => 'N54-N56', //GP1-GU1
'GW' => '270+280+294', //GG+GH-GI+GV ???
2014-03-14 10:42:09 +00:00
'GW1' => 'N53+N54+N56',
'HD' => '290',
'HD1' => 'N55',
2014-03-14 10:42:09 +00:00
'HH' => '300',
'HH1' => 'N57',
2014-03-14 10:42:09 +00:00
'HI' => '290-300',
'HI1' => 'N55-N57',
2014-03-14 10:42:09 +00:00
'HK' => '306',
'HK1' => 'N58',
2014-03-14 10:42:09 +00:00
'HL' => '232+280+290',
'HL1' => 'N40+N54+N55',
2014-03-14 10:42:09 +00:00
'HM' => '264+294+300+306',
'HM1' => 'N52+N56+N57+N58',
2014-03-14 10:42:09 +00:00
'HN' => '310',
'HN1' => 'N59',
2014-03-14 10:42:09 +00:00
'YY' => '374',
'YZ' => '378',
'YP' => '376',
);
$bilanRN=array();
foreach ($tabBS2BN as $posteRN => $formule) {
if (preg_match('/\+|\-/', $formule)) {
$tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE);
//$bilanRN[$posteRN]=0;
$scalc='';
foreach ($tabTmp as $i=>$tab) {
if ($i==0) {
$bilanRN[$posteRN]=$bilanRS[$tab[0]];
$scalc.=$bilanRS[$tab[0]];
}
else {
$signe=$formule[$tab[1]-1];
$scalc.=$signe;
if ($signe=='+') $bilanRN[$posteRN]+=$bilanRS[$tab[0]];
elseif ($signe=='-') $bilanRN[$posteRN]-=$bilanRS[$tab[0]];
$scalc.=$bilanRS[$tab[0]];
}
}
$bilanRN[$posteRN]=$bilanRN[$posteRN];
}
else $bilanRN[$posteRN]=$bilanRS[$formule];
}
2014-03-14 10:42:09 +00:00
if ( $bilanRS['240']<>0 ) {
$bilanRN['BL']=$bilanRS['050'];
$bilanRN['BM']=$bilanRS['052'];
} else {
$bilanRN['BN']=$bilanRS['050'];
$bilanRN['BO']=$bilanRS['052'];
}
2014-03-14 10:42:09 +00:00
if ( $bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0 ) {
$bilanRN['GC']=$bilanRS['256'];
} elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0 ) {
$bilanRN['GD']=$bilanRS['256'];
}
if ( $bilanRS['071']<>0 || $bilanRS['075']<>0 || $bilanRS['053']<>0 || $bilanRS['063']<>0 ) {
$bilanRN['GC1']=$bilanRS['N50'];
} elseif ($bilanRS['071']==0 || $bilanRS['075']==0 || $bilanRS['053']==0 || $bilanRS['063']==0 && $bilanRS['N49']<>0 ) {
$bilanRN['GD1']=$bilanRS['N50'];
}
2014-03-14 10:42:09 +00:00
if ( $bilanRS['584']<>0 ) {
$bilanRN['HB']=$bilanRS['584'];
$bilanRN['HA']=$bilanRS['290']-$bilanRS['584'];
2014-03-14 10:42:09 +00:00
} else {
$bilanRN['HA']=$bilanRS['290'];
}
2014-03-14 10:42:09 +00:00
if ( $bilanRS['582']<>0 ) {
$bilanRN['HF']=$bilanRS['582'];
$bilanRN['HE']=$bilanRS['582']-$bilanRS['300'];
2014-03-14 10:42:09 +00:00
} else {
$bilanRN['HE']=$bilanRS['300'];
}
return $bilanRN;
}
2011-07-04 10:00:22 +00:00
}