From 7c2106807ab091233099dd4ae5937bd1e80d0bb4 Mon Sep 17 00:00:00 2001
From: Mike Rylander <mrylander@gmail.com>
Date: Mon, 17 Sep 2018 10:19:34 -0400
Subject: [PATCH] LP#1792621: Ignore deleted items on hold shelf

The hold shelf rewrite brought back an old behavioral bug where items deleted
while on the hold shelf continued to show on the hold shelf list.  The most
recent behavior was to ignore those items, which this commit does.  It also
addresses an adjacent issue where holds may show with "Hold Shelf Delay"
instead of "Ready For Pickup" in some cases.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Signed-off-by: Ben Shum <ben@evergreener.net>
---
 .../src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm   | 3 ++-
 Open-ILS/web/js/ui/default/staff/circ/holds/app.js                     | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
index 045c5e5b39..527f029158 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
@@ -2170,7 +2170,7 @@ SELECT  h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time
              WHEN cp.status = 6 THEN 3
              WHEN EXTRACT(EPOCH FROM COALESCE(NULLIF(BTRIM(hold_wait_time.value,'"'),''),'0 seconds')::INTERVAL) = 0 THEN 4
              WHEN NOW() + COALESCE(NULLIF(BTRIM(hold_wait_time.value,'"'),''),'0 seconds')::INTERVAL > NOW() THEN 5
-             ELSE 5
+             ELSE 4
         END AS hold_status,
 
         (h.shelf_expire_time < NOW() OR h.cancel_time IS NOT NULL OR (h.current_shelf_lib IS NOT NULL AND h.current_shelf_lib <> h.pickup_lib)) AS clear_me,
@@ -2377,6 +2377,7 @@ SELECT  h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time
         usr_id => 'u.id',
         cs_id => 'cs.id',
         cp_id => 'cp.id',
+        cp_deleted => 'cp.deleted',
         cancel_time => 'h.cancel_time',
         tr_cancel_time => 'tr.cancel_time',
     );
diff --git a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js
index 5ce21aa221..1bd2eed08e 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js
@@ -84,6 +84,7 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
                 last_captured_hold: 'true',
                 capture_time      : { not : null },
                 cs_id             : 8, // on holds shelf
+                cp_deleted        : 'f',
                 fulfillment_time  : null,
                 current_shelf_lib : $scope.pickup_ou.id()
         };
-- 
2.11.0