Kyle M Hall
78eba2f974
CheckReserves was using the CircControl system preference to determine what patrons an item can fill a hold for. It should be using ReservesControlBranch instead. Test Plan: 1) Set ReservesControlBranch to "item's home library". 2) Create an item at Library A, place holds for it for patrons at Library B, Library C, and Library A in that order, for pickup at the patrons home library. 3) Make sure the holds policy for Library A is set to Hold Policy = "From home library" and Return Policy = "Item returns home". Make sure the holds policies for the other libraries are set to Hold Policy = "From any library". 4) Check the item in at Library C, the hold for the patron at Library B should pop up, even though it's in violation of the circulation rules. Don't click the confirm button! 5) Apply this patch, and reload the page, now the hold listed should be for the last hold, the hold for the patron at Library A, which is correct. This patch adds the subroutine C4::Reserves::GetReservesControlBranch as an equivilent to C4::Circulation::_GetCircControlBranch. Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Fixed POD so that arguments and explanation match (C<$item>). Also tested opac-reserves.pl for regressions. Passes all tests, QA script, and Reserves.t. Signed-off-by: Galen Charlton <gmc@esilibrary.com>
95 lines
2.8 KiB
Perl
Executable file
95 lines
2.8 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
|
|
use Test::More tests => 6;
|
|
use MARC::Record;
|
|
|
|
use C4::Branch;
|
|
use C4::Biblio;
|
|
use C4::Items;
|
|
use C4::Members;
|
|
|
|
BEGIN {
|
|
use_ok('C4::Reserves');
|
|
}
|
|
|
|
my $dbh = C4::Context->dbh;
|
|
|
|
# Start transaction
|
|
$dbh->{AutoCommit} = 0;
|
|
$dbh->{RaiseError} = 1;
|
|
|
|
# Setup Test------------------------
|
|
# Helper biblio.
|
|
diag("\nCreating biblio instance for testing.");
|
|
my $bib = MARC::Record->new();
|
|
my $title = 'Silence in the library';
|
|
$bib->append_fields(
|
|
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
|
|
MARC::Field->new('245', ' ', ' ', a => $title),
|
|
);
|
|
my ($bibnum, $bibitemnum);
|
|
($bibnum, $title, $bibitemnum) = AddBiblio($bib, '');
|
|
# Helper item for that biblio.
|
|
diag("Creating item instance for testing.");
|
|
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum);
|
|
|
|
# Modify item; setting barcode.
|
|
my $testbarcode = '97531';
|
|
ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber);
|
|
|
|
# Create a borrower
|
|
my %data = (
|
|
firstname => 'my firstname',
|
|
surname => 'my surname',
|
|
categorycode => 'S',
|
|
branchcode => 'CPL',
|
|
);
|
|
my $borrowernumber = AddMember(%data);
|
|
my $borrower = GetMember( borrowernumber => $borrowernumber );
|
|
my $biblionumber = $bibnum;
|
|
my $barcode = $testbarcode;
|
|
|
|
my $constraint = 'a';
|
|
my $bibitems = '';
|
|
my $priority = '1';
|
|
my $resdate = undef;
|
|
my $expdate = undef;
|
|
my $notes = '';
|
|
my $checkitem = undef;
|
|
my $found = undef;
|
|
|
|
my @branches = GetBranchesLoop();
|
|
my $branch = $branches[0][0]{value};
|
|
|
|
AddReserve($branch, $borrowernumber, $biblionumber,
|
|
$constraint, $bibitems, $priority, $resdate, $expdate, $notes,
|
|
$title, $checkitem, $found);
|
|
|
|
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
|
|
|
|
is($status, "Reserved", "CheckReserves Test 1");
|
|
|
|
($status, $reserve, $all_reserves) = CheckReserves($itemnumber);
|
|
is($status, "Reserved", "CheckReserves Test 2");
|
|
|
|
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
|
|
is($status, "Reserved", "CheckReserves Test 3");
|
|
|
|
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
|
|
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
|
|
ok(
|
|
'ItemHomeLib' eq GetReservesControlBranch(
|
|
{ homebranch => 'ItemHomeLib' },
|
|
{ branchcode => 'PatronHomeLib' }
|
|
), "GetReservesControlBranch returns item home branch when set to ItemHomeLibrary"
|
|
);
|
|
C4::Context->set_preference( 'ReservesControlBranch', 'PatronLibrary' );
|
|
ok(
|
|
'PatronHomeLib' eq GetReservesControlBranch(
|
|
{ homebranch => 'ItemHomeLib' },
|
|
{ branchcode => 'PatronHomeLib' }
|
|
), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
|
|
);
|
|
C4::Context->set_preference( 'ReservesControlBranch', $ReservesControlBranch );
|