From 692317232351840d9f061a3b2e4137dd0720632a Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 17 May 2021 17:14:04 +0100
Subject: [PATCH] Bug 28294: Add 'WrongTransfer' to transfer reason enum

This patch adds the 'WrongTransfer' value to the 'reason' enum in the
branchtransfers table.  This is so we can use it as a reason for the
subsequent transfer when a trainsfer is triggered by a checkin at an
incorrect branch after transfer has been initiated.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
---
 .../data/mysql/atomicupdate/bug_28294.pl      | 30 +++++++++++++++++++
 installer/data/mysql/kohastructure.sql        |  2 +-
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100755 installer/data/mysql/atomicupdate/bug_28294.pl

diff --git a/installer/data/mysql/atomicupdate/bug_28294.pl b/installer/data/mysql/atomicupdate/bug_28294.pl
new file mode 100755
index 00000000000..484c922a2f5
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_28294.pl
@@ -0,0 +1,30 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+
+    # Add 'WrongTransfer' to branchtransfers cancellation_reason enum
+    $dbh->do(
+        q{
+            ALTER TABLE
+                `branchtransfers`
+            MODIFY COLUMN
+                `reason` enum(
+                    'Manual',
+                    'StockrotationAdvance',
+                    'StockrotationRepatriation',
+                    'ReturnToHome',
+                    'ReturnToHolding',
+                    'RotatingCollection',
+                    'Reserve',
+                    'LostReserve',
+                    'CancelReserve',
+                    'TransferCancellation',
+                    'Recall',
+                    'RecallCancellation',
+                    'WrongTransfer'
+                )
+            AFTER `comments`
+          }
+    );
+
+    NewVersion( $DBversion, 28294, "Add 'WrongTransfer' to branchtransfers.reason enum");
+}
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 16310f0f449..f393b68d6f2 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1692,7 +1692,7 @@ CREATE TABLE `branchtransfers` (
   `datecancelled` datetime DEFAULT NULL COMMENT 'the date the transfer was cancelled',
   `tobranch` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch the transfer was going to',
   `comments` longtext DEFAULT NULL COMMENT 'any comments related to the transfer',
-  `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer',
+  `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation','WrongTransfer') DEFAULT NULL COMMENT 'what triggered the transfer',
   `cancellation_reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','ItemLost','WrongTransfer','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer cancellation',
   PRIMARY KEY (`branchtransfer_id`),
   KEY `frombranch` (`frombranch`),
-- 
2.43.0