From 738ebf525c040dd63377ef58c90e76b37a7c7a7f Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 9 Oct 2015 13:57:17 -0400 Subject: [PATCH] Make some changes to NCIP::ILS::Evergreen->check_circ_details. Testing revealed some problems with the initial logic. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 65712bc..1a5f3c3 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -413,7 +413,7 @@ sub checkinitem { # the patron was provided, that it is checked out to the patron in # question. We also verify the copy ownership and circulation # location. - my $problem = $self->check_circ_details($circ, $copy, $user); + my $problem = $self->check_circ_details($details, $user); if ($problem) { # We need to fill in some information, however. if (!$problem->ProblemValue() && !$problem->ProblemElement()) { @@ -1745,13 +1745,14 @@ sub check_user_for_problems { =head2 check_circ_details - $problem = $ils->check_circ_details($circ, $copy, $user); + $problem = $ils->check_circ_details($details, $user); Checks if we can checkin or renew a circulation. That is, the circulation is still open (i.e. the copy is still checked out), if we either own the copy or are the circulation location, and if the -circulation is for the optional $user argument. $circ and $copy are -required. $user is optional. +circulation is for the optional $user argument. The $details argument +is required and comes from the retrieve_copy_details call. $user is +optional. Returns a problem if any of the above conditions fail. Returns undef if they pass and we can proceed with the checkin or renewal. @@ -1765,12 +1766,21 @@ fields will be empty and need to be filled in by the caller. =cut sub check_circ_details { - my ($self, $circ, $copy, $user) = @_; + my ($self, $details, $user) = @_; + + my $copy = $details->{copy}; + my $circ = $details->{circ}; + my $transit = $details->{transit}; # Shortcut for the next check. my $ou_id = $self->{session}->{work_ou}->id(); - if (!$circ || $circ->checkin_time() || ($circ->circ_lib() != $ou_id && $copy->circ_lib() != $ou_id)) { + # We need to have a circulation. The copy needs to either have + # been checked out at the NCIP user's working_ou or it needs to be + # owned there. If the circulation was subsequently checked in, + # then we need an open transit to the NCIP user's working_ou. + if (!$circ || ($circ->circ_lib() != $ou_id && $copy->circ_lib() != $ou_id) + || ($circ->checkin_time() && (!$transit || $transit->dest() != $ou_id))) { # Item isn't checked out. return NCIP::Problem->new( { -- 2.43.2