From 9ab8f767774362078f78a60565db8654a073ac3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 18:40:21 +0200 Subject: [PATCH] Fix insert supplier invoice line --- htdocs/fourn/class/fournisseur.facture.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index ea91765b94a..3d61698d5dd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1277,7 +1277,13 @@ class FactureFournisseur extends CommonInvoice if (empty($txtva)) $txtva=0; if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; - + // Clean vat code + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\((.*)\)/', '', $txtva); + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu=price2num($pu); @@ -1312,6 +1318,7 @@ class FactureFournisseur extends CommonInvoice $this->line->desc=$desc; $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->tva_tx=$txtva; + $this->line->vat_src_code=$vat_src_code; $this->line->localtax1_tx=$txlocaltax1; $this->line->localtax2_tx=$txlocaltax2; $this->line->fk_product=$fk_product; @@ -2571,7 +2578,7 @@ class SupplierInvoiceLine extends CommonObjectLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,'; - $sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,'; $sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,'; $sql.= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit'; @@ -2582,6 +2589,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".price2num($this->qty).","; + $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").","; $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).",";