Bug 27947: Add authorised values list in article requests cancellation
authorAgustin Moyano <agustinmoyano@theke.io>
Fri, 20 Aug 2021 02:00:26 +0000 (23:00 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Oct 2021 08:09:25 +0000 (10:09 +0200)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/atomicupdate/bug_27947.pl [new file with mode: 0755]
installer/data/mysql/en/optional/auth_val.yml
installer/data/mysql/fr-CA/facultatif/auth_val.sql
installer/data/mysql/fr-FR/1-Obligatoire/authorised_values.sql
installer/data/mysql/kohastructure.sql
installer/data/mysql/mandatory/auth_val_cat.sql
installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql

diff --git a/installer/data/mysql/atomicupdate/bug_27947.pl b/installer/data/mysql/atomicupdate/bug_27947.pl
new file mode 100755 (executable)
index 0000000..c1f3009
--- /dev/null
@@ -0,0 +1,41 @@
+use Modern::Perl;
+
+return {
+    bug_number => "27947",
+    description => "Add authorised values list in article requests cancellation",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out column_exists)};
+        # Do you stuffs here
+        $dbh->do(q{
+            INSERT IGNORE INTO authorised_value_categories( category_name, is_system )
+            VALUES ('AR_CANCELLATION', 0)
+        });
+        # Print useful stuff here
+        say $out "Add AR_CANCELLATION category for authorised values";
+
+        $dbh->do(q{
+            INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
+        });
+
+        $dbh->do(q{
+            INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request');
+        });
+
+        say $out "Add AR_CANCELLATION authorised values";
+
+        $dbh->do(q{
+            ALTER TABLE `article_requests` ADD COLUMN `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value AR_CANCELLATION' AFTER `urls`
+        }) unless column_exists('article_requests', 'cancellation_reason');
+
+        # Print useful stuff here
+        say $out "Add cancellation_reason column in article_requests table";
+
+        $dbh->do(q{
+            UPDATE `letter`
+            SET    `content` = 'Dear <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>),\r\n\r\nYour request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason:\r\n\r\n<<reason>>\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\nFormat: [% IF article_request.format == ''PHOTOCOPY'' %]Copy[% ELSIF article_request.format == ''SCAN'' %]Scan[% END %]\r\n\r\nYour library'
+            WHERE   `module` = 'circulation'
+                    AND `code` = 'AR_CANCELED'
+        })
+    },
+}
\ No newline at end of file
index de8baf3..d2497d7 100644 (file)
@@ -300,3 +300,12 @@ tables:
         - category: "HOLD_CANCELLATION"
           authorised_value: "DAMAGED"
           lib: "Item was found to be too damaged to fill hold"
+
+        # article request cancellations
+        - category: "AR_CANCELLATION"
+          authorised_value: "NOT_FOUND"
+          lib: "Item could not be located on shelves"
+
+        - category: "AR_CANCELLATION"
+          authorised_value: "DAMAGED"
+          lib: "Item was found to be too damaged to fill article request"
index fa668ca..c424c3a 100644 (file)
@@ -90,3 +90,7 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('RETURN_
 -- hold cancellation
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','DAMAGED','Item was found to be too damaged to fill hold');
+
+-- article request cancellation
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request');
\ No newline at end of file
index 0f7a6bc..8c70ff0 100644 (file)
@@ -724,3 +724,7 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('RETURN_
 -- hold cancellation
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','DAMAGED','Item was found to be too damaged to fill hold');
+
+-- article request cancellation
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request');
\ No newline at end of file
index 9bd74ac..0976ece 100644 (file)
@@ -753,6 +753,7 @@ CREATE TABLE `article_requests` (
   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   `format` enum('PHOTOCOPY', 'SCAN') NOT NULL DEFAULT 'PHOTOCOPY',
   `urls` MEDIUMTEXT,
+  `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value AR_CANCELLATION',
   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Be careful with two timestamps in one table not allowing NULL',
   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
   PRIMARY KEY (`id`),
index e3bbef0..d185f23 100644 (file)
@@ -18,7 +18,8 @@ INSERT IGNORE INTO authorised_value_categories( category_name, is_system )
     ('PAYMENT_TYPE', 0),
     ('PA_CLASS', 0),
     ('HOLD_CANCELLATION', 0),
-    ('ROADTYPE', 0);
+    ('ROADTYPE', 0),
+    ('AR_CANCELLATION', 0);
 
 INSERT IGNORE INTO authorised_value_categories( category_name, is_system )
     VALUES
index 0901965..86a502d 100644 (file)
@@ -109,3 +109,7 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('RETURN_
 -- hold cancellation
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
 INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('HOLD_CANCELLATION','DAMAGED','Item was found to be too damaged to fill hold');
+
+-- article request cancellation
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves');
+INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request');
\ No newline at end of file