Bug 24865: Customize the Accountlines Description

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 <cbrannon@cdalibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2022-02-17 09:23:28 -05:00 committed by Tomas Cohen Arazi
parent ae9c951160
commit 10fa2db886
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 45 additions and 9 deletions

View File

@ -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(

View File

@ -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')
});
},
};

View File

@ -1565,6 +1565,17 @@ tables:
- "</p>"
- "[% 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: ""

View File

@ -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;