From bc435c92468714a0017d399131a3c4b245900ce5 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 18 Mar 2025 20:37:23 +0000 Subject: [PATCH] Bug 34498: Make autorenewal notices consider ItemsDeniedRenewal This fix ensures that autorenewals (and corresponding notices) are not generated for items that are configured to be denied renewal in the ItemsDeniedRenewal system preference. To test: 1. Have the default notices set for AUTO_RENEWALS and AUTO_RENEWALS_DGST. 2. Set the ItemsDeniedRenewal system preference. ( itemlost: [1,2,3,4,5] ) 3. Set the AutoRenewalNotices system preference to 'According to messaging preferences'. 4. Don't mark lost items as returned ( MarkLostItemsAsReturned ). 5. Set up some auto renewals and then mark the items as lost. 6. Run automatic_renewals.pl 7. You get a notice telling you the item cannot be renewed but no reason is specified. 8. Apply the patch and restart services 9. Run through the test plan again and confirm no notices are generated. Sponsored-by: New Zealand Parliamentary Library Signed-off-by: Magnus Enger --- misc/cronjobs/automatic_renewals.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index a3f0b92ca7..58323230ac 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -135,7 +135,7 @@ $verbose = 1 unless $verbose or $confirm; print "Test run only\n" unless $confirm; print "getting auto renewals\n" if $verbose; -my @auto_renews = Koha::Checkouts->search( +my @all_auto_renews = Koha::Checkouts->search( { auto_renew => 1, 'patron.autorenew_checkouts' => 1, @@ -145,6 +145,15 @@ my @auto_renews = Koha::Checkouts->search( order_by => 'patron.borrowernumber', } )->as_list; + +# Exclude ItemsDeniedRenewal +my @auto_renews; +foreach my $issue (@all_auto_renews) { + unless ( $issue->item->is_denied_renewal ) { + push @auto_renews, $issue; + } +} + print "found " . scalar @auto_renews . " auto renewals\n" if $verbose; my $cron_options = C4::Context->config('auto_renew_cronjob'); -- 2.34.1