diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index 3f27d19c7f351f192b01db3dadeed78ec230f5e1..280f2b8190810f493ad1371dde1eaf0c80b30b76 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -59,7 +59,7 @@ exit;*/
 print '<div class="inline-block" style="vertical-align: top">';
 print '<div class="principal">';
 
-$page=GETPOST('menu','alpha');
+$page=GETPOST('menutpl','alpha');
 if (empty($page)) $page='facturation';
 
 if (in_array(
diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php
index 6ac2915a9d17653b5bd7287c27f70aff96232a0f..e30a0ea33033e373b2042c6ccf5091a3792f08c4 100644
--- a/htdocs/cashdesk/affIndex.php
+++ b/htdocs/cashdesk/affIndex.php
@@ -42,7 +42,7 @@ $langs->load("cashdesk");
  */
 
 //header("Content-type: text/html; charset=UTF-8");
-header("Content-type: text/html; charset=".$conf->file->character_set_client);
+//header("Content-type: text/html; charset=".$conf->file->character_set_client);
 
 $arrayofjs=array();
 $arrayofcss=array('/cashdesk/css/style.css');
diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php
index fd67bf9e2ae77517fcbb5b8ad3cf8fb67ff58bd4..3143805b86039ca2d1c4e128272c45c53c28a3f2 100644
--- a/htdocs/cashdesk/class/Facturation.class.php
+++ b/htdocs/cashdesk/class/Facturation.class.php
@@ -99,26 +99,17 @@ class Facturation
         $product = new Product($db);
         $product->fetch($this->id);
 
-        $sql = "SELECT taux";
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_tva";
-        $sql.= " WHERE rowid = ".$this->tva();
-
-        dol_syslog("ajoutArticle", LOG_DEBUG);
-        $resql = $db->query($sql);
-
-        if ($resql)
-        {
-            $obj = $db->fetch_object($resql);
-            $vat_rate=$obj->taux;
-            //var_dump($vat_rate);exit;
-        }
-        else
-       {
-            dol_print_error($db);
-        }
-
+        
+        $vatrowid = $this->tva();
+        
+        $tmp = getTaxesFromId($vatrowid);
+        $vat_rate = $tmp['rate'];
+        $vat_npr = $tmp['npr'];
+        
+        $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1);
+        
         // Define part of HT, VAT, TTC
-        $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0,$product->type,$mysoc);
+        $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, 0, 0, 0, 'HT', $use_npr, $product->type, $mysoc, $locataxarray);
 
         // Calcul du total ht sans remise
         $total_ht = $resultarray[0];
@@ -442,9 +433,8 @@ class Facturation
      * @param	int		$aTva		Vat
      * @return	int					Vat
      */
-    public function tva ( $aTva=null )
+    public function tva($aTva=null)
     {
-
         if ( !$aTva ) {
 
             return $this->tva;
@@ -467,9 +457,8 @@ class Facturation
      * @param string	$aNumFacture		Invoice ref
      * @return	string						Invoice ref
      */
-    public function numInvoice( $aNumFacture=null )
+    public function numInvoice($aNumFacture=null)
     {
-
         if ( !$aNumFacture ) {
 
             return $this->num_facture;
diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php
index 8953f7b0ccc8258fbefeb00f98276a5382248d4d..95a129e88a50cc07df3873a8a0ffb5177ccbd26c 100644
--- a/htdocs/cashdesk/facturation_verif.php
+++ b/htdocs/cashdesk/facturation_verif.php
@@ -37,7 +37,7 @@ switch ( $_GET['action'] )
 	default:
 		if ( $_POST['hdnSource'] != 'NULL' )
 		{
-			$sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx";
+			$sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.recuperableonly";
 			if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
 			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
 			if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot;
@@ -66,19 +66,23 @@ switch ( $_GET['action'] )
 					{
 						$ret[$key] = $value;
 					}
-
-					/** add Ditto for MultiPrix*/
-					if (! empty($conf->global->PRODUIT_MULTIPRICES))
+                    // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function
+                    
+					$productid = $ret['rowid'];
+					$product = new Product($db);
+                    $product->fetch($productid);
+
+					$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
+                    $societe = new Societe($db);
+					$societe->fetch($thirdpartyid);
+
+					$tva_tx = get_default_tva($mysoc,$societe,$productid);
+					$tva_npr = get_default_npr($mysoc,$societe,$productid);
+					if (empty($tva_tx)) $tva_npr=0;
+					dol_syslog('tva_tx='.$tva_tx.'-tva_npr='.$tva_npr);
+					
+					if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($societe->price_level))
 					{
-						$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-						$productid = $ret['rowid'];
-
-						$societe = new Societe($db);
-						$societe->fetch($thirdpartyid);
-
-						$product = new Product($db);
-                        $product->fetch($productid);
-
 						if(isset($product->multiprices[$societe->price_level]))
 						{
 							$ret['price'] = $product->multiprices[$societe->price_level];
@@ -86,16 +90,39 @@ switch ( $_GET['action'] )
 							// $product->multiprices_min[$societe->price_level];
 							// $product->multiprices_min_ttc[$societe->price_level];
 							// $product->multiprices_base_type[$societe->price_level];
-							$ret['tva_tx'] = $product->multiprices_tva_tx[$societe->price_level];
+							if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))  // using this option is a bug. kept for backward compatibility
+							{
+							    if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level];
+							    if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level];
+							    if (empty($tva_tx)) $tva_npr=0;
+							}
 						}
 					}
