Code is shorter

This commit is contained in:
Laurent Destailleur 2011-04-10 23:25:49 +00:00
parent 48f28a1ab8
commit 8ec6346bf3

View File

@ -996,8 +996,8 @@ class CommonObject
/** /**
* Update total_ht, total_ttc and total_vat for an object (sum of lines) * Update total_ht, total_ttc and total_vat for an object (sum of lines)
* @param exclspec Exclude special product (product_type=9) * @param exclspec Exclude special product (product_type=9)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_price($exclspec=0) function update_price($exclspec=0)
{ {
@ -1036,11 +1036,11 @@ class CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->total_ht += $obj->total_ht; $this->total_ht += $obj->total_ht;
$this->total_tva += $obj->total_tva; $this->total_tva += $obj->total_tva;
$this->total_localtax1 += $obj->total_localtax1; $this->total_localtax1 += $obj->total_localtax1;
$this->total_localtax2 += $obj->total_localtax2; $this->total_localtax2 += $obj->total_localtax2;
$this->total_ttc += $obj->total_ttc; $this->total_ttc += $obj->total_ttc;
$i++; $i++;
} }
@ -1049,28 +1049,13 @@ class CommonObject
// Now update field total_ht, total_ttc and tva // Now update field total_ht, total_ttc and tva
$fieldht='total_ht'; $fieldht='total_ht';
$fieldtva='tva'; $fieldtva='tva';
$fieldlocaltax1='localtax1'; $fieldlocaltax1='localtax1';
$fieldlocaltax2='localtax2'; $fieldlocaltax2='localtax2';
$fieldttc='total_ttc'; $fieldttc='total_ttc';
if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total';
if ($this->element == 'facture' || $this->element == 'facturerec') if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva';
{ if ($this->element == 'propal') $fieldttc='total';
$fieldht='total';
}
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
$fieldtva='total_tva';
}
if ($this->element == 'propal')
{
$fieldttc='total';
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
$sql .= " ".$fieldht."='".price2num($this->total_ht)."',"; $sql .= " ".$fieldht."='".price2num($this->total_ht)."',";