From e2d7c71dc89e01586e75949f8701d42d9db252cf Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 5 Sep 2016 13:50:54 +0200 Subject: [PATCH] Bug 17247: Check if patron is debarred in CanItemBeReserved Content-Type: text/plain; charset=utf-8 This way, calls to ILS-DI HoldTitle and HoldItem do this check too Signed-off-by: Brendan Gallagher Signed-off-by: Marcel de Rooy --- C4/Reserves.pm | 5 +++++ t/db_dependent/Holds.t | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 73b86b6..d7c4183 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -290,6 +290,7 @@ sub CanBookBeReserved{ cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. tooManyReserves, if the borrower has exceeded his maximum reserve amount. notReservable, if holds on this item are not allowed + debarred, if patron is debarred =cut @@ -308,6 +309,10 @@ sub CanItemBeReserved { my $patron = Koha::Patrons->find( $borrowernumber ); my $borrower = $patron->unblessed; + if ($patron->is_debarred) { + return 'debarred'; + } + # If an item is damaged and we don't allow holds on damaged items, we can stop right here return 'damaged' if ( $item->{damaged} diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 1e6c234..2a85496 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 55; +use Test::More tests => 56; use MARC::Record; use C4::Biblio; use C4::Items; @@ -411,6 +411,16 @@ my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum, '', 1, ); is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), 'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); +my $debarred_borrowernumber = AddMember( + firstname => 'Debarred', + surname => 'Patron', + categorycode => $category->{categorycode}, + branchcode => $branch_1, + debarred => '9999-12-31', +); +is(CanItemBeReserved($debarred_borrowernumber, $itemnumber), + 'debarred', 'Debarred patron cannot reserve'); + # Helper method to set up a Biblio. sub create_helper_biblio { -- 2.1.4