LP#1423813: adjust some queries to account for deleted copy locations
authorGalen Charlton <gmc@esilibrary.com>
Mon, 23 Feb 2015 21:03:41 +0000 (21:03 +0000)
committerBen Shum <bshum@biblio.org>
Mon, 23 Feb 2015 22:07:06 +0000 (17:07 -0500)
This patch adjusts some queries so that if a copy location
is deleted, any undeleted items that are attached to it
are considered deleted for the purpose of generating
OPAC item lists and seeing if items are potentially available
to fill hold request.

It should be noted that if a copy location is marked as
logically deleted, there shouldn't be any undeleted
copies associated with it.  However, as this condition is not
presently enforced by a database contraint, adding additional
checks on acpl.deleted provides some additional defense.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 09c30ee..b560bc9 100644 (file)
@@ -2021,7 +2021,10 @@ sub basic_opac_copy_query {
                     filter => {checkin_time => undef}
                 },
                 acpl => {
-                    ($staff ? () : (filter => { opac_visible => 't' }))
+                    filter => {
+                        deleted => 'f',
+                        ($staff ? () : ( opac_visible => 't' )),
+                    },
                 },
                 ccs => {
                     ($staff ? () : (filter => { opac_visible => 't' }))
index a5f9e7e..5061f24 100644 (file)
@@ -2577,7 +2577,11 @@ sub _check_title_hold_is_possible {
                         fkey   => 'call_number',
                         filter => { record => $titleid }
                     },
-                    acpl => { field => 'id', filter => { holdable => 't'}, fkey => 'location' },
+                    acpl => {
+                                field => 'id',
+                                filter => { holdable => 't', deleted => 'f' },
+                                fkey => 'location'
+                            },
                     ccs  => { field => 'id', filter => { holdable => 't'}, fkey => 'status'   },
                     acpm => { field => 'target_copy', type => 'left' } # ignore part-linked copies
                 }
@@ -2698,7 +2702,11 @@ sub _check_issuance_hold_is_possible {
                         fkey   => 'id',
                         filter => { issuance => $issuanceid }
                     },
-                    acpl => { field => 'id', filter => { holdable => 't'}, fkey => 'location' },
+                    acpl => {
+                        field => 'id',
+                        filter => { holdable => 't', deleted => 'f' },
+                        fkey => 'location'
+                    },
                     ccs  => { field => 'id', filter => { holdable => 't'}, fkey => 'status'   }
                 }
             },
@@ -2835,7 +2843,11 @@ sub _check_monopart_hold_is_possible {
                         fkey   => 'id',
                         filter => { part => $partid }
                     },
-                    acpl => { field => 'id', filter => { holdable => 't'}, fkey => 'location' },
+                    acpl => {
+                        field => 'id',
+                        filter => { holdable => 't', deleted => 'f' },
+                        fkey => 'location'
+                    },
                     ccs  => { field => 'id', filter => { holdable => 't'}, fkey => 'status'   }
                 }
             },
@@ -3806,7 +3818,11 @@ sub hold_has_copy_at {
         select => {acp => ['id'], acpl => ['name']},
         from   => {
             acp => {
-                acpl => {field => 'id', filter => { holdable => 't'}, fkey => 'location'},
+                acpl => {
+                    field => 'id',
+                    filter => { holdable => 't', deleted => 'f' },
+                    fkey => 'location'
+                },
                 ccs  => {field => 'id', filter => { holdable => 't'}, fkey => 'status'  }
             }
         },