-					/** end add Ditto */
 
+					$ret['tva_tx'] = $tva_tx;
+					$ret['tva_npr'] = $tva_npr;
+                    //var_dump('tva_tx='.$ret['tva_tx'].'-tva_npr='.$ret['tva_npr'].'-'.$conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL);exit;
+                    
 					$obj_facturation->id($ret['rowid']);
 					$obj_facturation->ref($ret['ref']);
 					$obj_facturation->stock($ret['reel']);
 					$obj_facturation->prix($ret['price']);
-					$obj_facturation->tva($ret['tva_tx']);
+					
+					// Use $ret['tva_tx'] / ret['tva_npr'] to find vat id
+					$vatrowid = null;
+					$sqlfindvatid = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'c_tva';
+					$sqlfindvatid.= ' WHERE taux = '.$ret['tva_tx'].' AND recuperableonly = '.(int) $ret['tva_npr'];
+					$sqlfindvatid.= ' AND fk_pays = '.$mysoc->country_id;
+					$resqlfindvatid=$db->query($sqlfindvatid);
+					if ($resqlfindvatid)
+					{
+					    $obj = $db->fetch_object($resqlfindvatid);
+					    if ($obj) $vatrowid = $obj->rowid;
+					}
+					else dol_print_error($db);
+					
+					dol_syslog("save vatrowid=".$vatrowid);
+					$obj_facturation->tva($vatrowid);     // Save vat it for next use
 
 					// Definition du filtre pour n'afficher que le produit concerne
 					if ( $_POST['hdnSource'] == 'LISTE' )
@@ -107,7 +134,7 @@ switch ( $_GET['action'] )
 						$filtre = $_POST['txtRef'];
 					}
 
-					$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre;
+					$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$filtre;
 				}
 				else
 				{
@@ -115,11 +142,11 @@ switch ( $_GET['action'] )
 
 					if ( $_POST['hdnSource'] == 'REF' )
 					{
-						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
+						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef'];
 					}
 					else
 					{
-						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
+						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 					}
 				}
 			}
@@ -130,40 +157,38 @@ switch ( $_GET['action'] )
 		}
 		else
 		{
-			$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
+			$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 		}
 
 		break;
 
 	case 'ajout_article':	// We have clicked on button "Add product"
 
-		//var_dump('ajout_article');
-		//exit;
-
 		if (! empty($obj_facturation->id))	// A product was previously selected and stored in session, so we can add it
 		{
+		    dol_syslog("facturation_verif save vat ".$_POST['selTva']);
 			$obj_facturation->qte($_POST['txtQte']);
-			$obj_facturation->tva($_POST['selTva']);
+			$obj_facturation->tva($_POST['selTva']);                 // Save VAT selected so we can use it for next product
 			$obj_facturation->remisePercent($_POST['txtRemise']);
 			$obj_facturation->ajoutArticle();	// This add an entry into $_SESSION['poscart']
 			// We update prixTotalTtc
 			 
 		}
 
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
+		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 		break;
 
 	case 'suppr_article':
 		$obj_facturation->supprArticle($_GET['suppr_id']);
 
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
+		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 		break;
 
 }
 
 // We saved object obj_facturation
 $_SESSION['serObjFacturation'] = serialize($obj_facturation);
