Lines 187-192
Koha::CirculationRules->set_rules(
Link Here
|
187 |
rules => { |
187 |
rules => { |
188 |
reservesallowed => 25, |
188 |
reservesallowed => 25, |
189 |
holds_per_record => 1, |
189 |
holds_per_record => 1, |
|
|
190 |
holds_per_day => 1, |
190 |
} |
191 |
} |
191 |
} |
192 |
} |
192 |
); |
193 |
); |
Lines 311-316
my $messages;
Link Here
|
311 |
# the one placed by the CPL patron, as the other two patron's hold |
312 |
# the one placed by the CPL patron, as the other two patron's hold |
312 |
# requests cannot be filled by that item per policy. |
313 |
# requests cannot be filled by that item per policy. |
313 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
314 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
|
|
315 |
|
314 |
is( $messages->{ResFound}->{borrowernumber}, |
316 |
is( $messages->{ResFound}->{borrowernumber}, |
315 |
$requesters{$branch_1}, |
317 |
$requesters{$branch_1}, |
316 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
318 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
Lines 722-727
MoveReserve( $item->itemnumber, $borrowernumber );
Link Here
|
722 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
724 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
723 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
725 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
724 |
|
726 |
|
|
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
#Test bug 23172. Check when returning an item that any patron category/item type combinations that forbid reservation are skipped over |
733 |
#when allocating the item to a bib-level hold |
734 |
$dbh->do('DELETE FROM issuingrules'); |
735 |
|
736 |
#Create two new patrons |
737 |
my $patronnumcat1 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_1})->store->borrowernumber; |
738 |
my $patronnumcat2 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_2})->store->borrowernumber; |
739 |
|
740 |
#Create a new biblio record |
741 |
my $bibnum3 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
742 |
|
743 |
#Create a second item type |
744 |
my $itemtype2 = $builder->build({ source => 'Itemtype', value => { notforloan => undef } } )->{itemtype}; |
745 |
|
746 |
# Create an item from new itemtype |
747 |
my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem( |
748 |
{ homebranch => $branch_1, |
749 |
holdingbranch => $branch_1, |
750 |
itype => $itemtype2, |
751 |
barcode => 'bug23172_CPL' |
752 |
}, |
753 |
$bibnum3 |
754 |
); |
755 |
|
756 |
#Make a general All patron category/all item type rule |
757 |
$dbh->do( |
758 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
759 |
VALUES (?, ?, ?, ?, ?, ?)}, |
760 |
{}, |
761 |
'*', '*', '*', 25, 1, 1 |
762 |
); |
763 |
|
764 |
#When patron category = $category_1 and itemtype = $itemtype1 then reservesallowed, holds_per_day and holds_per_record are 0 |
765 |
$dbh->do( |
766 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
767 |
VALUES (?, ?, ?, ?, ?, ?)}, |
768 |
{}, |
769 |
$category_1, $branch_1, $itemtype2, 0, 1, 1 |
770 |
); |
771 |
|
772 |
#When patron category = $category_2 and itemtype = $itemtype2 then reservesallowed, holds_per_day and holds_per_record are 1 |
773 |
$dbh->do( |
774 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
775 |
VALUES (?, ?, ?, ?, ?, ?)}, |
776 |
{}, |
777 |
$category_2, $branch_1, $itemtype2, 1, 1, 1 |
778 |
); |
779 |
|
780 |
#Remove existing reserves |
781 |
$dbh->do("DELETE FROM reserves"); |
782 |
|
783 |
#Create Bib-level hold for borrower who has a patron category of $category_2 |
784 |
my $reserveid2 = AddReserve($branch_1, $patronnumcat2, $bibnum3); |
785 |
|
786 |
#Bib-level hold for borrower who has a patron category of $category_1 |
787 |
my $reserveid1 = AddReserve($branch_1, $patronnumcat1, $bibnum3 ); |
788 |
|
789 |
#Check bib-level hold priority and confirm hold made by patronnumcat1 (who fits into issuingrule with reserveallowed = 0) has first priority |
790 |
my $reserve1 = Koha::Holds->find($reserveid1); |
791 |
is( $reserve1->priority, 1, 'patronnumcat1 reserve is first priority'); |
792 |
|
793 |
my $reserve2 = Koha::Holds->find($reserveid2); |
794 |
is( $reserve2->priority, 2, 'patronnumcat2 reserve is second priority'); |
795 |
|
796 |
#Return the item |
797 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
798 |
|
799 |
#First priority hold is skipped as issuingrule is checked and the first hold does not respect issuingrules (as one of the three fields: reservesallowed, holds_per_day is 0) therefore not allocating item to this bib-level hold |
800 |
is( $messages->{ResFound}->{borrowernumber}, $patronnumcat2,'Skip allocating item to first priority hold as it does not respect issuingrules instead allocate to next valid hold (bug 23172)'); |
801 |
|
802 |
#Remove and re-add the issuing rule that prevented patronnumcat1 bib-level hold from being allocated upon item return making reservesallowed, holds_per_day and holds_per_record > 0 |
803 |
$dbh->do(q{DELETE FROM issuingrules WHERE categorycode = ? AND branchcode = ? AND itemtype = ?}, |
804 |
{}, |
805 |
$category_1, $branch_1, $itemtype2 |
806 |
); |
807 |
$dbh->do( |
808 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
809 |
VALUES (?, ?, ?, ?, ?, ?)}, |
810 |
{}, |
811 |
$category_1, $branch_1, $itemtype2, 1, 1, 1 |
812 |
); |
813 |
|
814 |
#Return the item again and notice this time it is allocated to the bib-level hold made by patronnumcat1 |
815 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
816 |
is( $messages->{ResFound}->{borrowernumber}, $patronnumcat1,'Skip allocating item to first priority hold as it does not respect issuingrules instead allocate to next valid hold (bug 23172)'); |
817 |
|
725 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
818 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
726 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
819 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
727 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
820 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
728 |
- |
|
|