diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0cedf80d9c..7ff18f078b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2001,6 +2001,9 @@ sub AddReturn { "UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" ); $sth->execute( $item->itemnumber ); + + # If we are completing a transfer we should not generate a new transfer from return policy + $returnbranch = $branch; } else { $messages->{'WrongTransfer'} = $tobranch; $messages->{'WrongTransferItem'} = $item->itemnumber; diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t index dfd65d33d2..e4a9f316a5 100644 --- a/t/db_dependent/Circulation/Branch.t +++ b/t/db_dependent/Circulation/Branch.t @@ -25,7 +25,7 @@ use Koha::CirculationRules; use Koha::Patrons; -use Test::More tests => 14; +use Test::More tests => 15; use t::lib::Mocks; use t::lib::TestBuilder; @@ -295,6 +295,12 @@ $dbh->do( $query, {}, $borrower_id1, $item_id2, $samplebranch2->{branchcode} ); $samplebranch2->{branchcode}); is( $messages->{NeedsTransfer}, $samplebranch1->{branchcode}, "AddReturn respects branch return policy - item2->homebranch policy = 'holdingbranch'" ); +# Generate the transfer from above +ModItemTransfer($item_id2, $samplebranch2->{branchcode}, $samplebranch1->{branchcode}, "ReturnToHolding"); +# Fulfill it +($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_2',$samplebranch1->{branchcode}); +is( $messages->{NeedsTransfer}, undef, "AddReturn does not generate a new transfer for return policy when resolving an existing transfer" ); + # item3 should not trigger transfer - floating collection $query = "INSERT INTO issues (borrowernumber,itemnumber,branchcode) VALUES( ?,?,? )";