From e579f5019a7d4b171c3cdfa5a07441ff34072dd7 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 19 Apr 2022 11:48:14 +0000 Subject: [PATCH] Bug 24865: (QA follow-up) Remove hardcoded notice name from protected_letters If the letter has been removed, fall back to itemnumber/due date. (Title is no longer fetched.) We may assume that the notice is present. Note: The option to 'protect' a notice may need some more thought. Perhaps it needs to be an attribute on itself. Signed-off-by: Marcel de Rooy Tested by deleting notice, running fines again. Signed-off-by: Tomas Cohen Arazi --- C4/Overdues.pm | 5 +++-- tools/letter.pl | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index c277c6cffb..1894731c06 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -599,7 +599,7 @@ sub UpdateFine { } else { if ( $amount ) { # Don't add new fines with an amount of 0 my $patron = Koha::Patrons->find( $borrowernumber ); - my $desc = C4::Letters::GetPreparedLetter( + my $letter = eval { C4::Letters::GetPreparedLetter( module => 'circulation', letter_code => 'OVERDUE_FINE_DESC', message_transport_type => 'print', @@ -609,7 +609,8 @@ sub UpdateFine { borrowers => $borrowernumber, items => $itemnum, }, - )->{content}; + ) }; + my $desc = $letter ? $letter->{content} : "Item $itemnum - due $due"; my $account = Koha::Account->new({ patron_id => $borrowernumber }); $accountline = $account->add_debit( diff --git a/tools/letter.pl b/tools/letter.pl index 9751b70752..4276e46280 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -56,10 +56,7 @@ use Koha::Patron::Attribute::Types; sub protected_letters { my $dbh = C4::Context->dbh; my $codes = $dbh->selectall_arrayref(q{SELECT DISTINCT letter_code FROM message_transports}); - return { - OVERDUE_FINE_DESC => 1, - map { $_->[0] => 1 } @{$codes} - }; + return { map { $_->[0] => 1 } @{$codes} }; } our $input = CGI->new; -- 2.39.5