'._('Vérification des journaux').'
'; -$sql="select jrn_def_id,jrn_def_name from jrn_def"; +$sql=" + with jdebit as ( + select sum (j_montant) as amount,j_debit , jr_def_id + from jrnx join jrn on (j_grpt=jr_grpt_id) + where + $sql_year + and + j_debit='t' + group by jr_def_id,j_debit + ), +jcredit as ( + select sum (j_montant) as amount,j_debit , jr_def_id + from jrnx join jrn on (j_grpt=jr_grpt_id) + where + $sql_year + and + j_debit='f' + group by jr_def_id,j_debit + ) +select jrn_def_id, + jrn_def_name, + jdebit.amount as deb, + jcredit.amount as cred + from jrn_def +join jdebit on (Jdebit.jr_def_id=jrn_def.jrn_def_id) +join jcredit on (jcredit.jr_def_id=jrn_def.jrn_def_id) +where jcredit.amount<>jdebit.amount +order by jrn_def_name + "; $res=$cn->exec_sql($sql); $jrn=Database::fetch_all($res); + +$nb_jrn= count($jrn); +if ( $jrn ===false ) { + echo $g_succeed." "._("Aucune anomalie dans les montants des journaux"); +} echo ''; echo '
'._('Vérification des comptes').'
'; +$t2=microtime(true); $bilan=new Acc_Bilan($cn); $periode=new Periode($cn); list ($start_periode,$end_periode)=$periode->get_limit($exercice); @@ -88,7 +119,7 @@ $bilan->from=$start_periode->p_id; $bilan->to=$end_periode->p_id; $bilan->verify(); echo '
@@ -99,6 +130,7 @@ echo '
';
get_exercice()."')";
$sql_fiche_id="
@@ -115,7 +147,7 @@ having count(*) > 1
$a_fiche_id=$cn->get_array($sql_fiche_id);
- $sql_poste="select distinct j_poste,pcm_lib from jrnx join tmp_pcmn on (pcm_val=j_poste) where f_id =$1 $sql_year";
+ $sql_poste="select distinct j_poste,pcm_lib from jrnx join tmp_pcmn on (pcm_val=j_poste) where f_id =$1 and $sql_year";
$sql_qcode="select ad_value as qcode from fiche_detail where f_id=$1 and ad_id=".ATTR_DEF_QUICKCODE;
$res=$cn->prepare('get_poste',$sql_poste);
$resQcode=$cn->prepare('get_qcode',$sql_qcode);
@@ -153,6 +185,7 @@ having count(*) > 1
@@ -171,7 +204,7 @@ $sql_account_used="
join vw_fiche_attr as v_attr on (vw.f_id=v_attr.f_id)
join jrn on (jrnx.j_grpt=jrn.jr_grpt_id)
where
- jrnx.f_id is null $sql_year order by 1
+ jrnx.f_id is null and $sql_year order by 1
";
$sql_concerned_operation="select vw.f_id,jrnx.j_date,jrnx.j_id,jrn.jr_id,jrnx.j_poste,jr_internal ,jr_comment
@@ -179,7 +212,7 @@ $sql_concerned_operation="select vw.f_id,jrnx.j_date,jrnx.j_id,jrn.jr_id,jrnx.j_
join jrnx using (j_poste)
join jrn on (jrnx.j_grpt=jrn.jr_grpt_id)
where
- jrnx.f_id is null and vw.f_id= $1 $sql_year";
+ jrnx.f_id is null and vw.f_id= $1 and $sql_year";
$a_account_used=$cn->get_array($sql_account_used);
$nb_account_used=count ($a_account_used);
if ( $nb_account_used == 0 )
@@ -220,4 +253,9 @@ $nb_account_used=count ($a_account_used);
-