-
+//var_dump($_SESSION['serObjFacturation']);
 header('Location: '.$redirection);
 exit;
 
diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php
index db80866a77fa64741c074735e181478ca3f055c3..238a73f6ef7cc09ba73d8e72919bd53ec0138a3e 100644
--- a/htdocs/cashdesk/index_verif.php
+++ b/htdocs/cashdesk/index_verif.php
@@ -125,7 +125,7 @@ if ( $retour >= 0 )
         $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : '');
         //var_dump($_SESSION);exit;
 
-		header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&id=NOUV');
+		header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV');
 		exit;
 	}
 	else
diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php
index f9ef89e909c301936e742caf05a95b4c6bdbe779..ecb11c3e6ee3e8fa3a94c9a8e1a5dbdd3dfc55a4 100644
--- a/htdocs/cashdesk/tpl/facturation1.tpl.php
+++ b/htdocs/cashdesk/tpl/facturation1.tpl.php
@@ -119,7 +119,7 @@ $langs->load("cashdesk");
 				<td></td>
     			<!-- Choix de la remise -->
     			<td><input class="texte1" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
-<?php print genkeypad("txtRemise", "frmQte");?>
+					<?php print genkeypad("txtRemise", "frmQte");?>
     			</td>
     			<!-- Affichage du total HT -->
     			<td><input class="texte1_off" type="text" name="txtTotal" value="" disabled /></td><td></td>
@@ -128,16 +128,17 @@ $langs->load("cashdesk");
                 <?php //var_dump($tab_tva); ?>
                 <select name="selTva" onchange="javascript: modif();" >
                     <?php
