From 99ef971cfe9be385e9cb14d51359cda7e47eab5c Mon Sep 17 00:00:00 2001 From: Andrew Fuerste Henry Date: Tue, 14 Jan 2025 19:49:36 +0000 Subject: [PATCH] Bug 38894: Use HomeOrHoldingBranch with longoverdue cronjob To test: 1: have 4 items, 2 with homebranch = Library A and 2 with homebranch = Library B 2: Logged into Library A, check out 1 Library A item and 1 Library B item, both with due dates in the past enough for the longoverdue cron 3: set yourself to Library B, check out 1 Library A item and 1 Library B item, both with due dates in the past enough for the longoverdue cron 4: Run longoverdue cron with --verbose, without --confirm, and without --Library. see that it would act on all 4 items 5: Set CircControl to "the library the item is from" 6: Set HomeOrHoldingBranch to "the item's home library" 7: Run longoverdue cron with --verbose and --library="A" (where A is the code for your Library A), wihout --confirm 8: See the cron wants to act on the items with homebranch = A 9: Set HomeOrHoldingBranch to "the item's holding library" 10: Run longoverdue cron with --verbose and --library="A" (where A is the code for your Library A), wihout --confirm 11: See the cron is still trying to act on the two items with homebranch = A 12: Apply patch, restart all 13: Run longoverdue cron with --verbose and --library="A" (where A is the code for your Library A), wihout --confirm 14: See the cron is now trying to act on the two items with holdingbranch = A 15: Set HomeOrHoldingBranch to "the item's home library" 16: Run longoverdue cron with --verbose and --library="A" (where A is the code for your Library A), wihout --confirm 17: See the cron wants to act on the items with homebranch = A --- misc/cronjobs/longoverdue.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 4da8846d65..6288f9d9d3 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -355,6 +355,7 @@ sub longoverdue_sth { my $dbh = C4::Context->dbh; my $circ_control_pref = C4::Context->preference('CircControl'); +my $home_holding_pref = C4::Context->preference('HomeOrHoldingBranch'); my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode'); $borrower_category = [ map { uc $_ } @$borrower_category ]; @@ -478,7 +479,11 @@ foreach my $startrange (sort keys %$lost) { } elsif ( $_ eq 'PickupLibrary' ) { $lib = C4::Context->userenv->{'branch'}; } else { # ( $_ eq 'ItemHomeLibrary' ) - $lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); + if ($home_holding_pref eq 'homebranch') { + $lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); + } else { # ( $home_holding_pref eq 'holdingbranch' ) + $lib = Koha::Items->find( $row->{itemnumber} )->holdingbranch(); + } } } next ITEM unless ( $branches_to_process{$lib} ); -- 2.39.5