$script_libs = $lb;
$logger->debug(
- "Loaded rules scripts for circ: " .
+ "circulator: Loaded rules scripts for circ: " .
"circ permit patron = $p, ".
"circ permit copy = $c, ".
"circ duration = $d, ".
my @e = @{$circulator->events};
push( @ee, $_->{textcode} ) for @e;
$logger->info("circulator: bailing out with events: @ee");
- $circulator->editor->xact_rollback;
+ $circulator->editor->rollback;
} else {
$circulator->editor->commit;
$name =~ s/.*://o;
unless (grep { $_ eq $name } @AUTOLOAD_FIELDS) {
- $logger->error("$type: invalid autoload field: $name");
+ $logger->error("circulator: $type: invalid autoload field: $name");
die "$type: invalid autoload field: $name\n"
}
my @evts = @{$args->{_events}} if $args->{_events};
- $logger->debug("script builder returned events: : @evts") if @evts;
+ $logger->debug("circulator: script builder returned events: : @evts") if @evts;
if(@evts) {
my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
- $logger->info("circ searching for closed date overlap on lib $org".
+ $logger->info("circulator: circ searching for closed date overlap on lib $org".
" with an item due date of ".$circ->due_date );
my $dateinfo = $U->storagereq(
$org, $circ->due_date );
if($dateinfo) {
- $logger->info("$dateinfo : circ due data / close date overlap found : due_date=".
+ $logger->info("circulator: $dateinfo : circ due data / close date overlap found : due_date=".
$circ->due_date." start=". $dateinfo->{start}.", end=".$dateinfo->{end});
# XXX make the behavior more dynamic
my $copy = $self->copy;
if($copy) {
- $logger->debug("Pre-cat copy already exists in checkout: ID=" . $copy->id);
+ $logger->debug("ciculator: Pre-cat copy already exists in checkout: ID=" . $copy->id);
$copy->editor($self->editor->requestor->id);
$copy->edit_date('now');
my $count = $self->noncat_count || 1;
my $cotime = clense_ISO8601($self->checkout_time) || "";
- $logger->info("circ creating $count noncat circs with checkout time $cotime");
+ $logger->info("ciculator: circ creating $count noncat circs with checkout time $cotime");
for(1..$count) {
my $self = shift;
$self->log_me("do_checkin()");
+
return $self->bail_on_events(
OpenILS::Event->new('ASSET_COPY_NOT_FOUND'))
unless $self->copy;
+ # if we're on the holds shelf, do nothing
+# if( $U->copy_status($self->copy->status)->id == OILS_COPY_STATUS_ON_HOLDS_SHELF ) {
+# $logger->info("circulator: copy is already on the holds shelf at checkin, doing nothing: ".$self->copy->barcode);
+# $self->hold($U->fetch_open_hold_by_copy($self->copy->id));
+# $self->bail_on_events(OpenILS::Event->new('NO_CHANGE'));
+# $self->checkin_flesh_events;
+# return;
+# }
+
+
+ if( $self->checkin_check_holds_shelf() ) {
+ $self->bail_on_events(OpenILS::Event->new('NO_CHANGE'));
+ $self->hold($U->fetch_open_hold_by_copy($self->copy->id));
+ $self->checkin_flesh_events;
+ return;
+ }
+
unless( $self->is_renewal ) {
return $self->bail_on_events($self->editor->event)
unless $self->editor->allowed('COPY_CHECKIN');
} else {
+ my $bc = $self->copy->barcode;
+ $logger->info("circulator: copy $bc at a remote lib - sending home");
$self->checkin_build_copy_transit();
return if $self->bail_out;
$self->push_events(OpenILS::Event->new('ROUTE_ITEM', org => $circ_lib));
}
}
-
$self->reshelve_copy;
return if $self->bail_out;
}
+# Returns true if the item is at the current location
+# because it was transited there for a hold and the
+# hold has not been fulfilled
+sub checkin_check_holds_shelf {
+ my $self = shift;
+ return 0 unless $self->copy;
+
+ return 0 unless
+ $U->copy_status($self->copy->status)->id ==
+ OILS_COPY_STATUS_ON_HOLDS_SHELF;
+
+ # If we're on the holds shelf at our lib
+ return 1 if $self->copy->circ_lib == $self->editor->requestor->ws_ou;
+
+ # Otherwise, find the hold that put us on the holds shelf
+ my $holds = $self->editor->search_action_hold_request(
+ {
+ current_copy => $self->copy->id,
+ capture_time => { '!=' => undef },
+ fulfillment_time => undef,
+ cancel_time => undef,
+ }, { idlist => 1 }
+ );
+
+ return 0 unless @$holds;
+
+ $logger->info("circulator: we found a captured, un-fulfilled hold [".
+ $$holds[0]. "] for copy ".$self->copy->barcode);
+
+ # Then find the transit that got us here
+ my $transits = $self->editor->search_action_hold_transit_copy(
+ {
+ hold => $$holds[0],
+ dest => $self->editor->requestor->ws_ou,
+ dest_recv_time => { '!=' => undef }
+ }, { idlist =>1 }
+ );
+
+ return 0 unless @$transits;
+
+ $logger->info("circulator: we found a hold transit [".$$transits[0]."] for ".
+ $self->copy->barcode. " which puts the copy here.. not transiting home");
+
+ return 1;
+}
+
+
sub checkin_handle_precat {
my $self = shift;
my $copy = $self->copy;
if(!$notifier->event) {
- $logger->info("attempt at sending hold notification for hold $holdid");
+ $logger->info("ciculator: attempt at sending hold notification for hold $holdid");
my $stat = $notifier->send_email_notify;
- $logger->info("hold notify succeeded for hold $holdid") if $stat eq '1';
- $logger->warn(" * hold notify failed for hold $holdid") if $stat ne '1';
+ $logger->info("ciculator: hold notify succeeded for hold $holdid") if $stat eq '1';
+ $logger->warn("ciculator: * hold notify failed for hold $holdid") if $stat ne '1';
} else {
- $logger->info("Not sending hold notification since the patron has no email address");
+ $logger->info("ciculator: Not sending hold notification since the patron has no email address");
}
}
my $hold_transit = $self->editor->retrieve_action_hold_transit_copy($transit->id);
- $logger->info("Recovering original copy status in transit: ".$transit->copy_status);
+ $logger->info("ciculator: Recovering original copy status in transit: ".$transit->copy_status);
$copy->status( $transit->copy_status );
$self->update_copy();
return if $self->bail_out;
throw OpenSRF::EX::ERROR ("Circ Permit Renew Script Died: $@");
my $events = $result->{events};
- $logger->activity("circ_permit_renew for user ".
+ $logger->activity("ciculator: circ_permit_renew for user ".
$self->patron->id." returned events: @$events") if @$events;
$self->push_events(OpenILS::Event->new($_)) for @$events;