From 967d44d22ea4215e88e686ced4c571241f1d76f9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 12 Mar 2021 14:38:31 +0000 Subject: [PATCH] Bug 26689: Check for specific template then fallback - printfeercpt This patch adds a check for a more specific ACCOUNT_CREDIT template (named to match the credit_type_code of the credit line) prior to falling back to the ACCOUNT_CREDIT template. Test plan 1/ On a patrons account page use the print option on a series of credit lines with differing credit types (Payment, Lost Item Return, Writeoff) 2/ Note that the same template 'ACCOUNT_CREDIT' is used for all types 3/ Apply the patch 4/ Run step 1 again and note all still print using ACCOUNT_CREDIT 5/ Add a new notice template under the 'circulation' module with a code that matches one of your account credit types (PAYMENT, WRITEOFF, LOST_FOUND) 6/ Run step 1 again and note that where you have added a specific notice for that credit type it has been used. --- members/printfeercpt.pl | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl index 0dd60f3de2..30805ff6e4 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -55,8 +55,37 @@ output_and_exit_if_error( } ); -my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT', - C4::Context::mybranch, 'print', $patron->lang ); +my $letter = C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => $credit->credit_type_code, + branchcode => C4::Context::mybranch, + message_transport_type => 'print', + lang => $patron->lang, + tables => { + credits => $credit_id, + borrowers => $patron->borrowernumber + }, + substitute => { + tendered => scalar $input->param('tendered'), + change => scalar $input->param('change') + } +); + +$letter //= C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => 'ACCOUNT_CREDIT', + branchcode => C4::Context::mybranch, + message_transport_type => 'print', + lang => $patron->lang, + tables => { + credits => $credit_id, + borrowers => $patron->borrowernumber + }, + substitute => { + tendered => scalar $input->param('tendered'), + change => scalar $input->param('change') + } +); $template->param( letter => $letter, -- 2.20.1