From: Bill Erickson Date: Fri, 25 Oct 2013 18:53:33 +0000 (-0400) Subject: ff : pulling connector mods from ff master X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=206662324f4ee8f5fff801771fe5a13e25e7a200;p=evergreen%2Fequinox.git ff : pulling connector mods from ff master Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/FulfILLment/Application/LAICore.pm b/Open-ILS/src/perlmods/lib/FulfILLment/Application/LAICore.pm index fc3edfee10..a7ff1a0a0a 100644 --- a/Open-ILS/src/perlmods/lib/FulfILLment/Application/LAICore.pm +++ b/Open-ILS/src/perlmods/lib/FulfILLment/Application/LAICore.pm @@ -251,7 +251,7 @@ sub borrower_holds { $copy_barcode, $user_barcode, $pickup_lib) if $self->api_name =~ /place/; - return $connector->deletel_borrower_hold($copy_barcode, $user_barcode); + return $connector->delete_borrower_hold($copy_barcode, $user_barcode); } diff --git a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector.pm b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector.pm index 095be8b54b..b83583d3ac 100644 --- a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector.pm +++ b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector.pm @@ -326,18 +326,32 @@ sub delete_lender_hold { my ($self, $item_barcode, $user_barcode) = @_; } +sub get_lender_pickup_lib { + my ($self, $user_barcode) = @_; + + # first try the org unit setting + return $self->{extra}->{pickup_location} + if $self->{extra}->{pickup_location}; + + # next try the home org unit of the proxy user + # NOTE: proxy user may not exist in local DB + my $user = $self->flesh_user($user_barcode); + return $user ? $user->home_ou->shortname : undef; +} # --------------------------------------------------------------------------- # Provide a default hold placement via SIP +# TODO: turn params into a hash # --------------------------------------------------------------------------- sub place_hold_via_sip { my $self = shift; - my $bib_id = shift || ''; + my $bib_id = shift || ''; # bre.id, not bre.remote_id my $copy_barcode = shift || ''; my $user_barcode = shift || ''; my $pickup_lib = shift || ''; my $expire_date = shift; my $hold_type = shift; + my $remote_id = shift; if (!$hold_type) { # if no hold type is provided, assume passing @@ -353,12 +367,7 @@ sub place_hold_via_sip { DateTime->now->add({months => 6})->strftime("%Y%m%d 000000"); } - if (!$pickup_lib) { - # use the home org unit of the requesting user - # as the pickup lib if none is provided - my $user = $self->flesh_user($user_barcode); - $pickup_lib = $user->home_ou->shortname if $user; - } + $pickup_lib = $self->get_lender_pickup_lib unless $pickup_lib; $logger->warn("FF has no pickup lib for $user_barcode") if !$pickup_lib; @@ -366,8 +375,16 @@ sub place_hold_via_sip { "pickup_lib=$pickup_lib; bib=$bib_id; ". "user=$user_barcode; expire=$expire_date"); + # bib holds are placed against the remote id of the bib + if ($bib_id and not $remote_id) { + $remote_id = new_editor()->json_query({ + select => {bre => ['remote_id']}, + from => 'bre', + where => {id => $bib_id} + })->[0]->{remote_id}; + } my $resp = $self->sip_client->place_hold($user_barcode, undef, - $expire_date, $pickup_lib, $hold_type, $copy_barcode, $bib_id); + $expire_date, $pickup_lib, $hold_type, $copy_barcode, $remote_id); return undef unless $resp; diff --git a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III.pm b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III.pm index a26b0e0684..029dcf1bf8 100644 --- a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III.pm +++ b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III.pm @@ -127,7 +127,6 @@ sub get_items_by_record { return @items ? \@items : []; } -# TODO: test with 2011 sub get_record_by_id { my ($self, $rec_id) = @_; @@ -141,4 +140,32 @@ sub get_record_by_id { } } +sub place_lender_hold { + my ($self, $item_barcode, $user_barcode, $pickup_lib) = @_; + + my $hold = $self->place_hold_via_sip( + undef, $item_barcode, $user_barcode, $pickup_lib, 2) + or return; + + $hold->{hold_type} = 'T'; + return $hold; +} + +sub delete_lender_hold { + my ($self, $item_barcode, $user_barcode) = @_; + + my $user = $self->flesh_user($user_barcode); + my $pickup_lib = $user->home_ou->shortname if $user; + + my $resp = $self->sip_client->delete_hold( + $user_barcode, undef, undef, + $pickup_lib, 2, $item_barcode) + or return; + + return unless $resp; + return $self->translate_sip_hold($resp); +} + + + 1; diff --git a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III/2011_1_3.pm b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III/2011_1_3.pm index e0cbdfdf88..591292bb67 100644 --- a/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III/2011_1_3.pm +++ b/Open-ILS/src/perlmods/lib/FulfILLment/LAIConnector/III/2011_1_3.pm @@ -2,6 +2,9 @@ package FulfILLment::LAIConnector::III::2011_1_3; use base FulfILLment::LAIConnector::III; use strict; use warnings; use OpenSRF::Utils::Logger qw/$logger/; +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Application::AppUtils; +my $U = 'OpenILS::Application::AppUtils'; use MARC::Record; use MARC::Batch; @@ -15,6 +18,42 @@ use Data::Dumper; my $ua = LWP::UserAgent->new; $ua->agent("FulfILLment/1.0"); +# title-level hold on bib ID only supported +sub place_lender_hold { + my ($self, $item_barcode, $user_barcode, $pickup_lib) = @_; + + my $acp = new_editor()->search_asset_copy([ + { barcode => $item_barcode, + deleted => 'f', + source_lib => $U->get_org_ancestors($self->org_id) + }, { + flesh => 2, + flesh_fields => { + acp => ['call_number'], + acn => ['record'] + } + } + ])->[0]; + + my $remote_id = $acp->call_number->record->remote_id; + + # TODO: verify this is needed + $remote_id =~ s/^\.//; # kill the preceding '.' + #$remote_id =~ s/^b//; # kill the preceding 'b' + + # checkdigit + #$remote_id =~ s/(.)$//; + + + my $hold = $self->place_hold_via_sip( + $acp->call_number->record->id, undef, + $user_barcode, $pickup_lib, undef, 2, $remote_id) + or return; + + $hold->{hold_type} = 'T'; + return $hold; +} + sub get_record_by_id_ssh { my ($self, $record_id) = @_; diff --git a/Open-ILS/src/perlmods/lib/FulfILLment/Util/SIP2Client.pm b/Open-ILS/src/perlmods/lib/FulfILLment/Util/SIP2Client.pm index d7f68a1cc4..43c973a1d9 100644 --- a/Open-ILS/src/perlmods/lib/FulfILLment/Util/SIP2Client.pm +++ b/Open-ILS/src/perlmods/lib/FulfILLment/Util/SIP2Client.pm @@ -247,8 +247,8 @@ sub checkout{ my $patron_id = $_[1]; my $patron_passwd =$_[2]; my $item_id = $_[3]; - my $fee_ack = $_[4] || "N"; #value should be Y or N - my $cancel = $_[5] || "N"; #value should be Y or N + my $fee_ack = $_[4]; # Y or N + my $cancel = $_[5]; # Y or N my $due_date_epoch = $_[6]; my $msg = '11NN'; #sets message id to 11, no blocking, no autorenew $msg .= Sip::timestamp(); @@ -256,7 +256,7 @@ sub checkout{ $msg .= maybe_add(FID_INST_ID,$location); $msg .= add_field(FID_PATRON_ID,$patron_id); $msg .= add_field(FID_ITEM_ID,$item_id); - $msg .= add_field(FID_TERMINAL_PWD,$terminalPwd); + $msg .= maybe_add(FID_TERMINAL_PWD,$terminalPwd); $msg .= maybe_add(FID_PATRON_PWD,$patron_passwd); $msg .= maybe_add(FID_FEE_ACK,$fee_ack); $msg .= maybe_add(FID_CANCEL,$cancel);