Bug 41315: Change only notice branchcode when OverDueNoticeFrom is set to patron-homelibrary

This patch adds a new variable $notice_branchcode and uses this when getting the patron's
homelibrary to ensure we don't change the branch we are using.

To test:
 1 - At branch A - checkout three items, 1 day overdue to 3 patrons of the same category from different branches (not A)
 2 - Set the system preference OverdueNoticeFrom to 'patron home library'
 3 - Browse to More->Tools->Overdue notice/status triggers
 4 - Set overdue triggers for default library and the category used above to:
     Delay: 1
     Letter: Overdue notice (ODUE)
 5 - From the command line run the overdue notices:
     perl misc/cronjobs/overdue_notices.pl --triggered --library CPL --test --nomail -v -v
 6 - Note that we begin pass 1 with CPL and then use a different branch for passes 2 and 3
 7 - Apply patch
 8 - Repeat
 9 - Confirm branch is consistent
10 - Run without branch param:
     perl misc/cronjobs/overdue_notices.pl --triggered --library CPL --test --nomail -v -v
11 - Confirm branches are consistent

Signed-off-by: Ben Daeuber <bdaeuber@fargolibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2025-11-26 15:38:15 +00:00 committed by Lucas Gass
parent 1e4b9e33c7
commit 914c8be2c0
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 7 additions and 6 deletions

View File

@ -542,6 +542,7 @@ END_SQL
PERIOD: foreach my $i ( 1 .. 3 ) {
$verbose and warn "branch '$branchcode', categorycode = $overdue_rules->{categorycode} pass $i\n";
my $notice_branchcode = $branchcode;
my $mindays = $overdue_rules->{"delay$i"}; # the notice will be sent after mindays days (grace period)
my $maxdays = (
@ -647,8 +648,8 @@ END_SQL
my $patron = Koha::Patrons->find($borrowernumber);
if ($patron_homelibrary) {
$branchcode = $patron->branchcode;
$library = Koha::Libraries->find($branchcode);
$notice_branchcode = $patron->branchcode;
$library = Koha::Libraries->find($notice_branchcode);
$admin_email_address = $library->from_email_address;
$branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
|| $library->inbound_email_address;
@ -669,7 +670,7 @@ END_SQL
{
module => 'circulation',
code => $overdue_rules->{"letter$i"},
branchcode => $branchcode,
branchcode => $notice_branchcode,
lang => $patron->lang
}
);
@ -747,7 +748,7 @@ END_SQL
$sth2->finish;
my @message_transport_types =
@{ GetOverdueMessageTransportTypes( $branchcode, $overdue_rules->{categorycode}, $i ) };
@{ GetOverdueMessageTransportTypes( $notice_branchcode, $overdue_rules->{categorycode}, $i ) };
@message_transport_types =
@{ GetOverdueMessageTransportTypes( q{}, $overdue_rules->{categorycode}, $i ) }
unless @message_transport_types;
@ -772,7 +773,7 @@ END_SQL
module => 'circulation',
code => $overdue_rules->{"letter$i"},
message_transport_type => $effective_mtt,
branchcode => $branchcode,
branchcode => $notice_branchcode,
lang => $patron->lang
}
);
@ -781,7 +782,7 @@ END_SQL
{
letter_code => $overdue_rules->{"letter$i"},
borrowernumber => $borrowernumber,
branchcode => $branchcode,
branchcode => $notice_branchcode,
items => \@items,
substitute => { # this appears to be a hack to overcome incomplete features in this code.
bib => $library->branchname, # maybe 'bib' is a typo for 'lib<rary>'?