390 lines
8.3 KiB
PHP
390 lines
8.3 KiB
PHP
<?php
|
|
class Scores_Finance_Liasse
|
|
{
|
|
|
|
protected $postes = array();
|
|
protected $info = array();
|
|
protected $div;
|
|
protected $unit = array (
|
|
'E' => 1,
|
|
'K' => 1000,
|
|
'M' => 1000000,
|
|
);
|
|
|
|
public function __construct($liasse, $unit = 'K')
|
|
{
|
|
$this->div = $this->unit[$unit];
|
|
$this->setData($liasse);
|
|
}
|
|
|
|
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,
|
|
);
|
|
|
|
$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);
|
|
}
|
|
|
|
//Affectaction des postes
|
|
foreach ($postesData as $id => $val){
|
|
if (in_array($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
|
|
'XP' // numero de centre de gestion agréé
|
|
)))
|
|
{
|
|
$this->postes[$id] = number_format($val, 0, '', ' ');
|
|
} else {
|
|
$this->postes[$id] = $this->dMontant($val);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getInfo($key)
|
|
{
|
|
return $this->info[$key];
|
|
}
|
|
|
|
public function getPostes()
|
|
{
|
|
return $this->postes;
|
|
}
|
|
|
|
protected function dMontant($montant)
|
|
{
|
|
return number_format($montant/$this->div, 0, '', ' ');
|
|
}
|
|
|
|
function bilanSimplifie2Normal($bilanRS)
|
|
{
|
|
$tabBS2BN = array(
|
|
//2033 ACTIF PASSIF
|
|
'AH' => '010',
|
|
'AI' => '012',
|
|
'AI1' => '013',
|
|
'AI2' => 'N00',
|
|
|
|
'AJ' => '014',
|
|
'AK' => '016',
|
|
'AK1' => '017',
|
|
'AK2' => 'N01',
|
|
|
|
'AT' => '028',
|
|
'AU' => '030',
|
|
'AU1' => '031',
|
|
'AU2' => 'N02',
|
|
|
|
'BH' => '040',
|
|
'BI' => '042',
|
|
'BI1' => '043',
|
|
'BI2' => 'N03',
|
|
|
|
'BJ' => '044',
|
|
'BK' => '048',
|
|
'BK1' => '049',
|
|
'BK2' => 'N04',
|
|
|
|
'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',
|
|
|
|
'DD' => '126',
|
|
'DD1' => 'N18',
|
|
|
|
'DF' => '130',
|
|
'DF1' => 'N19',
|
|
|
|
'DG' => '132',
|
|
'DG1' => 'N20',
|
|
|
|
'DH' => '134',
|
|
'DH1' => 'N21',
|
|
|
|
'DI' => '136',
|
|
'DI1' => 'N22',
|
|
|
|
'DK' => '140',
|
|
'DK1' => 'N23',
|
|
|
|
'DL' => '142',
|
|
'DL1' => 'N24',
|
|
|
|
'DR' => '154',
|
|
'DR1' => 'N25',
|
|
|
|
'DU' => '156',
|
|
'DU1' => 'N26',
|
|
|
|
'DW' => '164',
|
|
'DW1' => 'N27',
|
|
|
|
'DX' => '166',
|
|
'DX1' => 'N28',
|
|
|
|
'EA' => '172',
|
|
'EA1' => 'N29',
|
|
|
|
'EB' => '174',
|
|
'EB1' => 'N30',
|
|
|
|
'EC' => '176',
|
|
'EC1' => 'N31',
|
|
|
|
'EE' => '180',
|
|
'EE1' => 'N32',
|
|
|
|
'EH' => '156-195',
|
|
|
|
//2033 CDR
|
|
'FA' => '210-209',
|
|
'FB' => '209',
|
|
'FC' => '210',
|
|
'FC1' => 'N33',
|
|
|
|
'FD' => '214-215',
|
|
'FE' => '215',
|
|
'FF' => '214',
|
|
'FF1' => 'N34',
|
|
|
|
'FG' => '218-217',
|
|
'FH' => '217',
|
|
'FI' => '218',
|
|
'FI1' => 'N35',
|
|
|
|
'FJ' => '210+214+218-209-215-217',
|
|
'FK' => '209+215+217',
|
|
'FL' => '210+214+218',
|
|
'FL1' => 'N33+N34+N35',
|
|
|
|
'FM' => '222',
|
|
'FM1' => 'N36',
|
|
|
|
'FN' => '224',
|
|
'FN1' => 'N37',
|
|
|
|
'FO' => '226',
|
|
'FO1' => 'N38',
|
|
|
|
'FQ' => '230',
|
|
'FQ1' => 'N39',
|
|
|
|
'FR' => '232',
|
|
'FR1' => 'N40',
|
|
|
|
'FS' => '234',
|
|
'FS1' => 'N41',
|
|
|
|
'FT' => '236',
|
|
'FT1' => 'N42',
|
|
|
|
'FU' => '238',
|
|
'FU1' => 'N43',
|
|
|
|
'FV' => '240',
|
|
'FV1' => 'N44',
|
|
|
|
'FW' => '242',
|
|
'FW1' => 'N45',
|
|
|
|
'FX' => '244',
|
|
'FX1' => 'N46',
|
|
|
|
'FY' => '250',
|
|
'FY1' => 'N47',
|
|
|
|
'FZ' => '252',
|
|
'FZ1' => 'N48',
|
|
|
|
'GA' => '254',
|
|
'GA1' => 'N49',
|
|
|
|
'GE' => '262',
|
|
'GE1' => 'N51',
|
|
|
|
'GF' => '264',
|
|
'GF1' => 'N52',
|
|
|
|
'GG' => '270',
|
|
'GG1' => 'N53',
|
|
|
|
'GP' => '280',
|
|
'GP1' => 'N54',
|
|
|
|
'GU' => '294',
|
|
'GU1' => 'N56',
|
|
|
|
'GV' => '280-294', //GP-GU
|
|
'GV1' => 'N54-N56', //GP1-GU1
|
|
|
|
'GW' => '270+280-294', //GG+GH-GI+GV ???
|
|
'GW1' => 'N53+N54-N56',
|
|
|
|
'HD' => '290',
|
|
'HD1' => 'N55',
|
|
|
|
'HH' => '300',
|
|
'HH1' => 'N57',
|
|
|
|
'HI' => '290-300',
|
|
'HI1' => 'N55-N57',
|
|
|
|
'HK' => '306',
|
|
'HK1' => 'N58',
|
|
|
|
'HL' => '232+280+290',
|
|
'HL1' => 'N40+N54+N55',
|
|
|
|
'HM' => '264+294+300+306',
|
|
'HM1' => 'N52+N56+N57+N58',
|
|
|
|
'HN' => '310',
|
|
'HN1' => 'N59',
|
|
|
|
'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];
|
|
}
|
|
|
|
//Variation de stock (matières premières et approvisionnement)
|
|
if ( is_numeric($bilanRS['240']) && $bilanRS['240'] != 0 ) {
|
|
$bilanRN['BL'] = $bilanRS['050'];
|
|
$bilanRN['BM'] = $bilanRS['052'];
|
|
$bilanRN['BM1'] = $bilanRS['053'];
|
|
$bilanRN['BM2'] = $bilanRS['N05'];
|
|
unset($bilanRN['BN']);
|
|
unset($bilanRN['BO']);
|
|
unset($bilanRN['BO1']);
|
|
unset($bilanRN['BO2']);
|
|
} else {
|
|
unset($bilanRN['BL']);
|
|
unset($bilanRN['BM']);
|
|
unset($bilanRN['BM1']);
|
|
unset($bilanRN['BM2']);
|
|
$bilanRN['BN'] = $bilanRS['050'];
|
|
$bilanRN['BO'] = $bilanRS['052'];
|
|
$bilanRN['BO1'] = $bilanRS['053'];
|
|
$bilanRN['BO2'] = $bilanRS['N05'];
|
|
}
|
|
|
|
if ( is_numeric($bilanRS['070']) && $bilanRS['070'] != 0
|
|
|| is_numeric($bilanRS['074']) && $bilanRS['074'] != 0
|
|
|| is_numeric($bilanRS['052']) && $bilanRS['052'] != 0
|
|
|| is_numeric($bilanRS['062']) && $bilanRS['062'] != 0 ) {
|
|
$bilanRN['GC'] = $bilanRS['256'];
|
|
} elseif ( $bilanRS['070'] == 0
|
|
&& $bilanRS['074'] == 0
|
|
&& $bilanRS['052'] == 0
|
|
&& $bilanRS['062'] == 0
|
|
&& intval($bilanRS['254']) > 0 ) {
|
|
$bilanRN['GD'] = $bilanRS['256'];
|
|
}
|
|
|
|
if ( is_numeric($bilanRS['584']) && $bilanRS['584'] != 0 ) {
|
|
$bilanRN['HB'] = $bilanRS['584'];
|
|
$bilanRN['HA'] = $bilanRS['290'] - $bilanRS['584'];
|
|
} else {
|
|
$bilanRN['HA'] = $bilanRS['290'];
|
|
}
|
|
|
|
if ( is_numeric($bilanRS['582']) && $bilanRS['582'] != 0 ) {
|
|
$bilanRN['HF'] = $bilanRS['582'];
|
|
$bilanRN['HE'] = $bilanRS['582'] - $bilanRS['300'];
|
|
} else {
|
|
$bilanRN['HE'] = $bilanRS['300'];
|
|
}
|
|
|
|
return $bilanRN;
|
|
}
|
|
} |