diff --git a/ChangeLog b/ChangeLog
index 66e4a8cfd8907836423c367ba85a0bfa1d835319..db9fc3b9f8eb104f790a5571ab58426d2e120320 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ English Dolibarr ChangeLog
 
 ***** ChangeLog for 3.4 compared to 3.3 *****
 For users:
+- New: Support revenue stamp onto invoices.
 - New: Add a tab "consumption" on thirdparties to list products bought/sells.
 - New: Some performance enhancements.
 - New: Can attach files onto trip and expenses modules.
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 55ad5902e1346a72fec00326187543786fe841f9..55a8a8b8b6039b24ea663e16f7274a3eebd306fd 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -547,7 +547,7 @@ if ($action == 'edit' || $action == 'updateedit')
     /*
      *  Local Taxes
      */
-    if ($mysoc->hasLocalTax(1))
+    if ($mysoc->useLocalTax(1))
     {
         // Local Tax 1
         print '<br>';
@@ -579,7 +579,7 @@ if ($action == 'edit' || $action == 'updateedit')
         print "</td></tr>\n";
         print "</table>";
 	}
-    if ($mysoc->hasLocalTax(2))
+    if ($mysoc->useLocalTax(2))
     {
         // Local Tax 2
         print '<br>';
@@ -927,7 +927,7 @@ else
     /*
      *  Local Taxes
      */
-    if ($mysoc->hasLocalTax(1))
+    if ($mysoc->useLocalTax(1))
     {
         // Local Tax 1
         print '<br>';
@@ -960,7 +960,7 @@ else
 
         print "</table>";
 	}
-    if ($mysoc->hasLocalTax(2))
+    if ($mysoc->useLocalTax(2))
     {
         // Local Tax 2
         print '<br>';
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 52b7761adbee97444d3c3b5b6ecf4e3f8c864f4e..bb9c9117f24c25a8c71c0a3b035f90ffd13d889f 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1487,7 +1487,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 		else
 		{
 			print '<td colspan="2">';
-			print $form->select_company('','socid','s.client = 1',1);
+			print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
 			print '</td>';
 		}
 		print '</tr>'."\n";
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 96fca70af4c6c4c2af2554956987e372e96f7e3e..f792d7c6e2055c188dd33b02ecf49d8c691081e1 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -302,6 +302,14 @@ else if ($action == 'setpaymentterm' && $user->rights->facture->creer)
     $result=$object->update($user);
     if ($result < 0) dol_print_error($db,$object->error);
 }
+else if ($action == 'setrevenuestamp' && $user->rights->facture->creer)
+{
+    $object->fetch($id);
+    $object->revenuestamp=GETPOST('revenuestamp');
+    $result=$object->update($user);
+    $object->update_price(1);
+    if ($result < 0) dol_print_error($db,$object->error);
+}
 else if ($action == 'setremisepercent' && $user->rights->facture->creer)
 {
     $object->fetch($id);
@@ -369,22 +377,22 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
     $object->fetch_thirdparty();
 
     // Check parameters
-    
+
     // Check for  mandatory prof id
     for ($i = 1; $i < 5; $i++)
     {
-    	 
+
     	$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_INVOICE_MANDATORY';
     	$idprof='idprof'.$i;
     	if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory))
         {
         	if (! $error) $langs->load("errors");
     		$error++;
-    	
+
     		setEventMessage($langs->trans('ErrorProdIdIsMandatory',$langs->transcountry('ProfId'.$i, $object->thirdparty->country_code)),'errors');
     	}
-    } 
-    
+    }
+
     //Check for warehouse
     if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
     {
@@ -395,7 +403,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
             $action='';
         }
     }
