diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index 6a38a958ac..274fda9325 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -76,7 +76,9 @@ sub do_checkin { } my ( $return, $messages, $issue, $borrower ); + my $item = Koha::Items->find( { barcode => $barcode } ); + my $human_required = 0; if ( C4::Context->preference("CircConfirmItemParts") && defined($item) @@ -86,10 +88,12 @@ sub do_checkin { $messages->{additional_materials} = 1; } + my $checkin_blocked_by_holds = $holds_block_checkin && $item->biblio->holds->count; + $debug and warn "do_checkin() calling AddReturn($barcode, $branch)"; ( $return, $messages, $issue, $borrower ) = AddReturn( $barcode, $branch, undef, $return_date ) - unless $human_required; + unless $human_required || $checkin_blocked_by_holds; if ( $checked_in_ok ) { delete $messages->{ItemLocationUpdated}; @@ -132,8 +136,8 @@ sub do_checkin { $self->{item}->destination_loc($issue->item->homebranch); $self->alert_type('04'); # send to other branch } - if ($messages->{ResFound}) { - if ($holds_block_checkin) { + if ($messages->{ResFound} || $checkin_blocked_by_holds ) { + if ($checkin_blocked_by_holds) { $self->alert_type('99'); $return = 0; } elsif ($branch eq $messages->{ResFound}->{branchcode}) { diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 31baf30e3a..f3850f5b85 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -69,7 +69,7 @@ subtest 'Testing Patron Info Request V2' => sub { subtest 'Checkin V2' => sub { my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; - plan tests => 33; + plan tests => 35; $C4::SIP::Sip::protocol_version = 2; test_checkin_v2(); $schema->storage->txn_rollback; @@ -657,6 +657,8 @@ sub test_checkin_v2 { 'Issue record is gone now' ); # Test account option no_holds_check that prevents items on hold from being checked in via SIP + $issue = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object->itemnumber })->store; + is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 1, "Item is checked out"); Koha::Old::Checkouts->search({ issue_id => $issue->issue_id })->delete; $server->{account}->{holds_block_checkin} = 1; my $reserve_id = AddReserve({ @@ -673,6 +675,7 @@ sub test_checkin_v2 { is( substr($response,2,1), '0', 'OK flag is false when we check in an item on hold and we do not allow it' ); is( substr($response,5,1), 'Y', 'Alert flag is set' ); check_field( $respcode, $response, FID_SCREEN_MSG, 'Item is on hold, please return to circulation desk', 'Screen message is correct' ); + is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 1, "Item was not checked in"); $hold->delete(); $server->{account}->{holds_block_checkin} = 0;