IMPROVE QuickWriting check if account exist

This commit is contained in:
Dany De Bontridder 2008-10-09 20:19:18 +00:00
parent cc8b022fd5
commit d06e479561
2 changed files with 11 additions and 3 deletions

View file

@ -97,6 +97,14 @@ class Acc_Account_Ledger {
}
return $this->name;
}
/*!\brief check if the poste exist in the tmp_pcmn
*\return the number of line (normally 1 or 0)
*/
function do_exist() {
$sql="select pcm_val from tmp_pcmn where pcm_val= $1";
$ret=ExecSqlParam($this->db,$sql,array($this->id));
return pg_NumRows($ret) ;
}
/*!\brief Get all the value for this object from the database
* the data member are set
* \return false if this account doesn't exist otherwise true

View file

@ -1083,9 +1083,9 @@ class Acc_Ledger {
if ( $p->belong_ledger ($p_jrn) < 0 )
throw new AcException("Le poste ".$p->id." n\'est pas dans ce journal",5);
if ( strlen(trim(${'poste'.$i}))!=0 && isNumber(${'amount'.$i} ) == 0 )
throw new AcException('Montant invalide',3);
throw new AcException('Poste invalide',3);
if ( $p->do_exist() == 0 )
throw new AcException('Poste Inexistant',4);
}