-    
+
     if (! $error)
     {
         $result = $object->validate($user,'',$idwarehouse);
@@ -617,7 +625,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
     $db->begin();
 
     $error=0;
-    
+
     // Get extra fields
     foreach($_POST as $key => $value)
     {
@@ -1630,7 +1638,7 @@ else if ($action == 'builddoc')	// En get ou en post
 
     if (GETPOST('model'))   $object->setDocModel($user, GETPOST('model'));
 	if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank');
-	
+
     // Define output language
     $outputlangs = $langs;
     $newlang='';
@@ -1916,7 +1924,7 @@ if ($action == 'create')
     else
    {
    		print '<td colspan="2">';
-   		print $form->select_company('','socid','s.client = 1',1);
+   		print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
    		print '</td>';
     }
     print '</tr>'."\n";
@@ -2272,10 +2280,10 @@ else if ($id > 0 || ! empty($ref))
      */
 
     $result=$object->fetch($id,$ref);
-    
+
     // fetch optionals attributes and labels
  	$extralabels=$extrafields->fetch_name_optionals_label('facture');
- 	
+
     if ($result > 0)
     {
         if ($user->societe_id>0 && $user->societe_id!=$object->socid)  accessforbidden('',0);
@@ -2284,11 +2292,12 @@ else if ($id > 0 || ! empty($ref))
 
         $soc = new Societe($db);
         $soc->fetch($object->socid);
+        $selleruserevenustamp=$mysoc->useRevenueStamp();
 
         $totalpaye  = $object->getSommePaiement();
         $totalcreditnotes = $object->getSumCreditNotesUsed();
         $totaldeposits = $object->getSumDepositsUsed();
-        //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
+        //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." selleruserrevenuestamp=".$selleruserevenustamp;
 
         // We can also use bcadd to avoid pb with floating points
         // For example print 239.2 - 229.3 - 9.9; does not return 0.
@@ -2752,10 +2761,9 @@ else if ($id > 0 || ! empty($ref))
         $nbrows=8; $nbcols=2;
         if (! empty($conf->projet->enabled)) $nbrows++;
         if (! empty($conf->banque->enabled)) $nbcols++;
-
-        //Local taxes
         if($mysoc->localtax1_assuj=="1") $nbrows++;
         if($mysoc->localtax2_assuj=="1") $nbrows++;
+        if ($selleruserevenustamp) $nbrows++;
 
         print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
 
@@ -3031,17 +3039,44 @@ else if ($id > 0 || ! empty($ref))
 		print '</tr>';
 
         // Amount Local Taxes
-        if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
+        if ($mysoc->localtax1_assuj=="1" && $mysoc->useLocalTax(1)) //Localtax1 (example RE)
         {
             print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
             print '<td align="right" colspan="3" nowrap>'.price($object->total_localtax1,1,'',1,-1,-1,$conf->currency).'</td></tr>';
         }
-        if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
+        if ($mysoc->localtax2_assuj=="1" && $mysoc->useLocalTax(2)) //Localtax2 (example IRPF)
         {
             print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
             print '<td align="right" colspan="3" nowrap>'.price($object->total_localtax2,1,'',1,-1,-1,$conf->currency).'</td></tr>';
         }
 
+        // Revenue stamp
+        if ($selleruserevenustamp)		// Test company use revenue stamp
+        {
+	        print '<tr><td>';
+	        print '<table class="nobordernopadding" width="100%"><tr><td>';
+	        print $langs->trans('RevenueStamp');
+	        print '</td>';
+	        if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrevenuestamp&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetRevenuStamp'),1).'</a></td>';
+	        print '</tr></table>';
+	        print '</td><td colspan="3" align="right">';
+	        if ($action == 'editrevenuestamp')
+	        {
+				print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
+				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+				print '<input type="hidden" name="action" value="setrevenuestamp">';
+	        	print '<input type="text" class="flat" size="4" name="revenuestamp" value="'.price2num($object->revenuestamp).'">';
+				print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
+				print '</form>';
+	        }
+	        else
+	        {
+	        	print price($object->revenuestamp,1,'',1,-1,-1,$conf->currency);
+	        }
+	        print '</td></tr>';
+        }
+
+        // Total with tax
         print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="3" nowrap>'.price($object->total_ttc,1,'',1,-1,-1,$conf->currency).'</td></tr>';
 
         // Statut
@@ -3078,14 +3113,14 @@ else if ($id > 0 || ! empty($ref))
             print '</td>';
             print '</tr>';
         }
-        
+
         // Other attributes
         $res=$object->fetch_optionals($object->id,$extralabels);
         $parameters=array('colspan' => ' colspan="2"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
         if (empty($reshook) && ! empty($extrafields->attribute_label))
         {
-        
+
         	if ($action == 'edit_extras')
         	{
         		print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
@@ -3093,8 +3128,8 @@ else if ($id > 0 || ! empty($ref))
         		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
         		print '<input type="hidden" name="id" value="'.$object->id.'">';
         	}
-        
-        
+
+
         	foreach($extrafields->attribute_label as $key=>$label)
         	{
         		$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
@@ -3118,16 +3153,16 @@ else if ($id > 0 || ! empty($ref))
 	        		print '</td></tr>'."\n";
         		}
         	}
-        
+
         	if(count($extrafields->attribute_label) > 0) {
-        
+
         		if ($action == 'edit_extras' && $user->rights->facture->creer)
         		{
         			print '<tr><td></td><td colspan="5">';
         			print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
         			print '</form>';
         			print '</td></tr>';
-        
+
         		}
         		else {
         			if ($object->statut == 0 && $user->rights->facture->creer)
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index f3427ee5d4bcd80014b3eb035bd34306b372fcbb..38995fdebb9f960e208ae81435d50830d7efc4e6 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -75,6 +75,7 @@ class Facture extends CommonInvoice
     var $total_ht=0;
     var $total_tva=0;
     var $total_ttc=0;
+    var $revenuestamp;
     var $note;			// deprecated
     var $note_private;
     var $note_public;
@@ -795,7 +796,8 @@ class Facture extends CommonInvoice
 
         if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
 
-        $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
+        $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
+        $sql.= ', f.remise_percent, f.remise_absolue, f.remise';
         $sql.= ', f.datef as df';
         $sql.= ', f.date_lim_reglement as dlr';
         $sql.= ', f.datec as datec';
@@ -841,6 +843,7 @@ class Facture extends CommonInvoice
                 $this->total_localtax1		= $obj->localtax1;
                 $this->total_localtax2		= $obj->localtax2;
                 $this->total_ttc			= $obj->total_ttc;
+                $this->revenuestamp         = $obj->revenuestamp;
                 $this->paye					= $obj->paye;
                 $this->close_code			= $obj->close_code;
                 $this->close_note			= $obj->close_note;
@@ -1050,6 +1053,7 @@ class Facture extends CommonInvoice
         $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").",";
         $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").",";
         $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").",";
+        $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->revenuestamp:"null").",";
         $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
         $sql.= " fk_user_author=".(isset($this->user_author)?$this->user_author:"null").",";
         $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").",";
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 902dde79f17d59f2fe70b461ab4542fe5e3e370f..de9ce68e6b34d92fc89ceff4d8cf9b523cad3678 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -827,7 +827,7 @@ if ($action == 'create')
 	else
 	{
 		print '<td colspan="2">';
-		print $form->select_company('','socid','s.client = 1',1);
+		print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
 		print '</td>';
 	}
 	print '</tr>'."\n";
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index faccaa315459174f935fb2bc3f3cf72e6cda2942..9561aa288fbe5ee178b652b01b2ee639c9394ee7 100755
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -185,11 +185,11 @@ abstract class CommonDocGenerator
         		}
         		$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
         	}
-        }        
+        }
         return $array_thirdparty;
     }
 
