Bug : Bank , no warning if balance incorrect when the first amount is 0

Protect $_REQUEST , do no replace the first amount when it is corrected
This commit is contained in:
sparkyx 2021-02-24 13:37:19 +01:00
parent faaeb16c05
commit aab7567c69
2 changed files with 25 additions and 14 deletions

View file

@ -218,16 +218,23 @@ class Acc_Ledger_Fin extends Acc_Ledger
throw new Exception('Il n\'y a aucune opération', 12);
/* Check if the last_saldo and first_saldo are correct */
if (strlen(trim($last_sold)) != 0 && isNumber($last_sold) &&
strlen(trim($first_sold)) != 0 && isNumber($first_sold))
if (strlen(trim($last_sold)) != 0
&& isNumber($last_sold)
&& strlen(trim($first_sold)) != 0
&& isNumber($first_sold)
)
{
$diff = $last_sold - $first_sold;
$diff = round($diff, 2) - round($tot_amount, 2);
if ($first_sold != 0 && $last_sold != 0)
$calc=bcadd($first_sold,$tot_amount,4);
if ($first_sold != 0 || $last_sold != 0)
{
if ($diff != 0)
throw new Exception('Le montant de l\'extrait est incorrect' .
$tot_amount . ' extrait ' . $diff, 13);
if ($diff != 0) {
throw new Exception(sprintf( _('Le montant de l\'extrait [%s] est incorrect,'.
" solde calculé [%s] , différence de [%s]") ,
$last_sold,$calc,$diff),13);
}
}
}
}