From 7c0afbe02525c7e9590ddc599853fc8426b1f87a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 May 2018 17:12:08 +0200 Subject: [PATCH] Clean code --- .../facture/class/facture-rec.class.php | 13 +++-- htdocs/compta/facture/class/facture.class.php | 11 ++-- htdocs/contrat/class/contrat.class.php | 54 +++++++++---------- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index dbf15ff0186..6f70af4412b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1784,11 +1784,14 @@ class FactureLigneRec extends CommonInvoiceLine $sql.= ", info_bits='".price2num($this->info_bits)."'"; $sql.= ", date_start_fill=".(int) $this->date_start_fill; $sql.= ", date_end_fill=".(int) $this->date_end_fill; - $sql.= ", total_ht='".price2num($this->total_ht)."'"; - $sql.= ", total_tva='".price2num($this->total_tva)."'"; - $sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; + if (empty($this->skip_update_total)) + { + $sql.= ", total_ht=".price2num($this->total_ht); + $sql.= ", total_tva=".price2num($this->total_tva); + $sql.= ", total_localtax1=".price2num($this->total_localtax1); + $sql.= ", total_localtax2=".price2num($this->total_localtax2); + $sql.= ", total_ttc=".price2num($this->total_ttc); + } $sql.= ", rang=".$this->rang; $sql.= ", special_code=".$this->special_code; $sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit )."'":"null"); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 85b596ce49c..7dfe8283d29 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4676,11 +4676,11 @@ class FactureLigne extends CommonInvoiceLine $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; if (empty($this->skip_update_total)) { - $sql.= ", total_ht=".price2num($this->total_ht).""; - $sql.= ", total_tva=".price2num($this->total_tva).""; - $sql.= ", total_ttc=".price2num($this->total_ttc).""; - $sql.= ", total_localtax1=".price2num($this->total_localtax1).""; - $sql.= ", total_localtax2=".price2num($this->total_localtax2).""; + $sql.= ", total_ht=".price2num($this->total_ht); + $sql.= ", total_tva=".price2num($this->total_tva); + $sql.= ", total_ttc=".price2num($this->total_ttc); + $sql.= ", total_localtax1=".price2num($this->total_localtax1); + $sql.= ", total_localtax2=".price2num($this->total_localtax2); } $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; @@ -4773,6 +4773,7 @@ class FactureLigne extends CommonInvoiceLine /** * Mise a jour en base des champs total_xxx de ligne de facture + * TODO What is goal of this method ? * * @return int <0 if KO, >0 if OK */ diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 8e6f6af33ce..e32ebaff987 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1287,36 +1287,36 @@ class Contrat extends CommonObject $result=$this->call_trigger('CONTRACT_MODIFY',$user); if ($result < 0) { $error++; } // End call triggers - } - } - - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; } } + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + /** * Ajoute une ligne de contrat en base