@@ -, +, @@ compatible --- Koha/ArticleRequest.pm | 2 +- t/db_dependent/Letters/TemplateToolkit.t | 54 +++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) --- a/Koha/ArticleRequest.pm +++ a/Koha/ArticleRequest.pm @@ -106,7 +106,7 @@ sub notify { if ( my $letter = C4::Letters::GetPreparedLetter( module => 'circulation', - letter_code => "AR_$status", + letter_code => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED message_transport_type => 'email', tables => { article_requests => $self->id, --- a/t/db_dependent/Letters/TemplateToolkit.t +++ a/t/db_dependent/Letters/TemplateToolkit.t @@ -30,6 +30,7 @@ use C4::Members; use C4::Biblio; use Koha::Database; use Koha::DateUtils; +use Koha::ArticleRequests; use Koha::Biblio; use Koha::Biblioitem; use Koha::Item; @@ -39,6 +40,7 @@ use Koha::Serial; use Koha::Subscription; use Koha::Suggestion; use Koha::Checkout; +use Koha::Notice::Messages; use Koha::Notice::Templates; use Koha::Patron::Modification; @@ -282,7 +284,7 @@ $prepared_letter = GetPreparedLetter( is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); subtest 'regression tests' => sub { - plan tests => 1; + plan tests => 2; my $library = $builder->build( { source => 'Branch' } ); my $patron = $builder->build( { source => 'Borrower' } ); @@ -323,6 +325,56 @@ subtest 'regression tests' => sub { is( $tt_letter->{content}, $letter->{content}, ); }; + + subtest 'AR_*' => sub { + plan tests => 1; + my $code = 'AR_CANCELED'; + my $article_request = $builder->build({ source => 'ArticleRequest' }); + my $branchcode = $library->{branchcode}; + + my $template = q| + <> <> (<>) + + Your request for an article from <> (<>) has been canceled for the following reason: + + <> + + Article requested: + Title: <> + Author: <> + Volume: <> + Issue: <> + Date: <> + Pages: <> + Chapters: <> + Notes: <> + |; + reset_template( { template => $template, code => $code, module => 'circulation' } ); + Koha::ArticleRequests->find( $article_request->{id} )->cancel; + my $letter = Koha::Notice::Messages->single( {}, { order_by => { -desc => 'id' } } ); + + my $tt_template = q| + [% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %]) + + Your request for an article from [% biblio.title %] ([% items.barcode %]) has been canceled for the following reason: + + [% article_request.notes %] + + Article requested: + Title: [% article_request.title %] + Author: [% article_request.author %] + Volume: [% article_request.volume %] + Issue: [% article_request.issue %] + Date: [% article_request.date %] + Pages: [% article_request.pages %] + Chapters: [% article_request.chapters %] + Notes: [% article_request.patron_notes %] + |; + reset_template( { template => $template, code => $code, module => 'circulation' } ); + Koha::ArticleRequests->find( $article_request->{id} )->cancel; + my $tt_letter = Koha::Notice::Messages->single( {}, { order_by => { -desc => 'id' } } ); + is( $tt_letter->{content}, $letter->{content}, ); + }; }; sub reset_template { --