Skip to content

Commit

Permalink
Fixed some errors of Bookkeeping class
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgdf committed Jan 18, 2015
1 parent 06eda34 commit be3527a
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions htdocs/accountancy/class/bookkeeping.class.php
Expand Up @@ -221,7 +221,7 @@ function fetch_all_per_mvt($piecenum)
* Insert line into bookkeeping
*
* @param User $user User who inserted operation
* @return $result Result
* @return int <0 KO >0 OK
*/
function create($user='')
{
Expand Down Expand Up @@ -276,8 +276,9 @@ function create($user='')
}

$now = dol_now();
if (empty($this->date_create))
$this->date_create = $now();
if (empty($this->date_create)) {
$this->date_create = $now;
}

$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,";
Expand Down Expand Up @@ -330,23 +331,19 @@ function delete_by_importkey($importkey) {
$sql .= " WHERE import_key = '" . $importkey . "'";

$resql = $this->db->query($sql);

if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}

// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
return - 1;
}

$this->db->commit();
return 1;
}

/**
Expand Down Expand Up @@ -595,16 +592,13 @@ function delete($user, $notrigger = 0)

$this->db->begin();

if (! $error)
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
}
// if (! $notrigger)
// {
// // Call trigger
// $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
// if ($result < 0) $error++;
// // End call triggers
// }

if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
Expand Down

0 comments on commit be3527a

Please sign in to comment.