Add duplicate request check to NCIP::ILS::Evergreen->requestitem
authorJason Stephenson <jason@sigio.com>
Tue, 23 Sep 2014 01:51:29 +0000 (21:51 -0400)
committerJason Stephenson <jason@sigio.com>
Tue, 23 Sep 2014 01:56:43 +0000 (21:56 -0400)
Signed-off-by: Jason Stephenson <jason@sigio.com>
lib/NCIP/ILS/Evergreen.pm

index 153875a..2c625ea 100644 (file)
@@ -1830,6 +1830,31 @@ sub place_hold {
         $params->{titleid} = $item->id();
     }
 
+    # Check for a duplicate hold:
+    my $duplicate = $U->simplereq(
+        'open-ils.pcrud',
+        'open-ils.pcrud.search.ahr',
+        $self->{session}->{authtoken},
+        {
+            hold_type => $hold->hold_type(),
+            target => $hold->target(),
+            usr => $hold->usr(),
+            expire_time => {'>' => 'now'},
+            cancel_time => undef,
+            fulfillment_time => undef
+        }
+    );
+    if ($duplicate) {
+        return NCIP::Problem->new(
+            {
+                ProblemType => 'Duplicate Request',
+                ProblemDetail => 'A request for this item already exists for this patron.',
+                ProblemElement => 'NULL',
+                ProblemValue => 'NULL'
+            }
+        );
+    }
+
     # Check if the hold is possible:
     my $r = $U->simplereq(
         'open-ils.circ',