From eb780561ca63f71f5078c5ed5f82dcf75b54d705 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 11 Dec 2010 14:59:14 +0000 Subject: [PATCH] =?UTF-8?q?0000177:=20Solde=20Banque=20intitul=C3=A9s=20de?= =?UTF-8?q?s=20colonnes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class_fiche.php | 31 +++++++++++++++++++++++++++++++ include/compta_fin.inc.php | 20 +++++++++++++------- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/include/class_fiche.php b/include/class_fiche.php index 19bd88304..b79a1c93a 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -1345,6 +1345,37 @@ class Fiche 'credit'=>$r['sum_cred'], 'solde'=>abs($r['sum_deb']-$r['sum_cred'])); } + /** + *get the bank balance with receipt or not + * + */ + function get_bk_balance($p_cond="") + { + if ( $this->id == 0 ) exit('fiche->id est nul'); + $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE); + + if ( $p_cond != "") $p_cond=" and ".$p_cond; + $sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from + ( select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx + join jrn on (jr_grpt_id=j_grpt) + where + j_qcode = ('$qcode'::text) + $p_cond + ) as m "; + + $Res=$this->cn->exec_sql($sql); + $Max=Database::num_row($Res); + if ($Max==0) return 0; + $r=Database::fetch_array($Res,0); + + return array('debit'=>$r['sum_deb'], + 'credit'=>$r['sum_cred'], + 'solde'=>abs($r['sum_deb']-$r['sum_cred'])); + + } /*!\brief check if an attribute is empty *\param $p_attr the id of the attribut to check (ad_id) *\return return true is the attribute is empty or missing diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 084c1c523..e5bf54ca7 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -230,13 +230,16 @@ if ( $def==3) echo '
'; - echo ''; - echo tr(th('Quick Code').th('Compte en banque').th('solde').th('solde rapproché').th('solde extrait / relevé')); + echo '
'; + echo tr(th('Quick Code').th('Compte en banque',' style="text-align:left"').th('solde opération',' style="text-align:right"') + .th('solde extrait/relevé',' style="text-align:right"') + .th('différence',' style="text-align:right"')); // Filter the saldo // on the current year $filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; // for highligting tje line $idx=0; + bcscale(2); // for each account for ( $i = 0; $i < count($array);$i++) { @@ -249,10 +252,11 @@ if ( $def==3) if ( $m['debit'] != 0.0 || $m['credit'] != 0.0) { /* get saldo for not reconcilied operations */ - $saldo_not_reconcilied=$array[$i]->get_solde_detail($filter_year." and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) ='' or jr_pj_number is null)" ); + $saldo_not_reconcilied=$array[$i]->get_bk_balance($filter_year." and (trim(jr_pj_number) ='' or jr_pj_number is null)" ); /* get saldo for reconcilied operation */ - $saldo_reconcilied=$array[$i]->get_solde_detail($filter_year." and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) != '' and jr_pj_number is not null)" ); + + $saldo_reconcilied=$array[$i]->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)" ); if ( $idx%2 != 0 ) $odd="odd"; @@ -265,17 +269,19 @@ if ( $def==3) IButton::history_card($array[$i]->id,$array[$i]->strAttribut(ATTR_DEF_QUICKCODE)). ""; + $saldo_rec=bcsub($saldo_reconcilied['debit'],$saldo_reconcilied['credit']); + $diff=bcsub($saldo_not_reconcilied['debit'],$saldo_not_reconcilied['credit']); echo "". "". "". "". ""; }
". $array[$i]->strAttribut(ATTR_DEF_NAME). "". - $solde. + nbm($solde). "". - sprintf('%.2f',($saldo_reconcilied['debit']-$saldo_reconcilied['credit'])). + nbm($saldo_rec). "". - sprintf('%.2f',($saldo_not_reconcilied['debit']-$saldo_not_reconcilied['credit'])). + nbm($diff). "