2
0
forked from Wavyzz/dolibarr

Fix a lot of fixes to have the french vat npr working better

This commit is contained in:
Laurent Destailleur
2016-02-27 11:32:49 +01:00
parent 4ed53edee8
commit c86a1a30d5
16 changed files with 68 additions and 45 deletions

View File

@@ -3452,14 +3452,15 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs)
* Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller
* Note: This function applies same rules than get_default_tva
*
* @param float $vatrate Vat rate. Can be '8.5' or '8.5 (8.5NPR)' for example
* @param float $vatrate Vat rate. Can be '8.5' or '8.5 (VATCODEX)' for example
* @param int $local Local tax to search and return (1 or 2 return only tax rate 1 or tax rate 2)
* @param Societe $thirdparty_buyer Object of buying third party
* @param Societe $thirdparty_seller Object of selling third party
* @param int $vatnpr If vat rate is NPR or not
* @return mixed 0 if not found, localtax rate if found
* @see get_default_tva
*/
function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="")
function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
{
global $db, $conf, $mysoc;
@@ -3568,7 +3569,8 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'";
$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority
else $sql.= " AND t.recuperableonly ='".$npr."'";
dol_syslog("get_localtax", LOG_DEBUG);
$resql=$db->query($sql);