diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index b91643290310869365d9b849a71a0691a7c334a9..ec1087386471b2389c18929c470cb17035d497d7 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -30,6 +30,7 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 
 // Langs
 $langs->load("accountancy");
@@ -52,6 +53,7 @@ if ($sortfield == "")
 $offset = $conf->liste_limit * $page;
 
 $formventilation = new FormVentilation($db);
+$formother = new FormOther($db);
 
 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
 {
@@ -77,7 +79,20 @@ if ($action == 'delbookkeeping') {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
-} // Export
+}
+elseif ($action == 'delbookkeepingyear') {
+	
+	$delyear = GETPOST('delyear', 'int');
+	
+	if (! empty($delyear)) {
+		$object = new BookKeeping($db);
+		$result = $object->delete_by_year($delyear);
+		Header("Location: list.php");
+		if ($result < 0) {
+			setEventMessages($object->error, $object->errors, 'errors');
+		}
+	}
+}// Export
 else if ($action == 'export_csv') {
 	
 	header('Content-Type: text/csv');
@@ -147,7 +162,7 @@ else {
 		
 		print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
 		
-		print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
+		/*print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
 		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
 		print '<input type="hidden" name="action" value="delbookkeeping">';
 		
@@ -155,6 +170,16 @@ else {
 		
 		print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
 		
+		print '</form>';*/
+		
+		print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
+		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+		print '<input type="hidden" name="action" value="delbookkeepingyear">';
+		
+		print $formother->select_year(GETPOST('delyear'),'delyear');
+		
+		print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
+		
 		print '</form>';
 		
 		print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 141b122690c1468823670bf317330f98762873bc..d3801b4a4d166f5c5cf8bd3dc86529539cc0fdfe 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -372,6 +372,36 @@ class BookKeeping extends CommonObject
 		$this->db->commit();
 		return 1;
 	}
+	
+	/**
+	 * Delete bookkepping by importkey
+	 *
+	 * @param	string 	$delyear		year to delete
+	 * @return	int						Result
+	 */
+	function delete_by_year($delyear) {
+		$this->db->begin();
+	
+		// first check if line not yet in bookkeeping
+		$sql = "DELETE";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
+		$sql .= " WHERE YEAR(doc_date) = ".$delyear;
+	
+		$resql = $this->db->query($sql);
+	
+		if (! $resql) {
+			$this->errors[] = "Error " . $this->db->lasterror();
+			foreach ( $this->errors as $errmsg ) {
+				dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+			}
+			$this->db->rollback();
+			return - 1;
+		}
+	
+		$this->db->commit();
+		return 1;
+	}
 
 	/**
 	 *	Create object into database
diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php
index de94d645c9229de7a27524b7741f27394c3dd550..f92f5b3ab88d106737e71724467dc40c1bcdff8e 100644
--- a/htdocs/accountancy/class/html.formventilation.class.php
+++ b/htdocs/accountancy/class/html.formventilation.class.php
@@ -70,7 +70,7 @@ class FormVentilation extends Form
 					$selected = ' selected ';
 				}
 
-				$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>';
+				$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . dol_print_date($obj->import_key,'dayhourtext') . '</OPTION>';
 
 				$i ++;
 			}
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 820596de166afce91d101231d3f9148940c7ec42..4800737528dea569dd43078df823ec4c72b3da62 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -87,10 +87,10 @@ if (! $user->rights->accounting->ventilation->dispatch)
 	accessforbidden();
 
 $formventilation = new FormVentilation($db);
-
 $accounting = new AccountingAccount($db);
-$aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT);
-$aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
+$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT,1);
+$aarowid_p = $accounting->fetch('',$conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT,1);
+
 
 // Purge search criteria
 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
@@ -278,6 +278,8 @@ if ($result) {
 		
 		$code_sell_p_notset = '';
 		$objp->aarowid_suggest = $objp->aarowid;
+		
+		
 		if (! empty($objp->code_sell)) {
 			$objp->code_sell_p = $objp->code_sell;
 		} else {
@@ -290,12 +292,14 @@ if ($result) {
 		}
 		if ($objp->type_l == 1) {
 			$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
-			if ($objp->aarowid == '')
+			if ($objp->aarowid == '') {
 				$objp->aarowid_suggest = $aarowid_s;
+			}
 		} elseif ($objp->type_l == 0) {
 			$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
-			if ($objp->aarowid == '')
+			if ($objp->aarowid == '') {
 				$objp->aarowid_suggest = $aarowid_p;
+			}
 		}
 		if ($objp->code_sell_l != $objp->code_sell_p)
 			$code_sell_p_l_differ = 'color:red';
@@ -311,10 +315,12 @@ if ($result) {
 		$product_static->id = $objp->product_id;
 		$product_static->type = $objp->type;
 		print '<td>';
+		
 		if ($product_static->id)
 			print $product_static->getNomUrl(1);
 		else
 			print '&nbsp;';
+		
 		print '</td>';
 		
 		print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index be136a38b9836bb8d1081cf77f7833b575d70507..34ebcaf43a9f26b43fd4f5f913417e981a97852c 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -16,7 +16,7 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License fr more details.
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -57,7 +57,7 @@ $langs->load("bank");
 $langs->load('bills');
 $langs->load("accountancy");
 
-$id_accountancy_journal = GETPOST('id_account','int');
+$id_bank_account = GETPOST('id_account','int');
 
 $date_startmonth = GETPOST('date_startmonth');
 $date_startday = GETPOST('date_startday');
@@ -70,17 +70,12 @@ $action = GETPOST('action');
 $now = dol_now();
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->societe_id > 0 && empty($id_bank_account))
 	accessforbidden();
 
 /*
  * View
  */
-if (empty($id_accountancy_journal))
-{
-	accessforbidden();
-}
-
 $year_current = strftime("%Y", dol_now());
 $pastmonth = strftime("%m", dol_now()) - 1;
 $pastmonthyear = $year_current;
@@ -107,7 +102,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
 $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
-$sql .= " WHERE ba.rowid=".$id_accountancy_journal;
+$sql .= " WHERE ba.rowid=".$id_bank_account;
 if (! empty($conf->multicompany->enabled)) {
 	$sql .= " AND ba.entity = " . $conf->entity;
 }
@@ -125,7 +120,12 @@ $paymentdonstatic = new PaymentDonation($db);
 $paymentvatstatic = new TVA($db);
 $paymentsalstatic = new PaymentSalary($db);
 
-dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG);
+// Get code of finance journal
+$bank_code_journal = new Account($db);
+$result=$bank_code_journal->fetch($id_bank_account);
+$journal=$bank_code_journal->accountancy_journal;
+
+dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
 $result = $db->query($sql);
 if ($result) {
 
@@ -288,8 +288,10 @@ if ($result) {
  */
 
 // Write bookkeeping
-if ($action == 'writeBookKeeping')
+if ($action == 'writebookkeeping')
 {
+	$now=dol_now();
+	
 	$error = 0;
 	foreach ( $tabpay as $key => $val )
 	{
@@ -309,8 +311,9 @@ if ($action == 'writeBookKeeping')
 			$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
 			$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
 			$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
-			$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
+			$bookkeeping->code_journal = $journal;
 			$bookkeeping->fk_user_author = $user->id;
+			$bookkeeping->date_create=$now;
 
 			if ($tabtype[$key] == 'payment') {
 
@@ -327,7 +330,7 @@ if ($action == 'writeBookKeeping')
 				}
 			} else if ($tabtype[$key] == 'payment_supplier') {
 
-				$sqlmid = 'SELECT facf.facnumber';
+				$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
 				$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
 				$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON  payfacf.fk_facturefourn=facf.rowid";
 				$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON  payfacf.fk_paiementfourn=payf.rowid";
@@ -336,7 +339,7 @@ if ($action == 'writeBookKeeping')
 				$resultmid = $db->query($sqlmid);
 				if ($resultmid) {
 					$objmid = $db->fetch_object($resultmid);
-					$bookkeeping->doc_ref = $objmid->facnumber;
+					$bookkeeping->doc_ref = $objmid->ref_supplier.' ('.$objmid->ref.')';;
 				}
 			}
 
@@ -360,8 +363,9 @@ if ($action == 'writeBookKeeping')
 			$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
 			$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
 			$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
-			$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
+			$bookkeeping->code_journal = $journal;
 			$bookkeeping->fk_user_author = $user->id;
+			$bookkeeping->date_create=$now;
 
 			if ($tabtype[$key] == 'sc') {
 				$bookkeeping->code_tiers = '';
@@ -383,7 +387,7 @@ if ($action == 'writeBookKeeping')
 				$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
 			} else if ($tabtype[$key] == 'payment_supplier') {
 
-				$sqlmid = 'SELECT facf.facnumber';
+				$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
 				$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
 				$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON  payfacf.fk_facturefourn=facf.rowid";
 				$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON  payfacf.fk_paiementfourn=payf.rowid";
@@ -392,7 +396,7 @@ if ($action == 'writeBookKeeping')
 				$resultmid = $db->query($sqlmid);
 				if ($resultmid) {
 					$objmid = $db->fetch_object($resultmid);
-					$bookkeeping->doc_ref = $objmid->facnumber;
+					$bookkeeping->doc_ref = $objmid->ref_supplier.' ('.$objmid->ref.')';
 				}
 				$bookkeeping->code_tiers = $k;
 				$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
@@ -433,7 +437,6 @@ if ($action == 'writeBookKeeping')
 if ($action == 'export_csv')
 {
 	$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
-	$journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
 
 	include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
 
@@ -443,16 +446,20 @@ if ($action == 'export_csv')
 	{
 		$sep = ";";
 
-		foreach ( $tabpay as $key => $val ) {
+		foreach ($tabpay as $key => $val) 
+		{
 			$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
 
 			$companystatic->id = $tabcompany[$key]['id'];
 			$companystatic->name = $tabcompany[$key]['name'];
+			$companystatic->client = $tabcompany[$key]['code_client'];
+			
+			$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
 
 			// Bank
 			foreach ( $tabbq[$key] as $k => $mt ) {
 				print $date . $sep;
-				print $bank_journal . $sep;
+				print $journal . $sep;
 				print length_accountg(html_entity_decode($k)) . $sep;
 				print $sep;
 				print ($mt < 0 ? 'C' : 'D') . $sep;
@@ -557,67 +564,26 @@ if ($action == 'export_csv')
 			}
 		}
 	}
-}
-else
+} 
+else 
 {
-
 	$form = new Form($db);
 
-	llxHeader('', $langs->trans("BankJournal"));
+	llxHeader('', $langs->trans("FinanceJournal"));
 
-	$namereport = $langs->trans("BankJournal");
-	$description = $langs->trans("DescBankJournal");
+	$nom = $langs->trans("FinanceJournal" . ' - ' . $journal);
+	$builddate = time();
+	$description = $langs->trans("DescFinanceJournal") . '<br>';
 	$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
 
-	// Report
-	$h=0;
-	$head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal;
-	$head[$h][1] = $langs->trans("Report");
-	$head[$h][2] = 'card';
-
-	dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment');
-
-	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">';
-	print '<table width="100%" class="border">';
-
-	// Title
-	print '<tr>';
-	print '<td width="110">'.$langs->trans("ReportName").'</td>';
-	print '<td colspan="3">'.$namereport.'</td>';
-	print '</td>';
-	print '</tr>';
-
-	// Period report
-	print '<tr>';
-	print '<td>'.$langs->trans("ReportPeriod").'</td>';
-	if (! $periodlink) print '<td colspan="3">';
-	else print '<td>';
-	if ($period) print $period;
-	if ($periodlink) print '</td><td colspan="2">'.$periodlink;
-	print '</td>';
-	print '</tr>';
-
-	// Description
-	print '<tr>';
-	print '<td>'.$langs->trans("ReportDescription").'</td>';
-	print '<td colspan="3">'.$description.'</td>';
-	print '</tr>';
-
-	print '<tr>';
-	print '<td colspan="4" align="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></td>';
-	print '</tr>';
-
-	print '</table>';
-
-	print '</form>';
-
-	print '</div>';
-	// End report
+	$varlink = 'id_account='.$id_bank_account;
+	report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
 
+	
 	print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
 
-	print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
-
+	print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
+	
 	print '
 	<script type="text/javascript">
 		function launch_export() {
@@ -625,8 +591,8 @@ else
 			$("div.fiche div.tabBar form input[type=\"submit\"]").click();
 		    $("div.fiche div.tabBar form input[name=\"action\"]").val("");
 		}
-		function writeBookKeeping() {
-		    $("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
+		function writebookkeeping() {
+		    $("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
 			$("div.fiche div.tabBar form input[type=\"submit\"]").click();
 		    $("div.fiche div.tabBar form input[name=\"action\"]").val("");
 		}
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 538edaa471ddf8246f8ed4dcdeab6916487fbe4c..9d41a7cf07c9b576454b53ea5e74b7d2a9f09661 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -86,7 +86,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
 $idpays = $p[0];
 
-$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,";
+$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,";
 $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
 $sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,";
 $sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
@@ -137,7 +137,7 @@ if ($result) {
 		$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
 
 		$tabfac[$obj->rowid]["date"] = $obj->df;
-		$tabfac[$obj->rowid]["ref"] = $obj->ref;
+		$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')';
 		$tabfac[$obj->rowid]["type"] = $obj->type;
 		$tabfac[$obj->rowid]["description"] = $obj->description;
 		$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 891d8b1439ed0d9cfdcf55bfea652df397f76d76..c94c8612535ba98d61a1c646034a70b166ed03b4 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -94,8 +94,8 @@ $formventilation = new FormVentilation($db);
 $accounting = new AccountingAccount($db);
 
 // TODO: we should need to check if result is a really exist accountaccount rowid.....
-$aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_BUY_ACCOUNT);
-$aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_BUY_ACCOUNT);
+$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT,1);
+$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT,1);
 
 // Purge search criteria
 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php
index 8946449d5aceb12b222aa5b7094745c6e8f3efb2..9441482d163ab476e213e79b477ec12d7285af6f 100644
--- a/htdocs/core/lib/report.lib.php
+++ b/htdocs/core/lib/report.lib.php
@@ -35,9 +35,10 @@
 *	@param 	string				$exportlink     Link for export or ''
 *	@param		array				$moreparam		Array with list of params to add into form
 *	@param		string				$calcmode		Calculation mode
+*    @param     string              $varlink        Add a variable into the address of the page
 *	@return	void
 */
-function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='')
+function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
 {
 	global $langs;
 
@@ -45,14 +46,16 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
 	
 	print "\n\n<!-- debut cartouche rapport -->\n";
 
+	if(! empty($varlink)) $varlink = '?'.$varlink;
+
 	$h=0;
-	$head[$h][0] = $_SERVER["PHP_SELF"];
+	$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
 	$head[$h][1] = $langs->trans("Report");
 	$head[$h][2] = 'report';
 
 	dol_fiche_head($head, 'report');
 
-	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
 	foreach($moreparam as $key => $value)
 	{
 		 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
@@ -115,7 +118,8 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
 
 	print '</form>';
 
-	print '</div>';
+	dol_fiche_end();
+	
 	print "\n<!-- fin cartouche rapport -->\n\n";
 }
 
diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
index d7907e15a1de40d2108a4c25e9d9d28fdb155628..1d8f3f223e17a89bb11105af300cdf2e3071ec59 100755
--- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
+++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
@@ -493,8 +493,7 @@ INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) V
 INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'W','WIEN','Wien',1);
 
 
-
--- Austria
+-- Juridical status Austria
 INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4100', 'GmbH - Gesellschaft mit beschränkter Haftung', 1);
 INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4101', 'GesmbH - Gesellschaft mit beschränkter Haftung', 1);
 INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4102', 'AG - Aktiengesellschaft', 1);
@@ -511,11 +510,7 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '
 INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4113', 'GesnbR - Gesellschaft nach bürgerlichem Recht', 1);
 INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4114', 'e.U. - eingetragener Einzelunternehmer', 1);
 
-
-
---
--- Austria
---
+-- Social contributions Austria
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4101, 'Krankenversicherung',				1,1,'TAXATKV'   ,'41');
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4102, 'Unfallversicherung',				1,1,'TAXATUV'   ,'41');
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4103, 'Pensionsversicherung',				1,1,'TAXATPV'   ,'41');
@@ -525,3 +520,6 @@ insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4107, 'Arbeiterkammerumlage',				1,1,'TAXATAK'   ,'41');
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4108, 'Mitarbeitervorsorgekasse',			1,1,'TAXATMVK'  ,'41');
 insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays) values (4109, 'Familienlastenausgleichsfond',		1,1,'TAXATFLAF' ,'41');
+
+ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN doc_ref varchar(255) NOT NULL;
+
diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
index 5e2be869a9ffec5f114c3837dd3da2b333833bb4..660dd4745b321fcf90db5f8ef62b2d91c00adb36 100644
--- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
@@ -22,7 +22,7 @@ CREATE TABLE llx_accounting_bookkeeping
   rowid				integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
   doc_date			date NOT NULL,
   doc_type			varchar(30) NOT NULL,	-- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur
-  doc_ref			varchar(30) NOT NULL,	-- facture_client/reglement_client/... reference number
+  doc_ref			varchar(255) NOT NULL,	-- facture_client/reglement_client/... reference number
   fk_doc			integer NOT NULL,		-- facture_client/reglement_client/... rowid
   fk_docdet			integer NOT NULL,		-- facture_client/reglement_client/... line rowid
   code_tiers		varchar(24),			-- code tiers