111 |
|
|
112 |
return abs($r['sum_deb']-$r['sum_cred']); |
return abs($r['sum_deb']-$r['sum_cred']); |
113 |
} |
} |
114 |
|
/* function GetSoldeDetail |
115 |
|
* Purpose : give the balance of an account |
116 |
|
* |
117 |
|
* parm : |
118 |
|
* - cond |
119 |
|
* gen : |
120 |
|
* - none |
121 |
|
* return: |
122 |
|
* - balance of the account |
123 |
|
* |
124 |
|
*/ |
125 |
|
function GetSoldeDetail($p_cond="") { |
126 |
|
$Res=ExecSql($this->db,"select sum(deb) as sum_deb, sum(cred) as sum_cred from |
127 |
|
( select j_poste, |
128 |
|
case when j_debit='t' then j_montant else 0 end as deb, |
129 |
|
case when j_debit='f' then j_montant else 0 end as cred |
130 |
|
from jrnx join tmp_pcmn on j_poste=pcm_val |
131 |
|
where |
132 |
|
j_poste like ('$this->id'::text) and |
133 |
|
$p_cond |
134 |
|
) as m "); |
135 |
|
$Max=pg_NumRows($Res); |
136 |
|
if ($Max==0) return 0; |
137 |
|
$r=pg_fetch_array($Res,0); |
138 |
|
|
139 |
|
return array('debit'=>$r['sum_deb'], |
140 |
|
'credit'=>$r['sum_cred'], |
141 |
|
'solde'=>abs($r['sum_deb']-$r['sum_cred'])); |
142 |
|
} |
143 |
} |
} |