From aab7567c6905198b4da2fcec5b17ed60aa690ae2 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 24 Feb 2021 13:37:19 +0100 Subject: [PATCH] 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 --- include/class/acc_ledger_fin.class.php | 19 +++++++++++++------ include/compta_fin.inc.php | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index de48fcb16..1aea14b4b 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -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); + + } } } } diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 5a60d628a..c9730f8e1 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -28,10 +28,10 @@ require_once NOALYSS_INCLUDE.'/lib/ipopup.class.php'; global $g_user,$g_parameter; $gDossier=dossier::id(); - +$http=new HttpInput(); $cn=Dossier::connect(); -$menu_action="?ledger_type=fin&ac=".$_REQUEST['ac']."&".dossier::get(); +$menu_action="?ledger_type=fin&ac=".$http->request('ac')."&".dossier::get(); $Ledger=new Acc_Ledger_Fin($cn,0); @@ -40,7 +40,9 @@ $Ledger=new Acc_Ledger_Fin($cn,0); //-------------------------------------------------------------------------------- if ( isset($_REQUEST['p_jrn'])) - $Ledger->id=$_REQUEST['p_jrn']; +{ + $Ledger->id=$http->request('p_jrn',"number"); +} else { $def_ledger=$Ledger->get_first('fin'); @@ -137,7 +139,7 @@ if ( $p_msg !="" ) echo ''.$p_msg.''; echo '
'; echo HtmlInput::hidden('ledger_type','fin'); -echo HtmlInput::hidden('ac',$_REQUEST['ac']); +echo HtmlInput::hidden('ac',$http->request("ac")); $array=( isset($correct))?$_POST:null; // show select ledger @@ -149,13 +151,15 @@ try echo HtmlInput::submit('save',_('Sauve')); echo HtmlInput::reset(_('Effacer')); + $script="update_name();"; if ( ! isset($_REQUEST['e_date'])&& $g_parameter->MY_DATE_SUGGEST=='Y') { - echo create_script(" get_last_date();ajax_saldo('first_sold');"); - }else { - echo create_script(" ajax_saldo('first_sold');"); + $script.=" get_last_date();"; } - echo create_script(" update_name()"); + if ( ! isset ($_REQUEST['first_sold']) ) { + $script.=" ajax_saldo('first_sold');"; + } + echo create_script($script); } catch (Exception $ex) { echo $ex->getMessage(); }