-    
+
     /**
      * Define array with couple substitution key => substitution value
      *
@@ -201,7 +201,7 @@ abstract class CommonDocGenerator
     function get_substitutionarray_propal($object,$outputlangs,$array_key='object')
     {
     	global $conf;
-    
+
     	$array_propal=array(
 	    	$array_key.'_id'=>$object->id,
 	    	$array_key.'_ref'=>$object->ref,
@@ -224,14 +224,14 @@ abstract class CommonDocGenerator
 	    	$array_key.'_note_private'=>$object->note,
 	    	$array_key.'_note'=>$object->note_public,
     	);
-    
+
     	// Add vat by rates
     	foreach ($object->lines as $line)
     	{
     		if (empty($array_propal[$array_key.'_total_vat_'.$line->tva_tx])) $array_propal[$array_key.'_total_vat_'.$line->tva_tx]=0;
     		$array_propal[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
     	}
-    	
+
     	// Retrieve extrafields
     	if(is_array($object->array_options) && count($object->array_options))
     	{
@@ -240,12 +240,12 @@ abstract class CommonDocGenerator
     		$extrafields = new ExtraFields($this->db);
     		$extralabels = $extrafields->fetch_name_optionals_label('propal',true);
     		$object->fetch_optionals($object->id,$extralabels);
-    	
+
     		$array_propal = $this->fill_substitutionarray_with_extrafields($object,$array_propal,$extrafields,$array_key,$outputlangs);
     	}
     	return $array_propal;
     }
-    
+
 
     /**
      *	Define array with couple substitution key => substitution value
@@ -257,7 +257,7 @@ abstract class CommonDocGenerator
     function get_substitutionarray_propal_lines($line,$outputlangs)
     {
     	global $conf;
-    
+
     	return array(
     	'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
     	'line_product_ref'=>$line->product_ref,
@@ -274,7 +274,7 @@ abstract class CommonDocGenerator
     	'line_date_end'=>$line->date_end
     	);
     }
-    
+
     /**
      *	Fill array with couple extrafield key => extrafield value
      *
@@ -309,14 +309,14 @@ abstract class CommonDocGenerator
 			{
 				$object->array_options['options_'.$key] = ($object->array_options['options_'.$key]!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):'');
 			}
-			$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));    			
+			$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
 		}
-		
+
 		return $array_to_fill;
-	    	
+
 	}
-    
-    
+
+
 	/**
 	 * Rect pdf
 	 *
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 975765d12b470250fd9f269911cf713160d049d1..79a471a02510fb86d5d445e863dcebad8f25165f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1556,6 +1556,9 @@ abstract class CommonObject
                 $i++;
             }
 
+            // Add revenue stamp to total
+            $this->total_ttc       += isset($this->revenuestamp)?$this->revenuestamp:0;
+            
             $this->db->free($resql);
 
             // Now update global field total_ht, total_ttc and tva
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 941865da45a0022d0ae18332ba56820839901ad3..4807ec768fab64ca31a74f27fc04ebd14158bb43 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -678,7 +678,7 @@ class Form
         if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
         $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
         if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
-        if ($filter) $sql.= " AND ".$filter;
+        if ($filter) $sql.= " AND (".$filter.")";
         if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
         $sql.= " ORDER BY nom ASC";
 
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 957b5d85428bf5f01a8ba43f1f1a7ec4438f0671..ee80dbbb141f65161b87575715d53fe2a63f09a2 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -121,16 +121,16 @@ class doc_generic_invoice_odt extends ModelePDFFactures
         	'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
         	'object_payment_term_code'=>$object->cond_reglement_code,
         	'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
-        	'object_total_ht'=>price2num($object->total_ht,2),
-            'object_total_vat'=>price2num($object->total_tva,2),
-            'object_total_ttc'=>price2num($object->total_ttc,2),
+        	'object_total_ht'=>price2num($object->total_ht),
+            'object_total_vat'=>price2num($object->total_tva),
+            'object_total_ttc'=>price2num($object->total_ttc),
             'object_total_discount_ht' => price2num($object->getTotalDiscount(), 0, $outputlangs),
             'object_vatrate'=>(isset($object->tva)?vatrate($object->tva):''),
             'object_note_private'=>$object->note,
             'object_note'=>$object->note_public,
         	// Payments
             'object_already_payed'=>$alreadypayed,
-            'object_remain_to_pay'=>price2num($object->total_ttc - $sumpayed,2)
+            'object_remain_to_pay'=>price2num($object->total_ttc - $sumpayed)
         );
 
         // Add vat by rates
@@ -139,7 +139,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
 			if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
 			$resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
 		}
-		
+
 		// Retrieve extrafields
 		if(is_array($object->array_options) && count($object->array_options))
 		{
@@ -148,7 +148,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
 			$extrafields = new ExtraFields($this->db);
 			$extralabels = $extrafields->fetch_name_optionals_label('facture',true);
 			$object->fetch_optionals($object->id,$extralabels);
-		
+
 			$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key='object',$outputlangs);
 		}
         return $resarray;
@@ -174,9 +174,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
             'line_up'=>price($line->subprice, 0, $outputlangs),
             'line_qty'=>$line->qty,
             'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
-            'line_price_ht'=>price2num($line->total_ht, 2),
-            'line_price_ttc'=>price2num($line->total_ttc, 2),
-            'line_price_vat'=>price2num($line->total_tva, 2),
+            'line_price_ht'=>price2num($line->total_ht),
+            'line_price_ttc'=>price2num($line->total_ttc),
+            'line_price_vat'=>price2num($line->total_tva),
             'line_date_start'=>dol_print_date($line->date_start, 'day', false, $outputlangs),
             'line_date_end'=>dol_print_date($line->date_end, 'day', false, $outputlangs),
         );
@@ -358,14 +358,13 @@ class doc_generic_invoice_odt extends ModelePDFFactures
                 {
                     $socobject=$object->client;
                 }
-                
+
                 // Fetch info for linked propal
                 $linked_propal = $object->fetchObjectLinked('','','','');
-                print '<pre>';
                 //print_r($object->linkedObjects['propal']); exit;
 
                 $propal_object = $object->linkedObjects['propal'][0];
-                
+
                 // Make substitution
                 $substitutionarray=array(
                     '__FROM_NAME__' => $this->emetteur->nom,
@@ -415,7 +414,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
 				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
 				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
 				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
-				$array_propal=$this->get_substitutionarray_propal($propal_object,$outputlangs,'propal');
+				$array_propal=is_object($propal_object)?$this->get_substitutionarray_propal($propal_object,$outputlangs,'propal'):array();
 
 				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
 				complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index ef7698d0564061c2f36eaa2c133db91e2c825bac..15ee4e29abaa474012aef6b7b0f2ce0b79cab64b 100755
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1020,6 +1020,17 @@ class pdf_crabe extends ModelePDFFactures
 					//}
 				}
 
+				// Revenue stamp
+				if (price2num($object->revenuestamp) != 0)
+				{
+					$index++;
+					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
+
+					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+					$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
+				}
+
 				// Total TTC
 				$index++;
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
diff --git a/htdocs/install/mysql/data/llx_c_revenuestamp.sql b/htdocs/install/mysql/data/llx_c_revenuestamp.sql
index 8d998111218e74840709dc959c5039f16fbde451..040a837048538a4f30288a1515bc6564f0256205 100644
--- a/htdocs/install/mysql/data/llx_c_revenuestamp.sql
+++ b/htdocs/install/mysql/data/llx_c_revenuestamp.sql
@@ -1,13 +1,4 @@
--- Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
--- Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
 -- Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
--- Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
--- Copyright (C) 2004      Guillaume Delecourt  <guillaume.delecourt@opensides.be>
--- Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@capnetworks.com>
--- Copyright (C) 2007 	   Patrick Raguin       <patrick.raguin@gmail.com>
--- Copyright (C) 2010-2011 Juanjo Menent        <jmenent@2byte.es>
--- Copyright (C) 2012      Sebastian Neuwert    <sebastian.neuwert@modula71.de>
--- Copyright (C) 2012	   Ricardo Schluter		<info@ripasch.nl>
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -35,5 +26,5 @@
 
 delete from llx_c_revenuestamp;
 
--- TUNISIA --
-insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, '0.4', 'Timbre fiscal', 1);
+-- TUNISIA (id country=10) --
+insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, 0.4, 'Revenue stamp tunisia', 1);
diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql
index b5f578f579b688317e0927b0b27acef8f0c43746..b6d38949451fcff657d114bf440a1cd1b9ce0ecf 100644
--- a/htdocs/install/mysql/data/llx_c_tva.sql
+++ b/htdocs/install/mysql/data/llx_c_tva.sql
@@ -219,13 +219,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 6
 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6,   '0','0','VAT Rate 0',  1);
 
 -- TUNISIA (id country=10)
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10,    '6','0','VAT 6%', 1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10,   '12','0','VAT 12%',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10,   '18','0','VAT 18%',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10,  '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10,   '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10,    '0','0','VAT Rate 0',  1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10,    '6','0','VAT 6%', 1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10,   '12','0','VAT 12%',1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10,   '18','0','VAT 18%',1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10,  '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10,   '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0, null);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10,    '0','0','VAT Rate 0',  1, 1, '4', 0, null);
 
 -- UKRAINE (id country=226)
 INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226,  '20','0','VAT standart rate',1);
diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
index e6b82dc565e642b14c118f001cae43bdcdd44e35..571ba7373a29a3a3f049edd32c9bf36e1e3f7aa0 100755
--- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
+++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
@@ -130,8 +130,6 @@ CREATE TABLE llx_c_revenuestamp
 
 insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, '0.4', 'Timbre fiscal', 1);
 
-ALTER TABLE llx_actioncomm ADD COLUMN code varchar(32) NULL after fk_action;
-
 ALTER TABLE llx_c_tva MODIFY COLUMN localtax1_type varchar(10)	NOT NULL DEFAULT '0';
 ALTER TABLE llx_c_tva MODIFY COLUMN localtax2_type varchar(10)	NOT NULL DEFAULT '0';
 ALTER TABLE llx_commande_fournisseurdet MODIFY COLUMN localtax1_type varchar(10)	NOT NULL DEFAULT '0';
@@ -148,6 +146,13 @@ ALTER TABLE llx_facturedet MODIFY COLUMN localtax1_type varchar(10)	NOT NULL DEF
 ALTER TABLE llx_facturedet MODIFY COLUMN localtax2_type varchar(10)	NOT NULL DEFAULT '0';
 ALTER TABLE llx_propaldet MODIFY COLUMN localtax1_type varchar(10)	NOT NULL DEFAULT '0';
 ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(10)	NOT NULL DEFAULT '0';
+-- No more use type 7, use revenuse stamp instead
+UPDATE llx_c_tva set localtax1=0, localtax1_type='0' where localtax1_type = '7';
+UPDATE llx_c_tva set localtax2=0, localtax2_type='0' where localtax2_type = '7';
+
+
+ALTER TABLE llx_actioncomm ADD COLUMN code varchar(32) NULL after fk_action;
+
 
 ALTER TABLE llx_holiday ADD COLUMN note text; 
 ALTER TABLE llx_holiday ADD COLUMN note_public text;
@@ -197,5 +202,9 @@ ALTER TABLE llx_societe MODIFY COLUMN zip varchar(25);
 ALTER TABLE llx_user ADD COLUMN   address           varchar(255);
 ALTER TABLE llx_user ADD COLUMN   zip               varchar(25);
 ALTER TABLE llx_user ADD COLUMN   town              varchar(50);
-ALTER TABLE llx_user ADD COLUMN   fk_state          integer        DEFAULT 0;            		--
+ALTER TABLE llx_user ADD COLUMN   fk_state          integer        DEFAULT 0;
 ALTER TABLE llx_user ADD COLUMN   fk_country        integer        DEFAULT 0;
+
+
+
+
diff --git a/htdocs/install/mysql/tables/llx_c_tva.sql b/htdocs/install/mysql/tables/llx_c_tva.sql
index 219b1fb9744d169f2cddfdc412b3c90ad0be6184..46aa3632faa7c8c615fd5353a0c1dd4eae72437f 100644
--- a/htdocs/install/mysql/tables/llx_c_tva.sql
+++ b/htdocs/install/mysql/tables/llx_c_tva.sql
@@ -24,9 +24,9 @@ create table llx_c_tva
   fk_pays           integer NOT NULL,
   taux              double  NOT NULL,
   localtax1         double  NOT NULL DEFAULT 0,
-  localtax1_type	varchar(10)	NOT NULL DEFAULT '0',
+  localtax1_type	varchar(10)	 NOT NULL DEFAULT '0',
   localtax2         double  NOT NULL DEFAULT 0,
-  localtax2_type	varchar(10)	NOT NULL DEFAULT '0',
+  localtax2_type	varchar(10) NOT NULL DEFAULT '0',
   recuperableonly   integer NOT NULL DEFAULT 0,
   note              varchar(128),
   active            tinyint DEFAULT 1 NOT NULL,
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 785f131b61bf0225c3cc5951bc1782ae4e5ca1a5..1ce21c7a8f661a0cc185600a3752f87e9c31e0d4 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -390,6 +390,7 @@ AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be
 ToMakePayment=Pay
 ToMakePaymentBack=Pay back
 ListOfYourUnpaidInvoices=List of unpaid invoices
+RevenueStamp=Revenue stamp
 ##### Types de contacts #####
 TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice
 TypeContact_facture_external_BILLING=Customer invoice contact
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index 51424be1cbfa619777e291c655537de15104534b..e5955167dd868ac0552bd7d15d0df781a39e88bb 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -387,6 +387,7 @@ AllCompletelyPayedInvoiceWillBeClosed=Toutes les factures avec un reste à payer
 ToMakePayment=Payer
 ToMakePaymentBack=Rembourser
 ListOfYourUnpaidInvoices=Liste des factures impayées
+RevenueStamp=Timbre fiscal
 ##### Types de contacts #####
 TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client
 TypeContact_facture_external_BILLING=Contact client facturation
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index c87a6ef11f411c23e87caee5930b0cdee025cca9..ecf387e13c2d97f5cfef2488dd76c29a63898d4e 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -82,7 +82,9 @@ class Societe extends CommonObject
     var $idprof1;	// IdProf1 (Ex: Siren in France)
     var $idprof2;	// IdProf2 (Ex: Siret in France)
     var $idprof3;	// IdProf3 (Ex: Ape in France)
-    var $idprof4;	// IdProf4 (Ex: RCS in France)
+    var $idprof4;	// IdProf4 (Ex: RCS in France)
+    var $idprof5;	// IdProf5
+    var $idprof6;	// IdProf6
 
     var $prefix_comm;
 
@@ -2599,40 +2601,53 @@ class Societe extends CommonObject
     }
 
     /**
-     *  Check if localtax define for company
-     *  Used to build previews or test instances.
-     *	id must be 0 if object instance is a specimen.
+     *  Check if thirdparty may using localtax or not
      *
-     *  @param	localTaxNum	$localTaxNum        1 or 2
-     *  @return boolean             			true / false
+     *	@param		int		$localTaxNum	To get info for only localtax1 or localtax2
+     *  @return		array					array(0=>boolean, 1=>boolean)
      */
