@@ -, +, @@ items items.onloan has been cleared. --- C4/Circulation.pm | 1 + t/db_dependent/Circulation.t | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -1812,6 +1812,7 @@ sub AddReturn { . Dumper($issue->unblessed) . "\n"; } else { $messages->{'NotIssued'} = $barcode; + ModItem({ onloan => undef }, $item->{biblionumber}, $item->{itemnumber}) if defined $item->{onloan}; # even though item is not on loan, it may still be transferred; therefore, get current branch info $doreturn = 0; # No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. --- a/t/db_dependent/Circulation.t +++ a/t/db_dependent/Circulation.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 113; +use Test::More tests => 114; use DateTime; @@ -2047,6 +2047,16 @@ subtest 'CanBookBeIssued | is_overdue' => sub { }; +subtest 'AddReturn should clear items.onloan for unissued items' => sub { + plan tests => 1; + + t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' ); + my $item = $builder->build_object({ class => 'Koha::Items', value => { onloan => '2018-01-01' }}); + AddReturn( $item->barcode, $item->homebranch ); + $item->discard_changes; # refresh + is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); +}; + sub set_userenv { my ( $library ) = @_; C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); --