Skip to content
Snippets Groups Projects
Commit be3527ab authored by Marcos García de La Fuente's avatar Marcos García de La Fuente
Browse files

Fixed some errors of Bookkeeping class

parent 06eda34b
Branches main
No related tags found
No related merge requests found
...@@ -221,7 +221,7 @@ class BookKeeping ...@@ -221,7 +221,7 @@ class BookKeeping
* Insert line into bookkeeping * Insert line into bookkeeping
* *
* @param User $user User who inserted operation * @param User $user User who inserted operation
* @return $result Result * @return int <0 KO >0 OK
*/ */
function create($user='') function create($user='')
{ {
...@@ -276,8 +276,9 @@ class BookKeeping ...@@ -276,8 +276,9 @@ class BookKeeping
} }
$now = dol_now(); $now = dol_now();
if (empty($this->date_create)) if (empty($this->date_create)) {
$this->date_create = $now(); $this->date_create = $now;
}
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, ";
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
...@@ -330,24 +331,20 @@ class BookKeeping ...@@ -330,24 +331,20 @@ class BookKeeping
$sql .= " WHERE import_key = '" . $importkey . "'"; $sql .= " WHERE import_key = '" . $importkey . "'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return - 1 * $error; return - 1;
} else { }
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
}
/** /**
* Create object into database * Create object into database
...@@ -595,16 +592,13 @@ class BookKeeping ...@@ -595,16 +592,13 @@ class BookKeeping
$this->db->begin(); $this->db->begin();
if (! $error) // if (! $notrigger)
{ // {
if (! $notrigger) // // Call trigger
{ // $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
// Call trigger // if ($result < 0) $error++;
$result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); // // End call triggers
if ($result < 0) $error++; // }
// End call triggers
}
}
if (! $error) { if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment