From 76af331b08da5fe1d2452218d91d8f338ef86b59 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 9 Jan 2017 09:13:11 +0100 Subject: [PATCH] Bug 17737: Rename holds_placed_before_today with current_holds Signed-off-by: Marcel de Rooy --- Koha/Item.pm | 4 ++-- catalogue/detail.pl | 2 +- circ/transferstoreceive.pl | 2 +- opac/opac-reserve.pl | 2 +- reserve/request.pl | 2 +- t/db_dependent/Holds.t | 4 ++-- t/db_dependent/Reserves.t | 16 ++++++++-------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 617f10c..a921018 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -185,11 +185,11 @@ sub article_request_type { return $issuing_rule->article_requests || q{} } -=head3 holds_placed_before_today +=head3 current_holds =cut -sub holds_placed_before_today { +sub current_holds { my ( $self ) = @_; my $attributes = { order_by => 'priority' }; my $dtf = Koha::Database->new->schema->storage->datetime_parser; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 25a28c5..63ba1ad 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -259,7 +259,7 @@ foreach my $item (@items) { # checking for holds my $item_object = Koha::Items->find( $item->{itemnumber} ); - my $holds = $item_object->holds_placed_before_today; + my $holds = $item_object->current_holds; if ( my $first_hold = $holds->next ) { my $ItemBorrowerReserveInfo = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber); # FIXME could be improved $item->{backgroundcolor} = 'reserved'; diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index 02664a5..bf1a756 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -102,7 +102,7 @@ while ( my $library = $libraries->next ) { # we check if we have a reserv for this transfer my $item = Koha::Items->find( $num->{itemnumber} ); - my $holds = $item->holds_placed_before_today; + my $holds = $item->current_holds; if ( my $first_hold = $holds->next ) { my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber ); $getransf{'borrowernum'} = $getborrower->{'borrowernumber'}; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 740f405..1939ec9 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -472,7 +472,7 @@ foreach my $biblioNum (@biblionumbers) { # checking reserve my $item = Koha::Items->find( $itemNum ); - my $holds = $item->holds_placed_before_today; + my $holds = $item->current_holds; # the item could be reserved for this borrower vi a host record, flag this my $reservedfor = q||; diff --git a/reserve/request.pl b/reserve/request.pl index 22147a9..89dace6 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -389,7 +389,7 @@ foreach my $biblionumber (@biblionumbers) { } # checking reserve - my $holds = Koha::Items->find( $itemnumber )->holds_placed_before_today; + my $holds = Koha::Items->find( $itemnumber )->current_holds; if ( my $first_hold = $holds->next ) { my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber ); diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index d49deea..1b4f1df 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -95,7 +95,7 @@ is( $holds->next->priority, 4, "Reserve 4 has a priority of 4" ); is( $holds->next->priority, 5, "Reserve 5 has a priority of 5" ); my $item = Koha::Items->find( $itemnumber ); -$holds = $item->holds_placed_before_today; +$holds = $item->current_holds; my $first_hold = $holds->next; my $reservedate = $first_hold->reservedate; my $borrowernumber = $first_hold->borrowernumber; @@ -132,7 +132,7 @@ CancelReserve({ 'reserve_id' => $reserve_id }); $holds = $biblio->holds; is( $holds->count, $borrowers_count - 1, "Test CancelReserve()" ); -$holds = $item->holds_placed_before_today; +$holds = $item->current_holds; $first_hold = $holds->next; $borrowernumber = $first_hold->borrowernumber; $branch_1code = $first_hold->branchcode; diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 08d88f8..ab20156 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -404,8 +404,8 @@ is( my $letter = ReserveSlip($branch_1, $requesters{$branch_1}, $bibnum); ok(defined($letter), 'can successfully generate hold slip (bug 10949)'); -# Tests for bug 9788: Does Koha::Item->holds_placed_before_today return a future wait? -# 9788a: holds_placed_before_today does not return future next available hold +# Tests for bug 9788: Does Koha::Item->current_holds return a future wait? +# 9788a: current_holds does not return future next available hold $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); @@ -416,21 +416,21 @@ AddReserve($branch_1, $requesters{$branch_1}, $bibnum, $bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, $found); my $item = Koha::Items->find( $itemnumber ); -$holds = $item->holds_placed_before_today; +$holds = $item->current_holds; my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); -is( $future_holds->count, 0, 'holds_placed_before_today does not return a future next available hold'); -# 9788b: holds_placed_before_today does not return future item level hold +is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); +# 9788b: current_holds does not return future item level hold $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); AddReserve($branch_1, $requesters{$branch_1}, $bibnum, $bibitems, 1, $resdate, $expdate, $notes, $title, $itemnumber, $found); #item level hold $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); -is( $future_holds->count, 0, 'holds_placed_before_today does not return a future item level hold' ); -# 9788c: holds_placed_before_today returns future wait (confirmed future hold) +is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); +# 9788c: current_holds returns future wait (confirmed future hold) ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); #confirm hold $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); -is( $future_holds->count, 1, 'holds_placed_before_today returns a future wait (confirmed future hold)' ); +is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' ); # End of tests for bug 9788 $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); -- 2.9.3