From 1be389fd3e3b874c0362376e73dfb95dd342f568 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 27 Feb 2017 12:06:45 +0100
Subject: [PATCH] FIX deletion of bank tag

---
 htdocs/compta/bank/class/bankcateg.class.php | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php
index 02d80d7429c..6ceca940571 100644
--- a/htdocs/compta/bank/class/bankcateg.class.php
+++ b/htdocs/compta/bank/class/bankcateg.class.php
@@ -202,7 +202,6 @@ class BankCateg // extends CommonObject
 		// Delete link between tag and bank account
 		if (! $error)
 		{
-    		//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";          // No more used
 		    $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
     		$sql.= " WHERE fk_categorie = ".$this->id;
     		
@@ -214,6 +213,20 @@ class BankCateg // extends CommonObject
     		}
 		}
 		
+		// Delete link between tag and bank lines
+		if (! $error)
+		{
+		    $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";          // No more used
+		    $sql.= " WHERE fk_categ = ".$this->id;
+		
+		    $resql = $this->db->query($sql);
+		    if (!$resql)
+		    {
+		        $error++;
+		        $this->errors[] = "Error ".$this->db->lasterror();
+		    }
+		}
+		
 		// Delete bank categ
 		if (! $error)
 		{
-- 
GitLab