Explicitly Support Placing "In-Network" Holds user/jboyer/requestitem_localhold
authorJason Boyer <jboyer@library.in.gov>
Sun, 7 Aug 2016 23:14:45 +0000 (19:14 -0400)
committerJason Boyer <jboyer@library.in.gov>
Sun, 7 Aug 2016 23:14:45 +0000 (19:14 -0400)
In a consortial setting, SHAREit can be told the makeup of your
local "network" of systems, and if an item can be found in-network,
a local hold can be placed instead of an ILL request. Without this
change, the item must be held by the user's home library specifically.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
lib/NCIP/ILS/Evergreen.pm

index 85aa440..16b1f8a 100644 (file)
@@ -2341,8 +2341,12 @@ sub place_hold {
     } elsif (ref($item) eq 'Fieldmapper::biblio::record_entry') {
         $params->{hold_type} = 'T';
         if ($org_unit && ref($org_unit) eq 'Fieldmapper::actor::org_unit') {
-            $params->{selection_ou} = $org_unit->id();
-            $params->{depth} = $org_unit->ou_type->depth() if (ref($org_unit->ou_type()));
+            # If the user home ou is in the same system as our service account assume it's an institutional account and
+            # limit the selection ou and depth, otherwise assume a "regular" hold.
+            if ( $U->org_unit_ancestor_at_depth($user->home_ou->id(), 1) == $U->org_unit_ancestor_at_depth($self->{session}->{work_ou}->id(), 1) ) {
+                $params->{selection_ou} = $org_unit->id();
+                $params->{depth} = $org_unit->ou_type->depth() if (ref($org_unit->ou_type()));
+            }
         }
     }