Bugzilla – Attachment 157008 Details for
Bug 33399
Improve checks of other items to determine if this is a valid recall
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33399: Improve checks of other items to determine if valid recall
Bug-33399-Improve-checks-of-other-items-to-determi.patch (text/plain), 6.15 KB, created by
Aleisha Amohia
on 2023-10-13 01:45:49 UTC
(
hide
)
Description:
Bug 33399: Improve checks of other items to determine if valid recall
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-10-13 01:45:49 UTC
Size:
6.15 KB
patch
obsolete
>From 9b87089d162c5fe4f2b521b9424f08e7da501e3c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 4 Apr 2023 04:45:14 +0000 >Subject: [PATCH] Bug 33399: Improve checks of other items to determine if > valid recall > >This patch employs the following checks to determine if it is valid for a patron to place a recall: >- that we don't include items already allocated to a hold (i.e. hold 'is found') when counting for recallable items >- that we don't include items that aren't allowed to be recalled (based on the recallsallowed circulation rule) when counting for recallable items > >To test: > >1. Enable the UseRecalls system preference and configure the relevant recalls circulation and fines rules. Set 'on shelf recalls allowed' to all which means all recallable items must be unavailable in order to place recalls. >2. Create a biblio (Biblio A) with 2 items (Item A and Item B). Items A and B should have different item types. >3. Check out Item A to another patron (Patron B) >4. Log into the OPAC as Patron A in a second tab >5. Search for Biblio A and try to recall. You should be blocked because Item B could still be checked out so can't be recalled >6. Place a hold on Item B for a third patron (Patron C) >7. Check in Item B so that you're prompted about the hold, confirm the hold as waiting for Patron C >8. Go back to your OPAC tab as Patron A and try to recall. You should be blocked again because Koha thinks Item B is still available --> BUG >9. Cancel the hold on Item B >10. Go to your circulation rules and create a new rule specifically for the Item B itemtype. Set 'recalls allowed' to 0 for this item type. 'Recalls allowed' for the Item A itemtype should still be more than 0. >11. Go back to your OPAC tab as Patron A and try to recall. You should be blocked again because Koha thinks Item B can be recalled still --> BUG > >Apply patch and restart services. > >12. Run through test plan again from steps 4 to 11. Instead of being blocked, you should be able to place your recall in both cases, because Koha will no longer recognise those items as recallable. > >Sponsored-by: Auckland University of Technology >--- > Koha/Item.pm | 19 +++++++++++++++++-- > t/db_dependent/Koha/Item.t | 32 +++++++++++++++++++++++++++++++- > 2 files changed, 48 insertions(+), 3 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 854b6cfd58c..1e2a2654af5 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1932,12 +1932,27 @@ sub can_be_recalled { > return 0 if ( scalar @items == 0 ); > > my $checked_out_count = 0; >+ my $recallable_items = scalar @items; > foreach (@items) { >- if ( Koha::Checkouts->search({ itemnumber => $_->itemnumber })->count > 0 ){ $checked_out_count++; } >+ my $item_recalls_allowed = Koha::CirculationRules->get_effective_rule({ >+ branchcode => $branchcode, >+ categorycode => $patron ? $patron->categorycode : undef, >+ itemtype => $_->effective_itemtype, >+ rule_name => 'recalls_allowed', >+ }); >+ if ( $item_recalls_allowed->rule_value == 0 ) { >+ # item is not allowed to be recalled >+ $recallable_items--; >+ } elsif ( $_->holds({ found => [ 'W','T','P' ] })->count > 0 ) { >+ # item is allocated for another hold >+ $recallable_items--; >+ } elsif ( Koha::Checkouts->search({ itemnumber => $_->itemnumber })->count > 0 ) { >+ $checked_out_count++; >+ } > } > > # can't recall if on shelf recalls only allowed when all unavailable, but items are still available for checkout >- return 0 if ( $rule->{on_shelf_recalls} eq 'all' && $checked_out_count < scalar @items ); >+ return 0 if ( $rule->{on_shelf_recalls} eq 'all' && $checked_out_count < $recallable_items ); > > # can't recall if no items have been checked out > return 0 if ( $checked_out_count == 0 ); >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 129f63cea4b..ce92ce9fc5c 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -1920,7 +1920,7 @@ subtest 'store() tests' => sub { > > subtest 'Recalls tests' => sub { > >- plan tests => 23; >+ plan tests => 25; > > $schema->storage->txn_begin; > >@@ -1938,6 +1938,7 @@ subtest 'Recalls tests' => sub { > > t::lib::Mocks::mock_userenv( { patron => $patron1 } ); > t::lib::Mocks::mock_preference('UseRecalls', 1); >+ t::lib::Mocks::mock_preference('item-level_itypes', 1); > > my $recall1 = Koha::Recall->new( > { patron_id => $patron1->borrowernumber, >@@ -2016,6 +2017,35 @@ subtest 'Recalls tests' => sub { > > is( $item1->can_be_recalled({ patron => $patron1 }), 0, "Can't recall if on_shelf_recalls = all and items are still available" ); > >+ my $item2_itype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ $item2->set({ itype => $item2_itype->itemtype })->store; >+ $item2 = Koha::Items->find( $item2->id ); >+ >+ Koha::CirculationRules->set_rules({ >+ branchcode => $branchcode, >+ categorycode => $patron1->categorycode, >+ itemtype => $item2->effective_itemtype, >+ rules => { >+ recalls_allowed => 0, >+ recalls_per_record => 1, >+ on_shelf_recalls => 'all', >+ }, >+ }); >+ is( $item1->can_be_recalled({ patron => $patron1 }), 1, "Can recall because on_shelf_recalls = all and other attached item is not allowed to be recalled so doesn't count" ); >+ >+ Koha::CirculationRules->set_rules({ >+ branchcode => $branchcode, >+ categorycode => $patron1->categorycode, >+ itemtype => $item2->effective_itemtype, >+ rules => { >+ recalls_allowed => 1, >+ recalls_per_record => 1, >+ on_shelf_recalls => 'all', >+ }, >+ }); >+ my $allocated_hold = $builder->build_object({ class => 'Koha::Holds', value => { itemnumber => $item2->id, borrowernumber => $patron3->id, branchcode => $branchcode, found => 'W' } }); >+ is( $item1->can_be_recalled({ patron => $patron1 }), 1, "Can recall because on_shelf_recalls = all and other attached item is allocated elsewhere so doesn't count" ); >+ > Koha::CirculationRules->set_rules({ > branchcode => $branchcode, > categorycode => $patron1->categorycode, >-- >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 33399
:
149112
| 157008