fix : return vat code for supplier price

This commit is contained in:
florian HENRY 2017-11-14 09:53:06 +01:00
parent a2c80a704f
commit e195cf0b95
2 changed files with 5 additions and 0 deletions

View File

@ -4306,6 +4306,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
{
$product->get_buyprice($idprodfournprice,0,0,0);
$ret=$product->vatrate_supplier;
if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')';
}
else
{

View File

@ -1505,6 +1505,7 @@ class Product extends CommonObject
// We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref)
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,";
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql.= " ,pfp.default_vat_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$prodfournprice;
if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
@ -1540,6 +1541,7 @@ class Product extends CommonObject
$this->ref_supplier = $obj->ref_fourn; // Ref supplier
$this->remise_percent = $obj->remise_percent; // remise percent if present and not typed
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
$this->default_vat_code = $obj->default_vat_code; // Vat code supplier
$result=$obj->fk_product;
return $result;
}
@ -1548,6 +1550,7 @@ class Product extends CommonObject
// We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc.
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
$sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql.= " ,pfp.default_vat_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.fk_product = ".$product_id;
if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'";
@ -1587,6 +1590,7 @@ class Product extends CommonObject
$this->ref_supplier = $obj->ref_supplier; // Ref supplier
$this->remise_percent = $obj->remise_percent; // remise percent if present and not typed
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
$this->default_vat_code = $obj->default_vat_code; // Vat code supplier
$result=$obj->fk_product;
return $result;
}