Bugzilla – Attachment 154711 Details for
Bug 20985
CanBookBeReserved and CanItemBeReserved should check 'On shelf holds allowed' policy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20985: Add OnShelfHoldsAllowed checks to CanItemBeReserved
Bug-20985-Add-OnShelfHoldsAllowed-checks-to-CanIte.patch (text/plain), 26.90 KB, created by
Julian Maurice
on 2023-08-23 14:40:22 UTC
(
hide
)
Description:
Bug 20985: Add OnShelfHoldsAllowed checks to CanItemBeReserved
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2023-08-23 14:40:22 UTC
Size:
26.90 KB
patch
obsolete
>From 17622cde2d28f7715c0ea55910c7c73548386457 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Tue, 17 Nov 2020 14:24:36 +0100 >Subject: [PATCH] Bug 20985: Add OnShelfHoldsAllowed checks to > CanItemBeReserved > >The expected behaviour for "On shelf holds allowed" setting for the >circulation rules (Koha administration > Patrons and circulation > >Circulation and fines rules): >- Allow holds only on items that are currently checked out or otherwise > unavailable. >- If set to "Yes", patrons can place holds on items currently checked > in. >- If set to "If any unavailable", patrons can only place holds on items > that are not unavailable. >- If set to "If all unavailable", patrons can only place holds on items > where *all* items on the record are unavailable. >(Adapted from >https://bywatersolutions.com/education/preparing-for-library-closures) > >These rules should also work when using ILS-DI, but currently they >don't. This bug makes sure that the "On shelf holds allowed" rules work >correctly when using ILS-DI to place holds. > >Test plan >--------- > >1. Enable ILS-DI (set the ILS-DI system preference to Enable). > >2. Go to Koha administration > Patrons and circulation > Circulation and > fines rules. > >3. Work through steps 4-5 for each of the settings for "On shelf holds > allowed" for all libraries/patron categories/item types: > "Yes", "If any unavailable", and "If all unavailable" > >4. Staff interface - place a hold on a record with items available for > loan, the rules should work as expected before and after the patch is > applied: > "Yes": > information column in the item table displays "Not on hold", the > hold is placed, cancel the hold > > "If any unavailable" and "If all unavailable": > the hold is not placed, message is "Cannot place hold. No items > are available to be placed on hold.", red "X" in the hold column > and the information column displays "Not on hold" > >5. ILS-DI - place a hold on a record with items available for loan > (note: without the patch, holds can be placed): > - Query to place a hold using ILS-DI on a title that have all its > items available, example query: > > http://127.0.0.1:8080/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=1&bib_id=1&request_location=127.0.0.1 > > Without the patch the hold is placed but it shouldn't be allowed, > cancel the hold > > - Query to place a hold using ILS-DI on an available item, example > query: > > http://127.0.0.1:8080/cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=1&bib_id=1&item_id=1) > > Without the patch the hold is placed but it shouldn't be allowed, > cancel the hold > >6. Run the tests in t/db_dependent/Reserves.t - these should pass. > >7. Apply the patch, flush the cache and restart Koha (if using > koha-testing-docker, run flush_memcached and restart_all) > >8. Run through steps 3-6 again, and note the changes when "If any > unavailable" and "If all unavailable" options are used: > For the staff interface: > there should be no change in behavour and should work as > expected, for the red "X" in the items table additional text is > added "onShelfHoldsNotAllowed". > > For ILS-DI: > these should now work as expected, with holds not placed, and > this message in the results returned > <code>onShelfHoldsNotAllowed</code> (check to confirm no holds > place for either the patron or the item) > > Tests: > should still pass, in particular the following tests: > - t/db_dependent/Reserves.t > - t/db_dependent/Holds.t > - t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t > - t/db_dependent/api/v1/holds.t > - t/db_dependent/ILSDI_Services.t > - t/db_dependent/Reserves/MultiplePerRecord.t > - t/db_dependent/Reserves/IsOnShelfHoldsPolicySatisfied.t (new > test file) >--- > C4/Reserves.pm | 93 +++++++++++---- > .../prog/en/modules/reserve/request.tt | 1 + > t/db_dependent/Holds.t | 30 +++++ > t/db_dependent/ILSDI_Services.t | 28 +++++ > t/db_dependent/Reserves.t | 76 +++++++++++- > .../Reserves/IsOnShelfHoldsPolicySatisfied.t | 111 ++++++++++++++++++ > t/db_dependent/Reserves/MultiplePerRecord.t | 1 + > t/db_dependent/api/v1/holds.t | 2 + > 8 files changed, 317 insertions(+), 25 deletions(-) > create mode 100755 t/db_dependent/Reserves/IsOnShelfHoldsPolicySatisfied.t > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index fd8f7e58bd..6447232a9a 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -404,8 +404,12 @@ sub CanBookBeReserved{ > current params are: > 'ignore_hold_counts' - we use this routine to check if an item can fill a hold - on this case we > should not check if there are too many holds as we only care about reservability >+ 'ignore_onshelfholds_policy' - if set to a true value, do not check if the >+ "on shelf holds" policy is satisfied; useful to avoid infinite recursion with >+ IsOnShelfHoldsPolicySatisfied and ItemsAnyAvailableAndNotRestricted > > @RETURNS { status => OK }, if the Item can be reserved. >+ { status => onShelfHoldsNotAllowed }, if onShelfHoldsAllowed parameter and item availability combination doesn't allow holds. > { status => ageRestricted }, if the Item is age restricted for this borrower. > { status => damaged }, if the Item is damaged. > { status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. >@@ -657,6 +661,12 @@ sub CanItemBeReserved { > } > } > >+ unless ( $params->{ignore_onshelfholds_policy} ) { >+ unless ( IsOnShelfHoldsPolicySatisfied( { item => $item, patron => $patron } ) ) { >+ return _cache { status => 'onShelfHoldsNotAllowed' }; >+ } >+ } >+ > return _cache { status => 'OK' }; > } > >@@ -1367,29 +1377,7 @@ sub IsAvailableForItemLevelRequest { > return 0 unless $branchitemrule->{hold_fulfillment_policy} ne 'holdgroup' || $home_library->validate_hold_sibling( {branchcode => $pickup_branchcode} ); > } > >- my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >- >- if ( $on_shelf_holds == 1 ) { >- return 1; >- } elsif ( $on_shelf_holds == 2 ) { >- >- # These calculations work at the biblio level, and can be expensive >- # we use the in-memory cache to avoid calling once per item when looping items on a biblio >- >- my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); >- my $cache_key = sprintf "ItemsAnyAvailableAndNotRestricted:%s:%s", $patron->id, $item->biblionumber; >- >- my $any_available = $memory_cache->get_from_cache($cache_key); >- return $any_available ? 0 : 1 if defined($any_available); >- >- $any_available = >- ItemsAnyAvailableAndNotRestricted( { biblionumber => $item->biblionumber, patron => $patron } ); >- $memory_cache->set_in_cache( $cache_key, $any_available ); >- return $any_available ? 0 : 1; >- >- } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved) >- return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); >- } >+ return IsOnShelfHoldsPolicySatisfied({ item => $item, patron => $patron }); > } > > =head2 ItemsAnyAvailableAndNotRestricted >@@ -1427,12 +1415,69 @@ sub ItemsAnyAvailableAndNotRestricted { > || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan > || $branchitemrule->{holdallowed} eq 'from_home_library' && $param->{patron}->branchcode ne $i->homebranch > || $branchitemrule->{holdallowed} eq 'from_local_hold_group' && ! $item_library->validate_hold_sibling( { branchcode => $param->{patron}->branchcode } ) >- || CanItemBeReserved( $param->{patron}, $i )->{status} ne 'OK'; >+ || CanItemBeReserved( $param->{patron}, $i, undef, { ignore_onshelfholds_policy => 1 } )->{status} ne 'OK'; > } > > return 0; > } > >+=head2 IsOnShelfHoldsPolicySatisfied >+ >+Verifies if a patron can place a hold on an item according to the "on shelf >+holds" policy. >+ >+Uses in-memory cache. >+ >+ $policy_ok = IsOnShelfHoldsPolicySatisfied({ item => $item, patron => $patron }) >+ >+=head3 Parameters >+ >+=over >+ >+=item C<$item> - a Koha::Item object >+ >+=item C<$patron> - a Koha::Patron object >+ >+=back >+ >+=head3 Return value >+ >+a true value if the hold is possible, a false value otherwise >+ >+=cut >+ >+sub IsOnShelfHoldsPolicySatisfied { >+ my ($args) = @_; >+ my ( $item, $patron ) = @$args{qw(item patron)}; >+ >+ my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >+ >+ if ( $on_shelf_holds == 1 ) { >+ return 1; >+ } >+ >+ if ( $on_shelf_holds == 2 ) { >+ >+ # These calculations work at the biblio level, and can be expensive >+ # we use the in-memory cache to avoid calling once per item when looping items on a biblio >+ >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); >+ my $cache_key = sprintf "ItemsAnyAvailableAndNotRestricted:%s:%s", $patron->id, $item->biblionumber; >+ >+ my $any_available = $memory_cache->get_from_cache($cache_key); >+ unless ( defined $any_available ) { >+ $any_available = >+ ItemsAnyAvailableAndNotRestricted( { biblionumber => $item->biblionumber, patron => $patron } ); >+ $memory_cache->set_in_cache( $cache_key, $any_available ); >+ } >+ >+ return $any_available ? 0 : 1; >+ } >+ >+ # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved) >+ return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); >+} >+ > =head2 AlterPriority > > AlterPriority( $where, $reserve_id, $prev_priority, $next_priority, $first_priority, $last_priority ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 682b44e967..70b926fc09 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1314,6 +1314,7 @@ > tooManyReserves: _("Too many holds"), > notReservable: _("Not holdable"), > noReservesAllowed: _("No reserves allowed"), >+ onShelfHoldsNotAllowed: _("Not holdable"), > cannotReserveFromOtherBranches: _("Patron is from different library"), > itemAlreadyOnHold: _("Patron already has hold for this item"), > cannotBeTransferred: _("Cannot be transferred to pickup library"), >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 39224e9905..618d7cd3d3 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -251,6 +251,7 @@ Koha::CirculationRules->set_rules( > branchcode => undef, > itemtype => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 25, > holds_per_record => 99, > } >@@ -262,6 +263,7 @@ Koha::CirculationRules->set_rules( > branchcode => undef, > itemtype => 'CANNOT', > rules => { >+ onshelfholds => 1, > reservesallowed => 0, > holds_per_record => 99, > } >@@ -430,6 +432,7 @@ subtest 'CanItemBeReserved' => sub { > branchcode => undef, > itemtype => $itemtype_cant, > rules => { >+ onshelfholds => 1, > reservesallowed => 0, > holds_per_record => 99, > } >@@ -441,6 +444,7 @@ subtest 'CanItemBeReserved' => sub { > branchcode => undef, > itemtype => $itemtype_can, > rules => { >+ onshelfholds => 1, > reservesallowed => 2, > holds_per_record => 2, > } >@@ -452,6 +456,7 @@ subtest 'CanItemBeReserved' => sub { > branchcode => undef, > itemtype => $itemtype_cant_record, > rules => { >+ onshelfholds => 1, > reservesallowed => 0, > holds_per_record => 0, > } >@@ -561,6 +566,7 @@ subtest 'CanItemBeReserved' => sub { > branchcode => undef, > itemtype => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 5, > holds_per_record => 1, > } >@@ -639,6 +645,7 @@ Koha::CirculationRules->set_rules( > branchcode => undef, > itemtype => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 25, > holds_per_record => 99, > } >@@ -701,6 +708,7 @@ Koha::CirculationRules->set_rules( > branchcode => undef, > itemtype => 'ONLY1', > rules => { >+ onshelfholds => 1, > reservesallowed => 1, > holds_per_record => 99, > } >@@ -743,6 +751,7 @@ subtest 'Test max_holds per library/patron category' => sub { > branchcode => undef, > itemtype => $biblio->itemtype, > rules => { >+ onshelfholds => 1, > reservesallowed => 99, > holds_per_record => 99, > } >@@ -822,6 +831,7 @@ subtest 'Pickup location availability tests' => sub { > categorycode => undef, > itemtype => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 25, > holds_per_record => 99, > } >@@ -882,6 +892,7 @@ subtest 'CanItemBeReserved / holds_per_day tests' => sub { > itemtype => $itemtype->itemtype, > rules => { > reservesallowed => 1, >+ onshelfholds => 1, > holds_per_record => 99, > holds_per_day => 2 > } >@@ -1051,6 +1062,15 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { > rule_value => 25, > } > ); >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); > > # Create item types > my $itemtype1 = $builder->build_object( { class => 'Koha::ItemTypes' } ); >@@ -1265,6 +1285,15 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { > rule_value => 25, > } > ); >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); > > # Create item types > my $itemtype1 = $builder->build_object( { class => 'Koha::ItemTypes' } ); >@@ -1613,6 +1642,7 @@ subtest 'CanItemBeReserved rule precedence tests' => sub { > categorycode => $patron->categorycode, > itemtype => $item->itype, > rules => { >+ onshelfholds => 1, > reservesallowed => 1, > } > } >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 65120df27a..4c7cfc4de9 100755 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -371,6 +371,16 @@ subtest 'Holds test' => sub { > } > ); > >+ Koha::CirculationRules->set_rule( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); >+ > t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); > Koha::CirculationRules->set_rule( > { >@@ -547,6 +557,15 @@ subtest 'Holds test for branch transfer limits' => sub { > rule_value => 99, > } > ); >+ Koha::CirculationRules->set_rule( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); > > my $limit = Koha::Item::Transfer::Limit->new({ > toBranch => $pickup_branch->{branchcode}, >@@ -613,6 +632,15 @@ subtest 'Holds test with start_date and end_date' => sub { > rule_value => 99, > } > ); >+ Koha::CirculationRules->set_rule( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); > > my $query = CGI->new; > $query->param( 'pickup_location', $pickup_library->branchcode ); >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 7e2d83e50e..63ca8d0ba2 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 77; >+use Test::More tests => 78; > use Test::MockModule; > use Test::Warn; > >@@ -185,6 +185,7 @@ Koha::CirculationRules->set_rules( > rules => { > reservesallowed => 25, > holds_per_record => 1, >+ onshelfholds => 1, > } > } > ); >@@ -1079,7 +1080,67 @@ subtest 'reserves.item_level_hold' => sub { > > $hold->delete; > }; >+}; >+ >+subtest 'OnShelfHoldAllowed test' => sub { >+ plan tests => 3; >+ $dbh->do('DELETE FROM circulation_rules'); >+ my $biblio = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; >+ >+ # Create a helper item instance for testing >+ my $item = $builder->build_sample_item({ biblionumber => $biblio, library => $branch_1, itype => $itemtype }); >+ >+ Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rules => { >+ reservesallowed => 25, >+ opacitemholds => 'Y', >+ onshelfholds => 1, >+ } >+ } >+ ); >+ >+ my $canreserve = C4::Reserves::CanItemBeReserved($patron, $item); > >+ is( $canreserve->{status}, 'OK', >+ 'item-level holds should be possible with onshelfholdallowed set to "Yes"' ); >+ >+ Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rules => { >+ reservesallowed => 25, >+ opacitemholds => 'Y', >+ onshelfholds => '0', >+ } >+ }); >+ >+ $canreserve = C4::Reserves::CanItemBeReserved($patron, $item); >+ >+ is( $canreserve->{status}, 'onShelfHoldsNotAllowed', >+ 'item-level holds should not be possible with onshelfholdallowed set to "If any unavailable"' ); >+ >+ Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rules => { >+ reservesallowed => 25, >+ opacitemholds => 'Y', >+ onshelfholds => '2', >+ } >+ }); >+ >+ $canreserve = C4::Reserves::CanItemBeReserved($patron, $item); >+ >+ is( $canreserve->{status}, 'onShelfHoldsNotAllowed', >+ 'item-level holds should not be possible with onshelfholdallowed set to "If all unavailable"' ); > }; > > subtest 'MoveReserve additional test' => sub { >@@ -1319,6 +1380,17 @@ subtest 'AllowHoldOnPatronPossession test' => sub { > my $patron = $builder->build_object({ class => "Koha::Patrons", > value => { branchcode => $item->homebranch }}); > >+ Koha::CirculationRules->set_rules( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rules => { >+ onshelfholds => 1, >+ } >+ } >+ ); >+ > C4::Circulation::AddIssue($patron->unblessed, > $item->barcode); > t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 0); >@@ -1639,6 +1711,7 @@ subtest 'CanBookBeReserved() tests' => sub { > itemtype => $itype->id, > rules => { > reservesallowed => 2, >+ onshelfholds => 1, > } > } > ); >@@ -1710,6 +1783,7 @@ subtest 'CanItemBeReserved() tests' => sub { > itemtype => $itype->id, > rules => { > reservesallowed => 2, >+ onshelfholds => 1, > } > } > ); >diff --git a/t/db_dependent/Reserves/IsOnShelfHoldsPolicySatisfied.t b/t/db_dependent/Reserves/IsOnShelfHoldsPolicySatisfied.t >new file mode 100755 >index 0000000000..bfdddc40fe >--- /dev/null >+++ b/t/db_dependent/Reserves/IsOnShelfHoldsPolicySatisfied.t >@@ -0,0 +1,111 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More; >+ >+use t::lib::TestBuilder; >+use Koha::Database; >+use Koha::Cache::Memory::Lite; >+ >+use C4::Reserves; >+ >+plan tests => 1; >+ >+my $schema = Koha::Database->schema; >+my $circulationrule_rs = $schema->resultset('CirculationRule'); >+my $builder = t::lib::TestBuilder->new; >+ >+subtest '2 items, 1 itemtype, 1 library' => sub { >+ plan tests => 3; >+ $schema->txn_begin; >+ >+ my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branchcode = $library->branchcode; >+ my $biblio = $builder->build_sample_biblio( { itemtype => $itemtype } ); >+ my $item1 = >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, library => $branchcode } ); >+ my $item2 = >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, library => $branchcode } ); >+ my $patron = >+ $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $branchcode } } ); >+ my $categorycode = $patron->categorycode; >+ >+ $circulationrule_rs->populate( >+ [ >+ [ 'branchcode', 'categorycode', 'itemtype', 'rule_name', 'rule_value' ], >+ [ $branchcode, undef, $itemtype, 'holdallowed', 'from_any_library' ], >+ [ $branchcode, undef, $itemtype, 'hold_fulfillment_policy', 'any' ], >+ [ $branchcode, $categorycode, undef, 'max_holds', '99' ], >+ [ $branchcode, $categorycode, $itemtype, 'holds_per_day', '99' ], >+ [ $branchcode, $categorycode, $itemtype, 'holds_per_record', '99' ], >+ [ $branchcode, $categorycode, $itemtype, 'reservesallowed', '99' ], >+ ] >+ ); >+ my $onshelfholds_rule = $circulationrule_rs->create( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => 'onshelfholds', >+ rule_value => '0', >+ } >+ ); >+ >+ subtest 'when all items are available' => sub { >+ plan tests => 3; >+ >+ $onshelfholds_rule->update({ rule_value => '0' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(!C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is not allowed if onshelfholds == 0'); >+ >+ $onshelfholds_rule->update({ rule_value => '1' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is always allowed if onshelfholds == 1'); >+ >+ $onshelfholds_rule->update({ rule_value => '2' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(!C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is not allowed if onshelfholds == 2'); >+ }; >+ >+ subtest 'when checked item is not available but others are available' => sub { >+ plan tests => 3; >+ >+ $item1->onloan(DateTime->now)->store; >+ >+ $onshelfholds_rule->update({ rule_value => '0' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is allowed if onshelfholds == 0'); >+ >+ $onshelfholds_rule->update({ rule_value => '1' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is always allowed if onshelfholds == 1'); >+ >+ $onshelfholds_rule->update({ rule_value => '2' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(!C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is not allowed if onshelfholds == 2'); >+ }; >+ >+ subtest 'when all items are unavailable' => sub { >+ plan tests => 3; >+ >+ $item1->onloan(DateTime->now)->store; >+ $item2->onloan(DateTime->now)->store; >+ >+ $onshelfholds_rule->update({ rule_value => '0' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is allowed if onshelfholds == 0'); >+ >+ $onshelfholds_rule->update({ rule_value => '1' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is always allowed if onshelfholds == 1'); >+ >+ $onshelfholds_rule->update({ rule_value => '2' }); >+ Koha::Cache::Memory::Lite->flush(); >+ ok(C4::Reserves::IsOnShelfHoldsPolicySatisfied({ item => $item1, patron => $patron }), 'on shelf hold is allowed if onshelfholds == 2'); >+ }; >+ >+ $schema->txn_rollback; >+}; >+ >diff --git a/t/db_dependent/Reserves/MultiplePerRecord.t b/t/db_dependent/Reserves/MultiplePerRecord.t >index 56da6d5036..5ab4be6cc4 100755 >--- a/t/db_dependent/Reserves/MultiplePerRecord.t >+++ b/t/db_dependent/Reserves/MultiplePerRecord.t >@@ -222,6 +222,7 @@ Koha::CirculationRules->set_rules( > itemtype => undef, > branchcode => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 3, > holds_per_record => 2, > } >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 245e5e6a09..483983f1b5 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -124,6 +124,7 @@ Koha::CirculationRules->set_rules( > branchcode => undef, > itemtype => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 1, > holds_per_record => 99 > } >@@ -683,6 +684,7 @@ subtest 'add() tests (maxreserves behaviour)' => sub { > branchcode => undef, > categorycode => undef, > rules => { >+ onshelfholds => 1, > reservesallowed => 3 > } > } >-- >2.30.2
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 20985
:
86874
|
89723
|
105991
|
110095
|
111954
|
112688
|
113730
|
113731
|
114801
|
114802
|
114804
|
114805
|
115732
|
115733
|
121100
|
121101
|
121102
|
121139
|
121176
|
121185
|
121186
|
121485
|
121486
| 154711