@@ -, +, @@ BlockReturnOfWithdrawn items is set to block --- C4/Circulation.pm | 12 +++++++----- t/db_dependent/Circulation.t | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2082,6 +2082,13 @@ sub AddReturn { } } + if ( $item->withdrawn ) { # book has been cancelled + $messages->{'withdrawn'} = 1; + $doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); + return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} )); + } + + # 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 @@ -2151,11 +2158,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; } --- a/t/db_dependent/Circulation.t +++ a/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 60; +use Test::More tests => 61; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -5280,6 +5280,20 @@ 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(); --