lp1616170 Transit __abort Refactor
authorKyle Huckins <khuckins@catalyte.io>
Tue, 21 May 2019 22:25:30 +0000 (22:25 +0000)
committerKyle Huckins <khuckins@catalyte.io>
Thu, 6 Jun 2019 16:19:14 +0000 (16:19 +0000)
- Add reshelve_on_checkin copy status column, applied to
all copy statuses previously hardcoded to check situations
where items would either reshelve on checkin, or retain their
original status  upon aborting transit.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/examples/fm_IDL.xml
modified:   Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm
modified:   Open-ILS/src/sql/Pg/002.schema.config.sql
modified:   Open-ILS/src/sql/Pg/950.data.seed-values.sql
modified:   Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1616170-custom-copy-status-maintainability.sql

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1616170-custom-copy-status-maintainability.sql

index efa592b..b32dd02 100644 (file)
@@ -4374,6 +4374,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             <field name="restrict_copy_delete" reporter:datatype="bool"/>
             <field name="is_available" reporter:datatype="bool"/>
             <field name="checkin_ok" reporter:datatype="bool"/>
+            <field name="reshelve_on_checkin" reporter:datatype="bool"/>
             <field name="copy_status_event" reporter:datatype="text"/>
                </fields>
                <links/>
index f627b99..80d1362 100644 (file)
@@ -246,16 +246,11 @@ sub __abort_transit {
     return $e->die_event unless $e->update_action_transit_copy($transit);
 
     # Only change the copy status if the copy status is "In Transit."
+    my $t_status = $U->copy_status($transit->copy_status);
+
     if ($copy->status == OILS_COPY_STATUS_IN_TRANSIT) {
         # if the status would normally result in 'Reshelving' once the item is checked in
-        if ($transit->copy_status == OILS_COPY_STATUS_AVAILABLE   ||
-            $transit->copy_status == OILS_COPY_STATUS_CHECKED_OUT ||
-            $transit->copy_status == OILS_COPY_STATUS_IN_PROCESS  ||
-            $transit->copy_status == OILS_COPY_STATUS_ON_HOLDS_SHELF  ||
-            $transit->copy_status == OILS_COPY_STATUS_IN_TRANSIT  ||
-            $transit->copy_status == OILS_COPY_STATUS_CATALOGING  ||
-            $transit->copy_status == OILS_COPY_STATUS_ON_RESV_SHELF  ||
-            $transit->copy_status == OILS_COPY_STATUS_RESHELVING) {
+        if ($t_status->reshelve_on_checkin) {
             # set copy to Canceled Transit
             $copy->status( OILS_COPY_STATUS_CANCELED_TRANSIT);
         } else {
index 68543d0..0f02363 100644 (file)
@@ -444,6 +444,7 @@ CREATE TABLE config.copy_status (
        restrict_copy_delete BOOL         NOT NULL DEFAULT FALSE,
     is_available  BOOL    NOT NULL DEFAULT FALSE,
     checkin_ok    BOOL    NOT NULL DEFAULT FALSE,
+    reshelve_on_checkin    BOOL    NOT NULL DEFAULT FALSE,
     copy_status_event    TEXT
 );
 COMMENT ON TABLE config.copy_status IS $$
index 697c172..84867ae 100644 (file)
@@ -523,22 +523,22 @@ INSERT INTO config.rule_age_hold_protect VALUES
        (2, oils_i18n_gettext(2, '6month', 'crahp', 'name'), '6 months', 2);
 SELECT SETVAL('config.rule_age_hold_protect_id_seq'::TEXT, 100);
 
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,is_available,checkin_ok) VALUES (0,oils_i18n_gettext(0, 'Available', 'ccs', 'name'),'t','t','t','t','t');
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete,checkin_ok) VALUES (1,oils_i18n_gettext(1, 'Checked out', 'ccs', 'name'),'t','t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,is_available,checkin_ok,reshelve_on_checkin) VALUES (0,oils_i18n_gettext(0, 'Available', 'ccs', 'name'),'t','t','t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete,checkin_ok,reshelve_on_checkin) VALUES (1,oils_i18n_gettext(1, 'Checked out', 'ccs', 'name'),'t','t','t','t','t','t',);
 INSERT INTO config.copy_status (id,name) VALUES (2,oils_i18n_gettext(2, 'Bindery', 'ccs', 'name'));
 INSERT INTO config.copy_status (id,name,restrict_copy_delete,copy_status_event) VALUES (3,oils_i18n_gettext(3, 'Lost', 'ccs', 'name'),'t','COPY_STATUS_LOST');
 INSERT INTO config.copy_status (id,name,copy_status_event) VALUES (4,oils_i18n_gettext(4, 'Missing', 'ccs', 'name'),'t');
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,checkin_ok) VALUES (5,oils_i18n_gettext(5, 'In process', 'ccs', 'name'),'t','t','t');
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,restrict_copy_delete,checkin_ok) VALUES (6,oils_i18n_gettext(6, 'In transit', 'ccs', 'name'),'t','t','t','t');
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,is_available,checkin_ok) VALUES (7,oils_i18n_gettext(7, 'Reshelving', 'ccs', 'name'),'t','t','t','t','t');
-INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete,checkin_ok) VALUES (8,oils_i18n_gettext(8, 'On holds shelf', 'ccs', 'name'),'t','t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,checkin_ok,reshelve_on_checkin) VALUES (5,oils_i18n_gettext(5, 'In process', 'ccs', 'name'),'t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,restrict_copy_delete,checkin_ok,reshelve_on_checkin) VALUES (6,oils_i18n_gettext(6, 'In transit', 'ccs', 'name'),'t','t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,is_available,checkin_ok,reshelve_on_checkin) VALUES (7,oils_i18n_gettext(7, 'Reshelving', 'ccs', 'name'),'t','t','t','t','t','t');
+INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete,checkin_ok,reshelve_on_checkin) VALUES (8,oils_i18n_gettext(8, 'On holds shelf', 'ccs', 'name'),'t','t','t','t','t','t');
 INSERT INTO config.copy_status (id,name,holdable,opac_visible) VALUES (9,oils_i18n_gettext(9, 'On order', 'ccs', 'name'),'t','t');
 INSERT INTO config.copy_status (id,name,copy_active) VALUES (10,oils_i18n_gettext(10, 'ILL', 'ccs', 'name'),'t');
