NEW Usage of vat code seems ok everywhere.

This commit is contained in:
Laurent Destailleur
2016-10-29 21:02:08 +02:00
parent 03b882d095
commit e9edbba093
9 changed files with 267 additions and 182 deletions

View File

@@ -1285,7 +1285,14 @@ class Commande extends CommonOrder
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx);
@@ -1327,6 +1334,8 @@ class Commande extends CommonOrder
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
@@ -1727,7 +1736,7 @@ class Commande extends CommonOrder
{
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx,';
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
$sql.= ' l.fk_unit,';
@@ -1762,6 +1771,8 @@ class Commande extends CommonOrder
$line->description = $objp->description; // Description line
$line->product_type = $objp->product_type;
$line->qty = $objp->qty;
$line->vat_src_code = $objp->vat_src_code;
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
@@ -2774,7 +2785,14 @@ class Commande extends CommonOrder
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx);
@@ -2848,26 +2866,28 @@ class Commande extends CommonOrder
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->vat_src_code = $vat_src_code;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$subprice;
$this->line->info_bits=$info_bits;
$this->line->special_code=$special_code;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->total_ttc=$total_ttc;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
$this->line->product_type=$type;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $subprice;
$this->line->info_bits = $info_bits;
$this->line->special_code = $special_code;
$this->line->total_ht = $total_ht;
$this->line->total_tva = $total_tva;
$this->line->total_localtax1= $total_localtax1;
$this->line->total_localtax2= $total_localtax2;
$this->line->total_ttc = $total_ttc;
$this->line->date_start = $date_start;
$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;
$this->line->fk_unit=$fk_unit;
$this->line->fk_unit = $fk_unit;
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
@@ -3931,7 +3951,7 @@ class OrderLine extends CommonOrderLine
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
$sql.= ' (fk_commande, 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, subprice, price, remise, fk_remise_except,';
$sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
@@ -3943,6 +3963,7 @@ class OrderLine extends CommonOrderLine
$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)."',";