Bugzilla – Attachment 80480 Details for
Bug 15486
Restrict number of holds placed by day
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15486: Extend CanItemBeReserved so it handles daily holds limits
Bug-15486-Extend-CanItemBeReserved-so-it-handles-d.patch (text/plain), 3.23 KB, created by
Josef Moravec
on 2018-10-12 13:44:12 UTC
(
hide
)
Description:
Bug 15486: Extend CanItemBeReserved so it handles daily holds limits
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-10-12 13:44:12 UTC
Size:
3.23 KB
patch
obsolete
>From 55ebcb78eb7cdac726cfbd886176cb58b4b72dad Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 19 Jul 2017 18:14:19 -0300 >Subject: [PATCH] Bug 15486: Extend CanItemBeReserved so it handles daily holds > limits >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch implements the required changes in >C4::Reserves::CanItemBeReserved so it implements a daily limit on holds. > >It returns the 'tooManyReservesToday' string if the policy doesn't allow >placing the hold. It returns 'OK' (current behaviour) otherwise. > >To test: >- Run: > $ sudo koha-shell kohadev > k$ cd kohaclone > k$ prove t/db_dependent/Holds.t >=> FAIL: Tests fail because the error condition is not making >CanItemBeReserved return the desired error code. >- Apply this patch >- Run: > k$ prove t/db_dependent/Holds.t >=> SUCCESS: Tests pass! >- Sign off :-D > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Reserves.pm | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 91966bd..3c3e158 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -314,10 +314,11 @@ sub CanItemBeReserved { > my $ruleitemtype; # itemtype of the matching issuing rule > my $allowedreserves = 0; # Total number of holds allowed across all records > my $holds_per_record = 1; # Total number of holds allowed for this one given record >+ my $holds_per_day = 0; # Total number of holds allowed per day for the given patron > > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery >- my $item = GetItem($itemnumber); >+ my $item = C4::Items::GetItem($itemnumber); > my $biblio = Koha::Biblios->find( $item->{biblionumber} ); > my $patron = Koha::Patrons->find( $borrowernumber ); > my $borrower = $patron->unblessed; >@@ -364,6 +365,7 @@ sub CanItemBeReserved { > $ruleitemtype = $rights->{itemtype}; > $allowedreserves = $rights->{reservesallowed}; > $holds_per_record = $rights->{holds_per_record}; >+ $holds_per_day = $rights->{holds_per_day}; > } > else { > $ruleitemtype = '*'; >@@ -381,6 +383,18 @@ sub CanItemBeReserved { > return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; > } > >+ my $today_holds = Koha::Holds->search({ >+ borrowernumber => $borrowernumber, >+ reservedate => dt_from_string->date >+ }); >+ >+ if ( defined $holds_per_day && >+ ( ( $holds_per_day > 0 && $today_holds->count() >= $holds_per_day ) >+ or ( $holds_per_day == 0 ) ) >+ ) { >+ return { status => 'tooManyReservesToday', limit => $holds_per_day }; >+ } >+ > # we retrieve count > > $querycount .= "AND $branchfield = ?"; >@@ -2122,7 +2136,7 @@ sub GetHoldRule { > > my $sth = $dbh->prepare( > q{ >- SELECT categorycode, itemtype, branchcode, reservesallowed, holds_per_record >+ SELECT categorycode, itemtype, branchcode, reservesallowed, holds_per_record, holds_per_day > FROM issuingrules > WHERE (categorycode in (?,'*') ) > AND (itemtype IN (?,'*')) >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15486
:
65128
|
65129
|
65130
|
65131
|
65132
|
65133
|
67202
|
67203
|
67204
|
67205
|
67206
|
67207
|
67337
|
67840
|
67841
|
67842
|
67843
|
67844
|
67845
|
68728
|
68729
|
68730
|
68731
|
68732
|
68733
|
68734
|
68735
|
68750
|
68751
|
68752
|
68791
|
71314
|
71315
|
71316
|
71317
|
71318
|
71319
|
72709
|
79318
|
79319
|
79320
|
79321
|
79322
|
79323
|
79324
|
79696
|
79697
|
79698
|
79699
|
79700
|
79701
|
79702
|
80478
|
80479
| 80480 |
80481
|
80482
|
80483
|
80484
|
81087