From 4fa77ef5d7a2fe824598553356aef494c31c762f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 7 Oct 2020 08:21:16 +0100 Subject: [PATCH] Bug 24446: Add datesent/datecancelled handling to GetTransfersFromTo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the first uses of Koha::Item->request_transfer and Koha::Item::Transfer->cancel having been added, we need to update GetTransferFromTo to respect transfers that have been requested but not yet sent and not cancelled. Test plan 1/ Run the included unit test 2/ Confirm the "Transfers to recieve" page loads 3/ Signoff Signed-off-by: Kathleen Milne Signed-off-by: Joonas Kylmälä --- C4/Circulation.pm | 2 ++ t/db_dependent/Circulation/transfers.t | 38 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 7b119e169d..2229f3edb0 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3462,6 +3462,8 @@ sub GetTransfersFromTo { FROM branchtransfers WHERE frombranch=? AND tobranch=? + AND datecancelled IS NULL + AND datesent IS NOT NULL AND datearrived IS NULL "; my $sth = $dbh->prepare($query); diff --git a/t/db_dependent/Circulation/transfers.t b/t/db_dependent/Circulation/transfers.t index 8ca9e31682..215afad81a 100755 --- a/t/db_dependent/Circulation/transfers.t +++ b/t/db_dependent/Circulation/transfers.t @@ -89,6 +89,26 @@ my $item_id2 = Koha::Item->new( itype => $itemtype }, )->store->itemnumber; +my $item_id3 = Koha::Item->new( + { + biblionumber => $biblionumber, + barcode => 3, + itemcallnumber => 'callnumber3', + homebranch => $branchcode_1, + holdingbranch => $branchcode_1, + itype => $itemtype + }, +)->store->itemnumber; +my $item_id4 = Koha::Item->new( + { + biblionumber => $biblionumber, + barcode => 4, + itemcallnumber => 'callnumber4', + homebranch => $branchcode_1, + holdingbranch => $branchcode_1, + itype => $itemtype + }, +)->store->itemnumber; #Add transfers ModItemTransfer( @@ -106,6 +126,24 @@ ModItemTransfer( $branchcode_2 ); +# Add an "unsent" transfer for tests +ModItemTransfer( + $item_id3, + $branchcode_1, + $branchcode_2 +); +my $transfer_requested = Koha::Item::Transfers->search( { itemnumber => $item_id3 }, { rows => 1 })->single; +$transfer_requested->set({ daterequested => dt_from_string, datesent => undef })->store; + +# Add a "cancelled" transfer for tests +ModItemTransfer( + $item_id4, + $branchcode_1, + $branchcode_2 +); +my $transfer_cancelled = Koha::Item::Transfers->search( { itemnumber => $item_id4 }, { rows => 1 })->single; +$transfer_cancelled->set( { daterequested => dt_from_string, datesent => undef, datecancelled => dt_from_string } )->store; + #Begin Tests #Test CreateBranchTransferLimit is( -- 2.20.1