From ee5c282ccd12d9862ec5242716dc8a23f38f993d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 10 Apr 2011 10:37:05 +0000 Subject: [PATCH] Fix: problem with $line->update_total if no $total_localtax --- htdocs/commande/class/commande.class.php | 12 ++++++++---- htdocs/compta/facture.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 96db18bbd3a..1e21670671e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2827,12 +2827,12 @@ class OrderLine $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($total_localtax1)."'"; - $sql.= " , total_localtax2='".price2num($total_localtax2)."'"; + $sql.= " , total_localtax1='".price2num($this->total_localtax1)."'"; + $sql.= " , total_localtax2='".price2num($this->total_localtax2)."'"; $sql.= " , info_bits=".$this->info_bits; - if ($date_start) { $sql.= " , date_start='".$this->db->idate($date_start)."'"; } + if ($this->date_start) { $sql.= " , date_start='".$this->db->idate($this->date_start)."'"; } else { $sql.=' , date_start=null'; } - if ($date_end) { $sql.= " , date_end='".$this->db->idate($date_end)."'"; } + if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; } $sql.= " , product_type=".$this->product_type; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); @@ -2872,6 +2872,10 @@ class OrderLine function update_total() { $this->db->begin(); + + // Clean parameters + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 58de414e9ac..ddd9feb6142 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1059,7 +1059,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST $localtax2_rate, 'HT', $info_bits, - $type + $type, + GETPOST('fk_parent_line') ); // Define output language diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 906714cbee9..c31b7937ecf 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3090,8 +3090,8 @@ class FactureLigne var $total_ht; //! Total TVA de la ligne toute quantite et incluant la remise ligne var $total_tva; - var $total_localtax1=0; //Total Local tax 1 de la ligne - var $total_localtax2=0; //Total Local tax 2 de la ligne + var $total_localtax1; //Total Local tax 1 de la ligne + var $total_localtax2; //Total Local tax 2 de la ligne //! Total TTC de la ligne toute quantite et incluant la remise ligne var $total_ttc; @@ -3344,6 +3344,16 @@ class FactureLigne // Clean parameters $this->desc=trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->remise)) $this->remise=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->product_type)) $this->product_type=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; // Check parameters if ($this->product_type < 0) return -1; @@ -3447,6 +3457,10 @@ class FactureLigne { $this->db->begin(); dol_syslog("FactureLigne::update_total", LOG_DEBUG); + + // Clean parameters + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";