Fix Bug : Prévision , erreur si on soustrait un montant négatif

This commit is contained in:
Dany wm De Bontridder 2021-08-13 19:27:24 +02:00
parent 7e402e6720
commit 7dfe35c8e8
2 changed files with 7 additions and 4 deletions

View file

@ -107,7 +107,7 @@ class Impress
$amount=\Impress::compute_amount($p_cn,$line,$cond." ".$p_sql,$cond_anc." ".$p_sql);
$p_formula=str_replace($x[0], $amount, $p_formula);
$p_formula=str_replace($x[0],"--(". $amount.")", $p_formula);
}
}
@ -119,9 +119,11 @@ class Impress
*/
$p_formula=remove_divide_zero($p_formula);
$p_formula="\$result=".$p_formula.";";
eval("$p_formula");
try {
eval("$p_formula");
} catch(Exception $e) {
return array("desc"=>"erreur","montant"=>'0');
}
while (preg_match("/\[([0-9]+)(-[Tt]*)\]/", trim($p_label), $e)==1)
{
$nom="!!".$e[1]."!!";

View file

@ -247,6 +247,7 @@ class ImpressTest extends TestCase
array("sum FOURNI1 Débit", "{FOURNI1-d}",221.43),
array("sum FOURNI1 Débit", "{NOTEXIST-d}",0),
array("sum FOURNI1 Débit", "{{NOTEXIST-d}}",0),
array("Double minus sign throw an error ParseError: syntax error, unexpected '--' (T_DEC) ", "[6%-S]-[6%-S]",0),
);
// ------ Periode ----------
foreach ($a_formula as $formula)