__PACKAGE__->register_method(
method => "generic_receive",
- api_name => "open-ils.circ.checkin__",
+ api_name => "open-ils.circ.checkin",
);
sub generic_receive {
my $copy = $ctx->{copy};
$U->unflesh_copy($copy);
- $logger->debug("Checkin copy called by user ".$requestor->id." for copy ".$copy->id);
+ $logger->info("Checkin copy called by user ".$requestor->id." for copy ".$copy->id);
return OpenILS::Event->new('COPY_NOT_FOUND') unless $copy;
# ------------------------------------------------------------------------------
+ return $self->checkin_do_receive($connection, $ctx);
+}
+
+sub checkin_do_receive {
+
+ my( $self, $connection, $ctx ) = @_;
+
+ my $evt;
+ my $copy = $ctx->{copy};
+ my $session = $ctx->{session};
+ my $requestor = $ctx->{requestor};
+
if(!$ctx->{force}) {
return $evt if ($evt = _checkin_check_copy_status($copy));
}
- my ($circ) = $U->fetch_open_circulation($copy->id);
- my ($transit) = $U->fetch_open_transit_by_copy($copy->id);
+ my $longoverdue = 0; # is this copy attached to a longoverdue circ?
+ my $claimsret = 0; # is this copy attached to a claims returned circ?
+ my ($circ) = $U->fetch_open_circulation($copy->id);
+ my ($transit) = $U->fetch_open_transit_by_copy($copy->id);
if( $circ ) {
-
- # There is an open circ on this item so close out the circ
- $ctx->{circ} = $circ;
- $evt = _checkin_handle_circ($ctx);
+
+ # There is an open circ on this item. Grab any interesting
+ # info from the circ then close it out
+ $longoverdue = 1 if ($circ->stop_fines =~ /longoverdue/);
+ $claimsret = 1 if ($circ->stop_fines =~ /claimsreturned/);
+ $ctx->{circ} = $circ;
+ $evt = _checkin_handle_circ($ctx);
return $evt if $evt;
} elsif( $transit ) {
if( $copy->circ_lib == $requestor->home_ou ) {
- # Copy is in the right place. Re-shelve the thing.
- $copy->status($U->copy_status_from_name('reshelving')->id );
- return $evt if ( $evt = $U->update_copy(
- copy => $copy, editor => $requestor->id, session => $session ));
+ # Copy is in the right place.
$evt = OpenILS::Event->new('SUCCESS');
$evt = OpenILS::Event->new('ITEM_NOT_CATALOGED') if $ctx->{precat};
my $evt = OpenILS::Event->new('COPY_BAD_STATUS', payload => $copy );
return $evt if ($stat == $U->copy_status_from_name('lost')->id);
return $evt if ($stat == $U->copy_status_from_name('missing')->id);
-
- # XXX Really do this?
- my ($circ) = $U->fetch_open_circulation($copy->id);
- if($circ) {
- $evt = OpenILS::Event->new('CIRC_BAD_STATUS', payload => $copy );
- return $evt if ($circ->stop_fines =~ /longoverdue/);
- return $evt if ($circ->stop_fines =~ /claimsreturned/);
- }
-
return undef;
}
# ------------------------------------------------------------------------------
+=head comment
__PACKAGE__->register_method(
method => "checkin",
- api_name => "open-ils.circ.checkin",
+ api_name => "open-ils.circ.checkin___",
notes => <<" NOTES");
PARAMS( authtoken, barcode => bc )
Checks in based on barcode
}
}
+=cut
+
sub _checkin_handle_circ { return _update_checkin_circ_and_copy(@_); }
}
}
- $logger->debug("Checkin committing copy and circ objects");
- $evt = $U->update_copy( session => $session,
- copy => $copy, editor => $requestor->id );
+ $logger->info("Checkin copy setting status to 'reshelving' and committing...");
+ $copy->status($U->copy_status_from_name('reshelving')->id);
+ $evt = $U->update_copy( session => $session, copy => $copy, editor => $requestor->id );
return $evt if $evt;
$ctx->{session}->request(
'open-ils.storage.direct.action.transit_copy.update', $transit )->gather(1);
return $U->DB_UPDATE_FAILED($transit) unless $r;
- # if this is a hold transit, finalize the hold transit
my $ishold = 0;
- if( ($evt = _finish_hold_transit(
- $session, $requestor, $copy, $transit->id )) ) {
- $ishold = 1;
- return $evt unless $U->event_equals($evt, 'SUCCESS');
- $evt = undef;
- }
-
- $U->logmark;
+ my ($ht) = $U->fetch_hold_transit( $transit->id );
- #recover this copy's status from the transit
- $copy->status( $transit->copy_status );
- return OpenILS::Event->new('SUCCESS', ishold => $ishold, payload => $copy);
-
-}
+ if($ht) {
+ $logger->info("Hold transit found: ".$hold_transit->id.". Setting copy status to 'on holds shelf'");
+ $copy->status($U->copy_status_from_name('on holds shelf')->id);
+ $ishold = 1;
+ } else {
-# ------------------------------------------------------------------------------
-# If we have a hold transit, set the copy's status to 'on holds shelf',
-# update the copy, and return SUCCESS
-# ------------------------------------------------------------------------------
-sub _finish_hold_transit {
- my( $session, $requestor, $copy, $transid ) = @_;
- $U->logmark;
- my ($hold_transit, $evt) = $U->fetch_hold_transit( $transid );
- return undef unless $hold_transit;
+ $logger->info("Hold transit not found, recovering original copy status");
+ $copy->status( $transit->copy_status );
+ }
- my $s = $U->copy_status_from_name('on holds shelf');
- $logger->info("Hold transit found: ".$hold_transit->id.". Routing to holds shelf");
+
+ return $evt if ( $evt =
+ $U->update_copy( copy => $copy, editor => $requestor->id, session => $session ));
- $copy->status($s->id);
- $U->update_copy( copy => $copy,
- editor => $requestor->id, session => $session );
+ return OpenILS::Event->new('SUCCESS', ishold => $ishold, payload => $copy);
+}
- my $r = $session->request(
- 'open-ils.storage.direct.asset.copy.update', $copy )->gather(1);
- return $U->DB_UPDATE_FAILED($copy) unless $r;
- return OpenILS::Event->new('SUCCESS');
-}
__PACKAGE__->register_method(