diff --git a/library/Scores/Finance/Liasse.php b/library/Scores/Finance/Liasse.php index 8bfbf1dbc..0579ef935 100644 --- a/library/Scores/Finance/Liasse.php +++ b/library/Scores/Finance/Liasse.php @@ -103,11 +103,6 @@ class Scores_Finance_Liasse 'BK1' => '049', 'BK2' => 'N04', - 'BL' => '050', - 'BM' => '052', - 'BM1' => '053', - 'BM2' => 'N05', - 'BT' => '060', 'BU' => '062', 'BU1' => '063', @@ -321,7 +316,7 @@ class Scores_Finance_Liasse $bilanRN=array(); foreach ($tabBS2BN as $posteRN => $formule) { if (preg_match('/\+|\-/', $formule)) { - $tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE); + $tabTmp = preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE); //$bilanRN[$posteRN]=0; $scalc=''; foreach ($tabTmp as $i=>$tab) { @@ -341,38 +336,53 @@ class Scores_Finance_Liasse } else $bilanRN[$posteRN]=$bilanRS[$formule]; } - if ( $bilanRS['240']<>0 ) { - $bilanRN['BL']=$bilanRS['050']; - $bilanRN['BM']=$bilanRS['052']; + + //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 { - $bilanRN['BN']=$bilanRS['050']; - $bilanRN['BO']=$bilanRS['052']; + 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 ( $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 ( 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 ( $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']; - } - - if ( $bilanRS['584']<>0 ) { - $bilanRN['HB']=$bilanRS['584']; - $bilanRN['HA']=$bilanRS['290']-$bilanRS['584']; + if ( is_numeric($bilanRS['584']) && $bilanRS['584'] != 0 ) { + $bilanRN['HB'] = $bilanRS['584']; + $bilanRN['HA'] = $bilanRS['290'] - $bilanRS['584']; } else { - $bilanRN['HA']=$bilanRS['290']; + $bilanRN['HA'] = $bilanRS['290']; } - if ( $bilanRS['582']<>0 ) { - $bilanRN['HF']=$bilanRS['582']; - $bilanRN['HE']=$bilanRS['582']-$bilanRS['300']; + if ( is_numeric($bilanRS['582']) && $bilanRS['582'] != 0 ) { + $bilanRN['HF'] = $bilanRS['582']; + $bilanRN['HE'] = $bilanRS['582'] - $bilanRS['300']; } else { - $bilanRN['HE']=$bilanRS['300']; + $bilanRN['HE'] = $bilanRS['300']; } return $bilanRN;