From acf7070770d403e4fcecd5f3d29c9da114c7ca31 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 To test: 1. Apply patch, restart all 2. Go to debit types and click "Show all debit types" and pick a system defined debit type to test with. I worked mainly with ACCOUNT ( Account creation fee ) but we should test with as many debit types as possible 3. Note the account_debit_types.code you are working with 4. Now go to Tools > Notices and Slips and create a new notice 5. Choose the "Debit description (custom)" module as your module. 6. Use the code from step 2 and 3. 7. In the "email" part of the noctice add something like: $[% accountline.amount %] (includes $[% accountline.amount * 0.1 %] tax) 8. Now go to Administration > Patron categories and configure a patron category to have a "Enrollment fee". ( I set mine to 100 ) 9. Now create a patron in that category. 10. Once created, visit the accounting tab for that patron. 11. You should see a description like "$100.00 (includes $10.00 tax)" 12. Try with other debit types to ensure this works with all. --- 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