From 91201d1923a7498b95ab0adb7540a00636e413c3 Mon Sep 17 00:00:00 2001
From: Thomas Berezansky <tsbere@mvlc.org>
Date: Tue, 15 Nov 2011 11:08:00 -0500
Subject: [PATCH] Skip shelved holds at checkout auto-fill

Already happened for volume/title hold, but target map checking wasn't
checking to see if the current copy was shelved.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---
 .../src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm    | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
index 720bc68659..2b99396bd0 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
@@ -1716,6 +1716,11 @@ sub find_related_user_hold {
                 ahcm => {
                     field => 'hold',
                     fkey => 'id'
+                },
+                acp => {
+                    field => 'id', 
+                    fkey => 'current_copy',
+                    type => 'left' # there may be no current_copy
                 }
             }
         }, 
@@ -1732,6 +1737,12 @@ sub find_related_user_hold {
             '+ahcm' => {
                 target_copy => $self->copy->id
             },
+            '+acp' => {
+                '-or' => [
+                    {id => undef}, # left-join copy may be nonexistent
+                    {status => {'!=' => OILS_COPY_STATUS_ON_HOLDS_SHELF}},
+                ]
+            }
         },
         order_by => {ahr => {request_time => {direction => 'asc'}}},
         limit => 1
-- 
2.11.0