Bugzilla – Attachment 177845 Details for
Bug 25193
Add syspref to control location for use of AllowRenewalIfOtherItemsAvailable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25193: Add AllowRenewalIfOtherItemsAvailableLocation syspref
Bug-25193-Add-AllowRenewalIfOtherItemsAvailableLoc.patch (text/plain), 11.07 KB, created by
Jonathan Druart
on 2025-02-12 12:50:46 UTC
(
hide
)
Description:
Bug 25193: Add AllowRenewalIfOtherItemsAvailableLocation syspref
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-02-12 12:50:46 UTC
Size:
11.07 KB
patch
obsolete
>From 5ba1fa9af93e74fa5aecd1bb2dc3a194a24aa84d Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 20 Apr 2020 07:12:59 +0000 >Subject: [PATCH] Bug 25193: Add AllowRenewalIfOtherItemsAvailableLocation > syspref > >This syspref works in conjunction with AllowRenewalIfOtherItemsAvailable >syspref. It has two options - allow renewal if other items are available >to fill holds at any branch, or only at the hold's pickup branch. > >To test: >1) Apply patch, update database, restart services >2) Go to Administration -> system preferences. Search for >AllowRenewalIfOtherItemsAvailable. Notice the two sysprefs exist in the >same row. By default they should be set to "Don't allow" and "at any >library". >3) Set up a biblio with two items. Have both items held at Branch A. >4) Check out Item A to Borrower A. >5) Place a biblio-level reserve for Borrower B with pickup branch at >Branch A. >6) View Borrower A's checkouts. Confirm you cannot renew Item A ('On > hold' message). >7) Edit Item B, set the current location to Branch B. The items should >now have different locations. >8) Enable the AllowRenewalIfOtherItemsAvailable syspref. Leave the AllowRenewalIfOtherItemsAvailableLocation syspref set to "at any library". >9) View Borrower A's checkouts. Confirm you CAN renew Item A (because > Item B can fill Borrower B's reserve). >10) Set the AllowRenewalIfOtherItemsAvailableLocation syspref to "at the >hold's pickup library". Keep AllowRenewalIfOtherItemsAvailable syspref >enabled. >11) View Borrower A's checkouts. Confirm you CANNOT renew Item A >(because Item B cannot fill Borrower B's reserve due to being at a > different branch). >12) Edit Item B, set the current location to Branch A. The items should >have the same location now. >13) View Borrower A's checkouts. Confirm you CAN renew Item A. > >Sponsored-by: Chartered Accountants Australia & New Zealand > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Circulation.pm | 3 + > ...alIfOtherItemsAvailableLocation_syspref.pl | 16 ++++ > installer/data/mysql/mandatory/sysprefs.sql | 3 +- > .../admin/preferences/circulation.pref | 9 +- > t/db_dependent/Circulation.t | 93 ++++++++++++++++++- > 5 files changed, 120 insertions(+), 4 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_25193-add_AllowRenewalIfOtherItemsAvailableLocation_syspref.pl > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index d546bc04f3f..786ae8d83a7 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3204,6 +3204,9 @@ sub CanBookBeRenewed { > $patron_with_reserve, $other_item, undef, > { ignore_hold_counts => 1 } > )->{status} eq 'OK'; >+ if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation') eq 'holdbranch' ) { >+ next unless $other_item->holdingbranch eq $possible_hold->{branchcode}; >+ } > > # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy' > # CanItemBeReserved checks 'rules' and 'policies' which means >diff --git a/installer/data/mysql/atomicupdate/bug_25193-add_AllowRenewalIfOtherItemsAvailableLocation_syspref.pl b/installer/data/mysql/atomicupdate/bug_25193-add_AllowRenewalIfOtherItemsAvailableLocation_syspref.pl >new file mode 100644 >index 00000000000..23888958a8e >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_25193-add_AllowRenewalIfOtherItemsAvailableLocation_syspref.pl >@@ -0,0 +1,16 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "25193", >+ description => "Add syspref to control location for use of AllowRenewalIfOtherItemsAvailable", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ $dbh->do( >+ q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowRenewalIfOtherItemsAvailableLocation', 'any', 'any|holdbranch', 'Specify where items must be available for fulfilling holds to allow a renewal.', 'Choice') } >+ ); >+ >+ say $out "Added system preference 'AllowRenewalIfOtherItemsAvailableLocation'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 682b9fb950b..8f063242bc2 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -45,6 +45,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set fines to be visible to their guarantor', 'YesNo'), > ('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'), > ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'), >+('AllowRenewalIfOtherItemsAvailableLocation', 'any', 'any|holdbranch', 'Specify where items must be available for fulfilling holds to allow a renewal.', 'Choice'), > ('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'), > ('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'), > ('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'), >@@ -873,4 +874,4 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), > ('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), > ('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea') >-; >+; >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 7192181ea4e..0c4f8d14ba0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -802,7 +802,12 @@ Circulation: > choices: > 1: Allow > 0: "Don't allow" >- - a patron to renew an item with unfilled holds if other available items can fill that hold. >+ - a patron to renew an item with unfilled holds if other available items >+ - pref: AllowRenewalIfOtherItemsAvailableLocation >+ choices: >+ any: "at any library" >+ holdbranch: "at the hold's pickup library" >+ - can fill that hold. > - > - pref: AllowHoldPolicyOverride > choices: >@@ -1514,4 +1519,4 @@ Circulation: > choices: > 1: Enable > 0: Disable >- - "the curbside pickup module." >+ - "the curbside pickup module." >\ No newline at end of file >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index d3e7dea4f69..ec79b077682 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 75; >+use Test::More tests => 76; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -2399,6 +2399,97 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > ); > } > >+subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { >+ plan tests => 3; >+ >+ $dbh->do('DELETE FROM issues'); >+ $dbh->do('DELETE FROM items'); >+ $dbh->do('DELETE FROM circulation_rules'); >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rules => { >+ reservesallowed => 25, >+ issuelength => 14, >+ lengthunit => 'days', >+ renewalsallowed => 1, >+ renewalperiod => 7, >+ norenewalbefore => undef, >+ auto_renew => 0, >+ fine => .10, >+ chargeperiod => 1, >+ maxissueqty => 20, >+ onshelfholds => 1, >+ } >+ } >+ ); >+ my $biblio = $builder->build_sample_biblio(); >+ >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library2->{branchcode}, >+ itype => $itemtype, >+ } >+ ); >+ >+ # add second item with different branchcode >+ my $item_2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->{branchcode}, >+ itype => $itemtype, >+ } >+ ); >+ >+ my $borrower1 = Koha::Patron->new( >+ { >+ firstname => 'Kyle', >+ surname => 'Hall', >+ categorycode => $patron_category->{categorycode}, >+ branchcode => $library2->{branchcode}, >+ } >+ )->store; >+ my $borrowernumber1 = $borrower1->id; >+ my $borrower2 = Koha::Patron->new( >+ { >+ firstname => 'Chelsea', >+ surname => 'Hall', >+ categorycode => $patron_category->{categorycode}, >+ branchcode => $library2->{branchcode}, >+ } >+ )->store; >+ my $borrowernumber2 = $borrower2->id; >+ >+ my $issue = AddIssue( $borrower1, $item_1->barcode ); >+ >+ # place bib-level reserve >+ AddReserve( >+ { >+ branchcode => $library2->{branchcode}, >+ borrowernumber => $borrowernumber2, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); >+ t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); >+ my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); >+ is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); >+ >+ t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); >+ ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); >+ is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); >+ >+ # adjust 2nd item to have same branchcode >+ $item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store; >+ ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); >+ is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); >+}; >+ > subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > plan tests => 26; > >-- >2.34.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 25193
:
103318
|
103322
|
103516
|
107293
|
110083
|
110415
|
110437
|
161126
|
171168
|
172554
|
175482
| 177845