-    function hasLocalTax($localTaxNum) {
-        global $user,$langs,$conf;
-
-        // check parameter
-        if ($localTaxNum != 1 && $localTaxNum != 2)
-            return false;
-
-		// Search local taxes
-		$sql  = "SELECT t.localtax1, t.localtax2";
-		$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
-		$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$this->country_code."'";
-		$sql .= " AND t.active = 1";
-        if ($localTaxNum == 1)
-            $sql .= " AND t.localtax1 <> 0";
-        elseif ($localTaxNum == 2)
-            $sql .= " AND t.localtax2 <> 0";
-
-		dol_syslog("get_localtax sql=".$sql);
+    function useLocalTax($localTaxNum=0)
+    {
+    	$sql  = "SELECT t.localtax1, t.localtax2";
+    	$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
+    	$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$this->country_code."'";
+    	$sql .= " AND t.active = 1";
+    	if (empty($localTaxNum))   $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')";
+    	elseif ($localTaxNum == 1) $sql .= " AND t.localtax1_type <> '0'";
+    	elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'";
+
+    	dol_syslog("useLocalTax sql=".$sql);
+    	$resql=$this->db->query($sql);
+    	if ($resql)
+    	{
+   			return ($this->db->num_rows($resql) > 0);
+    	}
+    	else return false;
+    }
+
+    /**
+     *  Check if thirdparty is from a country using revenue stamps
+     *
+     *  @return		boolean			Yes or no
+     */
+    function useRevenueStamp()
+    {
+		$sql  = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."c_revenuestamp as r, ".MAIN_DB_PREFIX."c_pays as p";
+		$sql .= " WHERE r.fk_pays = p.rowid AND p.code = '".$this->country_code."'";
+		$sql .= " AND r.active = 1";
+
+		dol_syslog("useRevenueStamp sql=".$sql);
 		$resql=$this->db->query($sql);
 		if ($resql)
 		{
-   			return ($this->db->num_rows($resql) > 0);
-
+			$obj=$this->db->fetch_object($resql);
+   			return (($obj->nb > 0)?true:false);
 		}
 		else
-		    return false;
-
+		{
+			$this->error=$this->db->lasterror();
+			return false;
+		}
 	}
 
 	/**
@@ -2752,7 +2767,7 @@ class Societe extends CommonObject
 	/**
 	 *  Set commnunication level
 	 *
-	 *  @param  User	$user		Utilisateur qui definie la remise
+	 *  @param  User	$user		User making change
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
 	function set_commnucation_level($user)
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index feb1b6164e053a98cc4e846b0dea29b3f1ef8617..37ff6735df5ddcb1b52d89b751994d81010d7c73 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -912,6 +912,11 @@ class User extends CommonObject
 		$this->office_phone	= $contact->phone_pro;
 		$this->office_fax	= $contact->fax;
 		$this->user_mobile	= $contact->phone_mobile;
+		$this->address      = $contact->address;
+		$this->zip          = $contact->zip;
+		$this->town         = $contact->town;
+		$this->state_id     = $contact->state_id;
+		$this->country_id   = $contact->country_id;
 
 		if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4));
 		$this->login = $login;
@@ -974,11 +979,16 @@ class User extends CommonObject
 
 		// Positionne parametres
 		$this->admin = 0;
-		$this->lastname = $member->lastname;
-		$this->firstname = $member->firstname;
-		$this->email = $member->email;
-		$this->fk_member = $member->id;
-		$this->pass = $member->pass;
+		$this->lastname     = $member->lastname;
+		$this->firstname    = $member->firstname;
+		$this->email        = $member->email;
+		$this->fk_member    = $member->id;
+		$this->pass         = $member->pass;
+		$this->address      = $member->address;
+		$this->zip          = $member->zip;
+		$this->town         = $member->town;
+		$this->state_id     = $member->state_id;
+		$this->country_id   = $member->country_id;
 
 		if (empty($login)) $login=strtolower(substr($member->firstname, 0, 4)) . strtolower(substr($member->lastname, 0, 4));
 		$this->login = $login;
@@ -1120,6 +1130,11 @@ class User extends CommonObject
 		$sql.= ", firstname = '".$this->db->escape($this->firstname)."'";
 		$sql.= ", login = '".$this->db->escape($this->login)."'";
 		$sql.= ", admin = ".$this->admin;
+		$sql.= ", address = '".$this->db->escape($this->address)."'";
+		$sql.= ", zip = '".$this->db->escape($this->zip)."'";
+		$sql.= ", town = '".$this->db->escape($this->town)."'";
+		$sql.= ", fk_state = '".$this->db->escape($this->state_id)."'";
+		$sql.= ", fk_country = '".$this->db->escape($this->country_id)."'";
 		$sql.= ", office_phone = '".$this->db->escape($this->office_phone)."'";
 		$sql.= ", office_fax = '".$this->db->escape($this->office_fax)."'";
 		$sql.= ", user_mobile = '".$this->db->escape($this->user_mobile)."'";