From 0e835e26c72c0d0fefb2132539e1e62d12f02d7c Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Thu, 17 Feb 2022 09:23:28 -0500 Subject: [PATCH] Bug 24865: Customize the Accountlines Description Content-Type: text/plain; charset=utf-8 It would be great if we could customize what information was added to the "Description of charges" field when a fine was made so data could be stored even when the item is deleted. Test Plan: 1) Create an overdue checkout that will get a fine 2) Run fines.pl 3) Note the description for the fine 4) Delete the fine from the database 5) Apply this patch 6) Run updatedatabase.pl 7) Restart all the things! 8) Run fines.pl 9) Note the description of the fine is unchanged 10) Delete the fine again 11) Browse to Slips & Notices 12) Edit the new notice OVERDUE_FINE_DESC You will have access to the objects checkout, item, and borrower 13) Run fines.pl 14) Note your new description was used Signed-off-by: Christopher Brannon --- C4/Overdues.pm | 23 ++++++++++++------- .../data/mysql/atomicupdate/bug_24865.pl | 15 ++++++++++++ .../mysql/en/mandatory/sample_notices.yml | 11 +++++++++ tools/letter.pl | 5 +++- 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_24865.pl diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 09d6724ff3..afa270651d 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -27,13 +27,14 @@ use POSIX qw( ceil floor ); use Locale::Currency::Format 1.28 qw( currency_format FMT_SYMBOL ); use Carp qw( carp ); -use C4::Context; use C4::Accounts; -use Koha::Logger; +use C4::Context; use Koha::Account::Lines; use Koha::Account::Offsets; use Koha::Libraries; use Koha::Recalls; +use Koha::Logger; +use Koha::Patrons; our (@ISA, @EXPORT_OK); BEGIN { @@ -597,12 +598,18 @@ sub UpdateFine { } } else { if ( $amount ) { # Don't add new fines with an amount of 0 - my $sth4 = $dbh->prepare( - "SELECT title FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?" - ); - $sth4->execute($itemnum); - my $title = $sth4->fetchrow; - my $desc = "$title $due"; + my $patron = Koha::Patrons->find( $borrowernumber ); + my $desc = C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => 'OVERDUE_FINE_DESC', + message_transport_type => 'print', + lang => $patron->lang, + tables => { + issues => $itemnum, + borrowers => $borrowernumber, + items => $itemnum, + }, + )->{content}; my $account = Koha::Account->new({ patron_id => $borrowernumber }); $accountline = $account->add_debit( diff --git a/installer/data/mysql/atomicupdate/bug_24865.pl b/installer/data/mysql/atomicupdate/bug_24865.pl new file mode 100755 index 0000000000..764a8ca121 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24865.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "24865", + description => "Customize the Accountlines Description", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO letter + (module,code,branchcode,name,is_html,title,content,message_transport_type,lang) + VALUES ('circulation','OVERDUE_FINE_DESC','','Overdue Item Fine Description',0,'Overdue Item Fine Description','[% item.biblio.title %] [% checkout.date_due | $KohaDates %]','print','default') + }); + }, +}; diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 0af93cd37b..d1c14c709a 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1541,6 +1541,17 @@ tables: - "

" - "[% END %]" + - module: circulation + code: OVERDUE_FINE_DESC + branchcode: "" + name: "Overdue Item Fine Description" + is_html: 0 + title: "Overdue Item Fine Description" + message_transport_type: print + lang: default + content: + - "[% item.biblio.title %] [% checkout.date_due | $KohaDates %]" + - module: circulation code: AUTO_RENEWALS_DGST branchcode: "" diff --git a/tools/letter.pl b/tools/letter.pl index 1b6f39ae89..d46ddd25d6 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -56,7 +56,10 @@ 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 { map { $_->[0] => 1 } @{$codes} }; + return { + OVERDUE_FINE_DESC => 1, + map { $_->[0] => 1 } @{$codes} + }; } our $input = CGI->new; -- 2.20.1