-                        $tva_tx = $obj_facturation->tva();
-                        $tab_tva_size=count($tab_tva);
-                        for($i=0;$i < $tab_tva_size;$i++) {
+                        $tva_tx = $obj_facturation->tva();  // Try to get a previously entered VAT rowid. First time, this will return empty.
 
-                            if ( $tva_tx == $tab_tva[$i]['taux'] )
+                        $tab_tva_size=count($tab_tva);      // $tab_tva contains list of possible vat array('rowid'=> , 'taux'=> ) 
+                        for ($i=0;$i < $tab_tva_size;$i++) 
+                        {
+                            if ($tva_tx == $tab_tva[$i]['rowid'])
                                 $selected = 'selected';
                             else
-                            $selected = '';
+                                $selected = '';
 
-                            echo ('<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n               ");
+                            echo '<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n               ";
                         }
                     ?>
                 </select>
diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php
index ce38bb7d7e84425970335c2258644a3db47c19c3..745ea723b49190269201cabd8c73d050679d58b8 100644
--- a/htdocs/cashdesk/tpl/menu.tpl.php
+++ b/htdocs/cashdesk/tpl/menu.tpl.php
@@ -62,7 +62,7 @@ $langs->load("main");
 print '<div class="menu_bloc">';
 print '<ul class="menu">';
 // Link to new sell
-print '<li class="menu_choix1"><a href="affIndex.php?menu=facturation&id=NOUV"><span>'.$langs->trans("NewSell").'</span></a></li>';
+print '<li class="menu_choix1"><a href="affIndex.php?menutpl=facturation&id=NOUV"><span>'.$langs->trans("NewSell").'</span></a></li>';
 // Open new tab on backoffice (this is not a disconnect from POS)
 print '<li class="menu_choix2"><a href=".." target="backoffice"><span>'.$langs->trans("BackOffice").'</span></a></li>';
 // Disconnect
diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php
index 1aa1c0c47234d335eefef51227ddc238d10c4768..047d597a6ef09442d2f56f967555d2d75ed45113 100644
--- a/htdocs/cashdesk/tpl/validation1.tpl.php
+++ b/htdocs/cashdesk/tpl/validation1.tpl.php
@@ -113,7 +113,7 @@ $langs->load("bills");
 		<p class="note_label"><?php echo $langs->trans("Notes"); ?><br><textarea class="textarea_note" name="txtaNotes"></textarea></p>
 
 		<div class="center"><input class="button" type="submit" name="btnValider" value="<?php echo $langs->trans("ValidateInvoice"); ?>" /><br>
-		<br><a class="lien1" href="affIndex.php?menu=facturation"><?php echo $langs->trans("RestartSelling"); ?></a>
+		<br><a class="lien1" href="affIndex.php?menutpl=facturation"><?php echo $langs->trans("RestartSelling"); ?></a>
 		</div>
 	</form>
 
diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index 27ce3380dd4d14215b87fdcca013fb889bb5ea3c..cccccb1fdfe8de361300cedd9806b6e6d9472bf6 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -42,7 +42,7 @@ switch ($action)
 
 	default:
 
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=validation';
+		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation';
 		break;
 
 
@@ -85,13 +85,13 @@ switch ($action)
 			$obj_facturation->paiementLe($txtDatePaiement);
 		}
 
-		$redirection = 'affIndex.php?menu=validation';
+		$redirection = 'affIndex.php?menutpl=validation';
 		break;
 
 
 	case 'retour':
 
-		$redirection = 'affIndex.php?menu=facturation';
+		$redirection = 'affIndex.php?menutpl=facturation';
 		break;
 
 
@@ -336,7 +336,7 @@ switch ($action)
 		if (! $error)
 		{
 			$db->commit();
-			$redirection = 'affIndex.php?menu=validation_ok&facid='.$id;	// Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
+			$redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id;	// Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
 		}
 		else
 		{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0fdf4365ae78b921ed998d2aaea664726c20a040..3594e6214efe2380c2cc1e960fd46dcefbee2cd6 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3937,7 +3937,7 @@ class Form
     /**
      *	Load into the cache vat rates of a country
      *
-     *	@param	string	$country_code		Country code
+     *	@param	string	$country_code		Country code with quotes ("'CA'", or "'CA,IN,...'")
      *	@return	int							Nb of loaded lines, 0 if already loaded, <0 if KO
      */
     function load_cache_vatrates($country_code)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 19af488508603ea7bf095193b38bb17f82136c3a..5e3224622b55359a5eb160992ea12687bc952326 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3503,20 +3503,52 @@ function get_localtax_by_third($local)
 }
 
 
+/**
+ *  Get vat rate and npr from id.
+ *  You can call getLocalTaxesFromRate after to get other fields 
+ *
+ *  @param	string  $vatrate			VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
+ *  @param	int		$usenpr             Use npr
+ *  @return	array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ */
+function getTaxesFromId($vatrowid)
+{
+    global $db, $mysoc;
+
+    dol_syslog("getTaxesFromId vatrowid=".$vatrowid);
+
+    // Search local taxes
+    $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr";
+    $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
+    $sql.= " WHERE t.rowid ='".$vatrowid."'";
+
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $obj = $db->fetch_object($resql);
+
+        return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr);
+    }
+    else dol_print_error($db);
+
+    return array();
+}
+
 /**
  *  Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
  *  TODO
- *  This function is also called to retrieve type for building PDF. Such call of function must be removed.
+ *  This function is ALSO called to retrieve type for building PDF. Such call of function must be removed.
  *  Instead this function must be called when adding a line to get the array of localtax and type, and then
  *  provide it to the function calcul_price_total.
  *
- *  @param	float	$vatrate			VAT Rate. Value can be '8.5' or '8.5 (8.5NPR)'.
+ *  @param	string  $vatrate			VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
  *  @param	int		$local              Number of localtax (1 or 2, or 0 to return 1 & 2)
  *  @param	Societe	$buyer         		Company object
  *  @param	Societe	$seller        		Company object
+ *  @param  int     $firstparamisid     1 if first param is id into table (use this if you can)
  *  @return	array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
  */
-function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
+function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
 {
 	global $db, $mysoc;
 
@@ -3531,12 +3563,17 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
 	
 	// Search local taxes
 	$sql  = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
-	$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
-	if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'";
-	else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
-	$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
-	if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
-
+	$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
+	if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'";
+	else
+	{
+	    $sql.=", ".MAIN_DB_PREFIX."c_country as c";
+    	if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'";    // local tax in spain use the buyer country ??
+    	else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
+    	$sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
+    	if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
+	}
+	
 	$resql=$db->query($sql);
 	if ($resql)
 	{