diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 025372849de..86080fbc623 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -287,10 +287,11 @@ class Paiement extends CommonObject return -2; } + $accline = new AccountLine($this->db); + // Delete bank urls. If payment is on a conciliated line, return error. if ($bank_line_id) { - $accline = new AccountLine($this->db); $result=$accline->fetch($bank_line_id); if ($result == 0) $accline->rowid=$bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url @@ -306,11 +307,13 @@ class Paiement extends CommonObject // Delete payment (into paiement_facture and paiement) $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture'; $sql.= ' WHERE fk_paiement = '.$this->id; + dol_syslog($sql); $result = $this->db->query($sql); if ($result) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement'; $sql.= ' WHERE rowid = '.$this->id; + dol_syslog($sql); $result = $this->db->query($sql); if (! $result) { @@ -322,9 +325,7 @@ class Paiement extends CommonObject // Supprimer l'ecriture bancaire si paiement lie a ecriture if ($bank_line_id) { - $accline = new AccountLine($this->db); - $accline->fetch($bank_line_id); - $result=$accline->delete(); + $result=$accline->delete($user); if ($result < 0) { $this->error=$accline->error;