Browse Source

Bug 26896: Enable SIP option holds_block_checkin to actually block checkin of items with holds

It appears that at some point, the actual blocking of checkins on items
with holds got lost from the patch set. This slipped by because the sip
server still outputs everything correctly, but the unit tests don't
actually test to see if the checkout still exists afterward!

Test plan:
1) Apply this patch
2) Prove t/db_dependent/SIP/Message.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Matthias Meusburger <matthias.meusburger@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Kyle Hall 11 months ago
committed by Jonathan Druart
parent
commit
20431a0336
  1. 10
      C4/SIP/ILS/Transaction/Checkin.pm
  2. 5
      t/db_dependent/SIP/Message.t

10
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}) {

5
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;

Loading…
Cancel
Save