-INSERT INTO config.copy_status (id,name,checkin_ok) VALUES (11,oils_i18n_gettext(11, 'Cataloging', 'ccs', 'name'),'t');
+INSERT INTO config.copy_status (id,name,checkin_ok,reshelve_on_checkin) VALUES (11,oils_i18n_gettext(11, 'Cataloging', 'ccs', 'name'),'t','t');
 INSERT INTO config.copy_status (id,name,opac_visible,copy_active) VALUES (12,oils_i18n_gettext(12, 'Reserves', 'ccs', 'name'),'t','t');
 INSERT INTO config.copy_status (id,name) VALUES (13,oils_i18n_gettext(13, 'Discard/Weed', 'ccs', 'name'));
 INSERT INTO config.copy_status (id,name) VALUES (14,oils_i18n_gettext(14, 'Damaged', 'ccs', 'name'));
-INSERT INTO config.copy_status (id,name,copy_active,checkin_ok) VALUES (15,oils_i18n_gettext(15, 'On reservation shelf', 'ccs', 'name'),'t','t');
+INSERT INTO config.copy_status (id,name,copy_active,checkin_ok,reshelve_on_checkin) VALUES (15,oils_i18n_gettext(15, 'On reservation shelf', 'ccs', 'name'),'t','t','t');
 INSERT INTO config.copy_status
     (id, name, holdable, opac_visible, copy_active, restrict_copy_delete, copy_status_event)
     VALUES (16, oils_i18n_gettext(16, 'Long Overdue', 'ccs', 'name'), 'f', 'f', 'f', 't', 'COPY_STATUS_LONG_OVERDUE');
index 737c346..6fa449a 100644 (file)
@@ -4,6 +4,7 @@ SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
 
 ALTER TABLE config.copy_status
     ADD COLUMN checkin_ok BOOL NOT NULL DEFAULT FALSE,
+    ADD COLUMN reshelve_on_checkin BOOL NOT NULL DEFAULT FALSE,
     ADD COLUMN copy_status_event TEXT;
 
     -- Update checkin_ok
@@ -23,4 +24,14 @@ ALTER TABLE config.copy_status
     UPDATE config.copy_status SET copy_status_event = 'COPY_STATUS_LONG_OVERDUE' WHERE id = 16;
     UPDATE config.copy_status SET copy_status_event = 'COPY_STATUS_LOST_AND_PAID' WHERE id = 17;
 
+    -- Update abort_transit_cancel
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 0;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 1;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 5;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 6;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 7;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 8;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 11;
+    UPDATE config.copy_status SET reshelve_on_checkin = true WHERE id = 15;
+
 COMMIT;