From cfec02aaae12b867b47f0dd6578dbc89169ea251 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Jan 2022 14:27:43 +0100 Subject: [PATCH] Debug v15 --- .../facture/class/facture-rec.class.php | 21 +++++++++++++++---- htdocs/core/class/commonobject.class.php | 1 + .../install/mysql/tables/llx_facture_rec.sql | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 19f70554637..047a66a78b9 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -470,11 +470,23 @@ class FactureRec extends CommonInvoice $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql .= " fk_soc = ".((int) $this->fk_soc); + $sql .= " entity = ".((int) $this->entity).","; + $sql .= " titre = '".$this->db->escape($this->title)."',"; + $sql .= " suspended = ".((int) $this->suspended).","; + $sql .= " fk_soc = ".((int) $this->socid).","; + $sql .= " total_tva = ".((float) $this->total_tva).","; + $sql .= " localtax1 = ".((float) $this->localtax1).","; + $sql .= " localtax2 = ".((float) $this->localtax2).","; + $sql .= " total_ht = ".((float) $this->total_ht).","; + $sql .= " total_ttc = ".((float) $this->total_ttc).","; + $sql .= " remise_percent = ".((float) $this->remise_percent); // TODO Add missing fields $sql .= " WHERE rowid = ".((int) $this->id); + $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { if (!$error) { @@ -498,7 +510,7 @@ class FactureRec extends CommonInvoice } else { $this->error = $this->db->lasterror(); $this->db->rollback(); - return -2; + return -1; } } @@ -531,9 +543,9 @@ class FactureRec extends CommonInvoice //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; if ($rowid) { - $sql .= ' AND f.rowid='.((int) $rowid); + $sql .= ' AND f.rowid = '.((int) $rowid); } elseif ($ref) { - $sql .= " AND f.titre='".$this->db->escape($ref)."'"; + $sql .= " AND f.titre = '".$this->db->escape($ref)."'"; } else { $sql .= ' AND f.rowid = 0'; } @@ -2130,6 +2142,7 @@ class FactureLigneRec extends CommonInvoiceLine $this->db->begin(); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { if (!$error) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 024efa9417e..029ac6cbfc1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6109,6 +6109,7 @@ abstract class CommonObject } $sql .= ")"; + $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index bb65ea4b6d8..697e0bc4510 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -35,7 +35,7 @@ create table llx_facture_rec remise_percent real DEFAULT 0, remise_absolue real DEFAULT 0, - vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + vat_src_code varchar(10) DEFAULT '', -- TODO Remove this. Field is inside the table of lines total_tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, -- amount localtax1 localtax2 double(24,8) DEFAULT 0, -- amount localtax2