FIX vat rate code not return by get_product_vat_for_country
This commit is contained in:
parent
bdbe2c02ed
commit
b08971b03b
@ -4955,7 +4955,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
*
|
||||
* @param int $idprod Id of product or 0 if not a predefined product
|
||||
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
|
||||
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" order/invoice)
|
||||
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice)
|
||||
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
|
||||
* @see get_product_localtax_for_country
|
||||
*/
|
||||
@ -4976,7 +4976,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
||||
|
||||
if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours
|
||||
{
|
||||
if ($idprodfournprice > 0) // We want vat for product for a "supplier" order or invoice
|
||||
if ($idprodfournprice > 0) // We want vat for product for a "supplier" object
|
||||
{
|
||||
$product->get_buyprice($idprodfournprice,0,0,0);
|
||||
$ret=$product->vatrate_supplier;
|
||||
@ -5001,7 +5001,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
||||
if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS))
|
||||
{
|
||||
// If vat of product for the country not found or not defined, we return the first higher vat of country.
|
||||
$sql = "SELECT taux as vat_rate";
|
||||
$sql = "SELECT c.taux as vat_rate, c.code as default_vat_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql.= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'";
|
||||
$sql.= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
|
||||
@ -5014,6 +5014,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
||||
if ($obj)
|
||||
{
|
||||
$ret=$obj->vat_rate;
|
||||
if ($obj->default_vat_code) $ret.=' ('.$obj->default_vat_code.')';
|
||||
}
|
||||
$db->free($sql);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user