Bugzilla – Attachment 120639 Details for
Bug 15565
Place multiple item-level holds at once for the same record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15565: Koha::Biblio->allowed_holds and tests
Bug-15565-KohaBiblio-allowedholds-and-tests.patch (text/plain), 4.52 KB, created by
Victor Grousset/tuxayo
on 2021-05-06 19:14:52 UTC
(
hide
)
Description:
Bug 15565: Koha::Biblio->allowed_holds and tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2021-05-06 19:14:52 UTC
Size:
4.52 KB
patch
obsolete
>From 9ff7df20551c7d25791efc81f11e8fb9ff362442 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 22 Feb 2021 17:54:58 +1300 >Subject: [PATCH] Bug 15565: Koha::Biblio->allowed_holds and tests > >Signed-off-by: David Cook <dcook@prosentient.com.au> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > Koha/Biblio.pm | 29 +++++++++++++++++++++ > t/db_dependent/Reserves/MultiplePerRecord.t | 16 +++++++++++- > 2 files changed, 44 insertions(+), 1 deletion(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 1d84f01a7b..5d0d00b20e 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -850,6 +850,35 @@ sub get_marc_notes { > return \@marcnotes; > } > >+=head3 allowed_holds >+ >+ my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron_obj ); >+ >+Calculates and returns the number of item-level holds a borrower is allowed to place on the record on a single day. >+ >+=cut >+ >+sub allowed_holds { >+ >+ my ( $self, $patron ) = @_; >+ >+ my $controlbranch = C4::Context->preference('ReservesControlBranch'); >+ my $holds_allowed = 0; >+ foreach my $item ( $self->items()->as_list() ) { >+ my $holds_per_day = Koha::CirculationRules->get_effective_rule({ >+ rule_name => 'holds_per_day', >+ categorycode => $patron->categorycode, >+ itemtype => $item->effective_itemtype(), >+ branchcode => ( $controlbranch and $controlbranch eq 'PatronLibrary' ) ? $patron->branchcode : $item->homebranch, >+ }); >+ $holds_per_day = $holds_per_day ? $holds_per_day->rule_value : 0; >+ if ( $holds_per_day ) { >+ $holds_allowed = $holds_per_day if $holds_per_day > $holds_allowed; >+ } >+ } >+ return $holds_allowed; >+} >+ > =head3 to_api > > my $json = $biblio->to_api; >diff --git a/t/db_dependent/Reserves/MultiplePerRecord.t b/t/db_dependent/Reserves/MultiplePerRecord.t >index 6e88740702..7659f4d0b2 100755 >--- a/t/db_dependent/Reserves/MultiplePerRecord.t >+++ b/t/db_dependent/Reserves/MultiplePerRecord.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 16; >+use Test::More tests => 18; > use t::lib::TestBuilder; > use t::lib::Mocks; > >@@ -98,6 +98,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 1, > holds_per_record => 1, >+ holds_per_day => 1, > } > } > ); >@@ -115,6 +116,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 2, > holds_per_record => 2, >+ holds_per_day => 2, > } > } > ); >@@ -130,6 +132,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 3, > holds_per_record => 3, >+ holds_per_day => 3, > } > } > ); >@@ -145,6 +148,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 4, > holds_per_record => 4, >+ holds_per_day => 4, > } > } > ); >@@ -152,6 +156,10 @@ Koha::CirculationRules->set_rules( > $max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 4, 'GetMaxPatronHoldsForRecord returns max of 4' ); > >+my $patron_obj = Koha::Patrons->find( $patron->{borrowernumber} ); >+my $holds_per_day = $biblio->allowed_holds( $patron_obj ); >+is( $holds_per_day, 4, "GetAllowedHoldsForPatronToday returns max of 4" ); >+ > Koha::CirculationRules->set_rules( > { > categorycode => $category->{categorycode}, >@@ -160,6 +168,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 5, > holds_per_record => 5, >+ holds_per_day => 5, > } > } > ); >@@ -167,6 +176,9 @@ Koha::CirculationRules->set_rules( > $max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 5, 'GetMaxPatronHoldsForRecord returns max of 5' ); > >+$holds_per_day = $biblio->allowed_holds( $patron_obj ); >+is( $holds_per_day, 5, "GetAllowedHoldsForPatronToday returns max of 4" ); >+ > Koha::CirculationRules->set_rules( > { > categorycode => undef, >@@ -175,6 +187,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 9, > holds_per_record => 9, >+ holds_per_day => 9, > } > } > ); >@@ -216,6 +229,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 3, > holds_per_record => 2, >+ holds_per_day => 3, > } > } > ); >-- >2.31.1
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 15565
:
47527
|
47551
|
47552
|
50068
|
50069
|
50392
|
50393
|
56229
|
56230
|
56231
|
56232
|
56458
|
56510
|
56511
|
56512
|
56513
|
56514
|
56515
|
56517
|
56518
|
56519
|
56520
|
56521
|
56522
|
56523
|
56524
|
61244
|
61245
|
61246
|
61247
|
61248
|
61576
|
61577
|
61578
|
61579
|
61580
|
64590
|
64591
|
64592
|
64593
|
64594
|
66594
|
66595
|
66596
|
66597
|
66598
|
68759
|
68760
|
68761
|
68762
|
68763
|
71643
|
71644
|
71645
|
71646
|
71647
|
71648
|
72644
|
72645
|
72646
|
72647
|
72648
|
72649
|
78242
|
78243
|
78244
|
78245
|
78246
|
78247
|
78248
|
78266
|
78305
|
78417
|
78418
|
78419
|
78420
|
78421
|
78422
|
78423
|
78424
|
78425
|
78426
|
78712
|
78713
|
78714
|
78715
|
78716
|
78717
|
78718
|
78719
|
78720
|
78815
|
78816
|
78817
|
78818
|
78819
|
78820
|
78821
|
78822
|
78823
|
81419
|
81420
|
81421
|
81422
|
81423
|
81424
|
81425
|
81426
|
81427
|
81431
|
81449
|
81570
|
81571
|
81572
|
81573
|
81574
|
81575
|
81576
|
81577
|
81578
|
81579
|
81580
|
81581
|
82205
|
82206
|
82207
|
82208
|
82209
|
82210
|
82211
|
82212
|
82213
|
82214
|
82215
|
82216
|
82220
|
82221
|
83331
|
83332
|
83333
|
83334
|
83335
|
83336
|
83337
|
83338
|
83339
|
83340
|
83341
|
83342
|
83378
|
83380
|
83381
|
84541
|
84542
|
84543
|
84544
|
84545
|
84546
|
84547
|
84548
|
84549
|
84550
|
84551
|
84552
|
84553
|
87979
|
87980
|
87981
|
87982
|
87983
|
87984
|
87985
|
87986
|
87987
|
87988
|
87989
|
87990
|
87991
|
117128
|
117129
|
117130
|
117131
|
117132
|
117133
|
120365
|
120366
|
120367
|
120639
|
120640
|
120641
|
121941
|
122098
|
162071
|
162072
|
162073
|
162074
|
163052
|
163053
|
163054
|
163055
|
163092
|
163093
|
166005
|
166006
|
166007
|
166008
|
166009