Receive or abort transit in NCIP::ILS::Evergreen->checkoutitem.
authorJason Stephenson <jason@sigio.com>
Sat, 13 Dec 2014 21:57:31 +0000 (16:57 -0500)
committerJason Stephenson <jason@sigio.com>
Sat, 13 Dec 2014 21:57:31 +0000 (16:57 -0500)
If the copy is in transit to or from the working organizational
unit of the NCIP staff user, then we have to either receive or
abort the transit before the check out can proceed.

Signed-off-by: Jason Stephenson <jason@sigio.com>
lib/NCIP/ILS/Evergreen.pm

index 37ea5b0..70fe5fb 100644 (file)
@@ -795,6 +795,30 @@ sub checkoutitem {
         return $response;
     }
 
+    # Check for the copy being in transit and receive or abort it.
+    my $transit = $U->simplereq(
+        'open-ils.circ.open_copy_transit.retrieve',
+        $self->{session}->{authtoken},
+        $copy->id()
+    );
+    if (ref($transit) eq 'Fieldmapper::action::transit_copy') {
+        if ($transit->dest() == $self->{session}->{work_ou}->id()) {
+            my $r = $U->simplereq(
+                'open-ils.circ',
+                'open-ils.circ.copy_transit.receive',
+                $self->{session}->{authtoken},
+                {copyid => $copy->id()}
+            );
+        } elsif ($transit->source() == $self->{session}->{work_ou}->id()) {
+            my $r = $U->simplereq(
+                'open-ils.circ',
+                'open-ils.circ.transit.abort',
+                $self->{session}->{authtoken},
+                {copyid => $copy->id()}
+            );
+        }
+    }
+
     # Now, we attempt the check out. If it fails, we simply say that
     # the user is not allowed to check out this item, without getting
     # into details.