From 7b73576731e7a804a29cc75f9e443658611a2df0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Apr 2011 15:39:03 +0000 Subject: [PATCH] Fix: possibility to skip update total of special lines with no qty and unit price --- htdocs/comm/propal/class/propal.class.php | 14 +++++++++----- htdocs/commande/class/commande.class.php | 14 ++++++++++---- htdocs/compta/facture/class/facture.class.php | 14 ++++++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b0db76ebee9..3973582e880 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -442,7 +442,7 @@ class Propal extends CommonObject * \param info_bits Miscellanous informations * \return int 0 en cas de succes */ - function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0) + function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0) { global $conf,$user,$langs; @@ -504,6 +504,7 @@ class Propal extends CommonObject $this->line->total_ttc=$total_ttc; $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; + $this->line->skip_update_total=$skip_update_total; if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -2329,7 +2330,7 @@ class PropaleLigne var $total_localtax1; var $total_localtax2; - + var $skip_update_total; // Skip update price total for special lines /** * \brief Constructeur d'objets ligne de propal @@ -2552,9 +2553,12 @@ class PropaleLigne $sql.= " , price=".price2num($this->price).""; // TODO A virer $sql.= " , remise=".price2num($this->remise).""; // TODO A virer $sql.= " , info_bits='".$this->info_bits."'"; - $sql.= " , total_ht=".price2num($this->total_ht).""; - $sql.= " , total_tva=".price2num($this->total_tva).""; - $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_ttc=".price2num($this->total_ttc).""; + } $sql.= " , marge_tx='".$this->marge_tx."'"; $sql.= " , marque_tx='".$this->marque_tx."'"; $sql.= " , info_bits=".$this->info_bits; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d8ad0edd742..e44f6f486bf 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1943,7 +1943,7 @@ class Commande extends CommonObject * \param type Type of line (0=product, 1=service) * \return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0) { global $conf; @@ -2016,6 +2016,7 @@ class Commande extends CommonObject $this->line->date_end=$date_end; $this->line->product_type=$type; $this->line->fk_parent_line=$fk_parent_line; + $this->line->skip_update_total=$skip_update_total; // TODO deprecated $this->line->price=$price; @@ -2591,6 +2592,8 @@ class OrderLine // Start and end date of the line var $date_start; var $date_end; + + var $skip_update_total; // Skip update price total for special lines /** @@ -2825,9 +2828,12 @@ class OrderLine $sql.= " , price=".price2num($this->price).""; // TODO A virer $sql.= " , remise=".price2num($this->remise).""; // TODO A virer $sql.= " , info_bits='".$this->info_bits."'"; - $sql.= " , total_ht=".price2num($this->total_ht).""; - $sql.= " , total_tva=".price2num($this->total_tva).""; - $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_ttc=".price2num($this->total_ttc).""; + } $sql.= " , total_localtax1='".price2num($this->total_localtax1)."'"; $sql.= " , total_localtax2='".price2num($this->total_localtax2)."'"; $sql.= " , info_bits=".$this->info_bits; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2b1af08cf52..88f9cc32d31 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1861,7 +1861,7 @@ class Facture extends CommonObject * @param type Type of line (0=product, 1=service) * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0,$price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0,$price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0) { include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); @@ -1927,6 +1927,7 @@ class Facture extends CommonObject $this->line->info_bits = $info_bits; $this->line->product_type = $type; $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; // A ne plus utiliser $this->line->price=$price; @@ -3142,6 +3143,8 @@ class FactureLigne var $libelle; // Product label (deprecated) var $product_label; // Product label var $product_desc; // Description produit + + var $skip_update_total; // Skip update price total for special lines /** @@ -3281,11 +3284,14 @@ class FactureLigne $sql.= ' '.$this->rang.','; $sql.= ' '.$this->special_code.','; $sql.= " '".$this->info_bits."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; + if (empty($this->skip_update_total)) + { + $sql.= " ".price2num($this->total_ht).","; + $sql.= " ".price2num($this->total_tva).","; + $sql.= " ".price2num($this->total_ttc); + } $sql.= " ".price2num($this->total_localtax1).","; $sql.= " ".price2num($this->total_localtax2).","; - $sql.= " ".price2num($this->total_ttc); $sql.= ')'; dol_syslog("FactureLigne::insert sql=".$sql);