From a10238e71aae35a4a9530cd6207acbca86b6ec79 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 20 Oct 2025 19:45:30 +0000 Subject: [PATCH] Bug 40255: Allow for custom debit descriptions --- Koha/Account/Line.pm | 21 +++++++++++++++++++ .../prog/en/modules/tools/letter.tt | 8 +++++++ 2 files changed, 29 insertions(+) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index f44761fcf48..391d95af79c 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -28,6 +28,7 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions::Account; use Koha::Patron::Debarments; +use C4::Letters; use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields); @@ -1097,6 +1098,26 @@ sub store { } } + #if there is a matching debit description letter, pull that content and render it for the accountline.description + if ( $self->is_debit && !$self->in_storage && !$self->description ) { + my $debit_type = $self->debit_type; + if ($debit_type) { + my $letter = C4::Letters::GetPreparedLetter( + module => 'debit_description', + letter_code => $debit_type->code, + tables => { + borrowers => $self->borrowernumber, + branches => $self->branchcode, + accountline => $self, + }, + ); + + if ( $letter && $letter->{content} ) { + $self->description( $letter->{content} ); + } + } + } + return $self->SUPER::store(); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 6ec0ce10799..63d6a293b49 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -208,6 +208,7 @@
  • Point of sale
  • Reports
  • Bookings
  • +
  • Debit description (custom)
  • @@ -290,6 +291,8 @@ Reports [% CASE 'bookings' %] Bookings + [% CASE 'debit_description' %] + Debit description (custom) [% CASE %] [% lette.module | html %] [% END %] @@ -501,6 +504,11 @@ [% ELSE %] [% END %] + [% IF ( module == "debit_descriptions" ) %] + + [% ELSE %] + + [% END %]
  • -- 2.39.5