- my $holds = Koha::Holds->search(
- {
- borrowernumber => $borrowernumber,
- biblionumber => $item->biblionumber,
+ my $rights = Koha::CirculationRules->get_effective_rules({
+ categorycode => $borrower->{'categorycode'},
+ itemtype => $item->effective_itemtype,
+ branchcode => $branchcode,
+ rules => ['holds_per_record','holds_per_day']
+ });
+ my $holds_per_record = $rights->{holds_per_record} // 1;
+ my $holds_per_day = $rights->{holds_per_day};
+
+ my $search_params = {
+ borrowernumber => $borrowernumber,
+ biblionumber => $item->biblionumber,
+ };
+ $search_params->{found} = undef if $params->{ignore_found_holds};
+
+ my $holds = Koha::Holds->search($search_params);
+ if ( defined $holds_per_record && $holds_per_record ne '' ){
+ if ( $holds_per_record == 0 ) {
+ return { status => "noReservesAllowed" };
+ }
+ if ( !$params->{ignore_hold_counts} && $holds->count() >= $holds_per_record ) {
+ return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };