Qual: Mise en transaction de l'ajout d'écritures bancaires

This commit is contained in:
Laurent Destailleur 2005-08-11 20:26:09 +00:00
parent 8d8be88daf
commit 453141fe18

View File

@ -133,12 +133,14 @@ class Account
/** /**
* \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank * \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
* \return int rowid de l'entrée ajoutée, < 0 si erreur * \return int rowid de l'entrée ajoutée, <0 si erreur
*/ */
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='') function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='')
{ {
dolibarr_syslog("Account::addline: $date, $oper, $label, $amount, $num_chq, $categorie, $user");
if ($this->rowid) if ($this->rowid)
{ {
$this->db->begin();
switch ($oper) switch ($oper)
{ {
@ -179,17 +181,26 @@ class Account
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (! $result)
{ {
return -2; $this->db->rollback();
$this->error=$this->db->error();
return -3;
} }
} }
$this->db->commit();
return $rowid; return $rowid;
} }
else else
{ {
dolibarr_print_error($this->db); $this->db->rollback();
return -1; $this->error=$this->db->error();
return -2;
} }
} }
else
{
$this->error="Account::addline rowid not defined";
return -1;
}
} }
/* /*