From 7d6da5929cb6dfb88abfcc6898aa2ad2308bab44 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 18 Aug 2011 16:48:44 +0100 Subject: [PATCH] Bug 3638 : Captured Holds may need to generate a transfer If a discharged item is captured for a hold at another branch the selfcheck should generate a branchtransfer for it. This was complicated as the checkin routine was setting its own location from a field not set in many scm machines (e.g. 3M) also in ILS::Transaction the test for location was incorrect assuming that an empty string or undefined was a valid location Signed-off-by: Chris Cormack --- C4/SIP/ILS.pm | 2 +- C4/SIP/ILS/Transaction/Checkin.pm | 10 +++++++++- C4/SIP/Sip/MsgType.pm | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 432e4f1..f046568 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -181,7 +181,7 @@ sub checkin { $circ->item($item = new ILS::Item $item_id); if ($item) { - $circ->do_checkin($current_loc, $return_date); + $circ->do_checkin($current_loc); } else { $circ->alert(1); $circ->alert_type(99); diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index a705f57..3e3c74c 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -14,6 +14,7 @@ use ILS::Transaction; use C4::Circulation; use C4::Reserves qw( ModReserveAffect ); +use C4::Items qw( ModItemTransfer ); use C4::Debug; our @ISA = qw(ILS::Transaction); @@ -45,7 +46,10 @@ sub new { sub do_checkin { my $self = shift; - my $branch = @_ ? shift : 'SIP2' ; + my $branch = shift; + if (!$branch) { + $branch = 'SIP2'; + } my $barcode = $self->{item}->id; $debug and warn "do_checkin() calling AddReturn($barcode, $branch)"; my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch); @@ -85,6 +89,10 @@ sub do_checkin { $self->alert_type('02'); ModReserveAffect( $messages->{ResFound}->{itemnumber}, $messages->{ResFound}->{borrowernumber}, 1); + ModItemTransfer( $messages->{ResFound}->{itemnumber}, + $branch, + $messages->{ResFound}->{branchcode} + ); } $self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} ); diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index c18186d..c3914c0 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -610,6 +610,7 @@ sub handle_checkin { my ($self, $server) = @_; my $account = $server->{account}; my $ils = $server->{ils}; + my $my_branch = $ils->institution; my ($current_loc, $inst_id, $item_id, $terminal_pwd, $item_props, $cancel); my ($patron, $item, $status); my $resp = CHECKIN_RESP; @@ -621,6 +622,9 @@ sub handle_checkin { $item_id = $fields->{(FID_ITEM_ID)}; $item_props = $fields->{(FID_ITEM_PROPS)}; $cancel = $fields->{(FID_CANCEL)}; + if ($current_loc) { + $my_branch = $current_loc;# most scm do not set $current_loc + } $ils->check_inst_id($inst_id, "handle_checkin"); @@ -629,7 +633,7 @@ sub handle_checkin { syslog("LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id}); $status = $ils->checkin_no_block($item_id, $trans_date, $return_date, $item_props, $cancel); } else { - $status = $ils->checkin($item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel); + $status = $ils->checkin($item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel); } $patron = $status->patron; @@ -647,7 +651,7 @@ sub handle_checkin { # apparently we can't trust the returns from Checkin yet (because C4::Circulation::AddReturn is faulty) # So we reproduce the alert logic here. if (not $status->alert) { - if ($item->destination_loc and $item->destination_loc ne $current_loc) { + if ($item->destination_loc and $item->destination_loc ne $my_branch) { $status->alert(1); $status->alert_type('04'); # no hold, just send it } -- 1.7.10