Skip to content

Commit

Permalink
fix : return vat code for supplier price
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-florian committed Nov 14, 2017
1 parent a2c80a7 commit e195cf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -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
{
Expand Down
4 changes: 4 additions & 0 deletions htdocs/product/class/product.class.php
Expand Up @@ -1505,6 +1505,7 @@ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_s
// 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;
Expand Down Expand Up @@ -1540,6 +1541,7 @@ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_s
$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;
}
Expand All @@ -1548,6 +1550,7 @@ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_s
// 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."'";
Expand Down Expand Up @@ -1587,6 +1590,7 @@ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_s
$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;
}
Expand Down

0 comments on commit e195cf0

Please sign in to comment.