Bug 22042: Block all return actions when BlockReturnOfWithdrawn items is set to block

Currently this syspref only bokcs the literal 'return' from a patron, i.e. the checkin

It still processes transfers, refunds lost items, updates NotForLoan status etc.

We should block all of these things

To test:
1 - Set BlockReturnOfWithdrawn to block
2 - Set an item as lost and withdrawn
3 - Check it in
4 - Item is found
5 - Apply patch
6 - Repeat 1-3
7 - Checkin is blocked, item still lost

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 321d8f7ce6)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
This commit is contained in:
Nick Clemens 2022-04-08 18:52:09 +00:00 committed by Arthur Suzuki
parent b23df4c8c0
commit c0fa919492
No known key found for this signature in database
GPG Key ID: 7558BEE2BEEEBCAA
2 changed files with 24 additions and 6 deletions

View File

@ -2008,6 +2008,16 @@ sub AddReturn {
}
}
if ( $item->withdrawn ) { # book has been cancelled
$messages->{'withdrawn'} = 1;
# In the case where we block return of withdrawn, we should completely block the return
# without updating item statuses, so we exit early
return ( 0, $messages, $issue, ( $patron ? $patron->unblessed : {} ))
if C4::Context->preference("BlockReturnOfWithdrawnItems");
}
# full item data, but no borrowernumber or checkout info (no issue)
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
# get the proper branch to which to return the item
@ -2077,11 +2087,6 @@ sub AddReturn {
return ( $doreturn, $messages, $issue, $patron_unblessed);
}
if ( $item->withdrawn ) { # book has been cancelled
$messages->{'withdrawn'} = 1;
$doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems");
}
if ( $item->itemlost and C4::Context->preference("BlockReturnOfLostItems") ) {
$doreturn = 0;
}

View File

@ -18,7 +18,7 @@
use Modern::Perl;
use utf8;
use Test::More tests => 57;
use Test::More tests => 58;
use Test::Exception;
use Test::MockModule;
use Test::Deep qw( cmp_deeply );
@ -5169,6 +5169,19 @@ subtest "GetSoonestRenewDate tests" => sub {
);
};
subtest 'Tests for BlockReturnOfWithdrawnItems' => sub {
plan tests => 1;
t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1);
my $item = $builder->build_sample_item();
$item->withdrawn(1)->itemlost(1)->store;
my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
is_deeply(
\@return,
[ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], "Item returned as withdrawn, no other messages");
};
$schema->storage->txn_rollback;
C4::Context->clear_syspref_cache();
$branches = Koha::Libraries->search();