0000177: Solde Banque intitulés des colonnes

This commit is contained in:
Dany De Bontridder 2010-12-11 14:59:14 +00:00
parent 5bf60434d2
commit eb780561ca
2 changed files with 44 additions and 7 deletions

View file

@ -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

View file

@ -230,13 +230,16 @@ if ( $def==3)
echo '<div class="content">';
echo '<table style="margin-left:10%;width:30%" class="result">';
echo tr(th('Quick Code').th('Compte en banque').th('solde').th('solde rapproché').th('solde extrait / relevé'));
echo '<table style="margin-left:10%;width:60%" class="result">';
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)).
"</TD>";
$saldo_rec=bcsub($saldo_reconcilied['debit'],$saldo_reconcilied['credit']);
$diff=bcsub($saldo_not_reconcilied['debit'],$saldo_not_reconcilied['credit']);
echo "<TD >".
$array[$i]->strAttribut(ATTR_DEF_NAME).
"</TD>".
"<TD align=\"right\">".
$solde.
nbm($solde).
"</TD>".
"<TD align=\"right\">".
sprintf('%.2f',($saldo_reconcilied['debit']-$saldo_reconcilied['credit'])).
nbm($saldo_rec).
"</TD>".
"<TD align=\"right\">".
sprintf('%.2f',($saldo_not_reconcilied['debit']-$saldo_not_reconcilied['credit'])).
nbm($diff).
"</TD>".
"</TR>";
}