View | Details | Raw Unified | Return to bug 17963
Collapse All | Expand All

(-)a/C4/Letters.pm (+6 lines)
Lines 1468-1473 sub _get_tt_params { Link Here
1468
    my $params;
1468
    my $params;
1469
1469
1470
    my $config = {
1470
    my $config = {
1471
        article_requests => {
1472
            module   => 'Koha::ArticleRequests',
1473
            singular => 'article_request',
1474
            plural   => 'article_requests',
1475
            pk       => 'id',
1476
          },
1471
        biblio => {
1477
        biblio => {
1472
            module   => 'Koha::Biblios',
1478
            module   => 'Koha::Biblios',
1473
            singular => 'biblio',
1479
            singular => 'biblio',
(-)a/Koha/ArticleRequest.pm (-1 / +1 lines)
Lines 106-112 sub notify { Link Here
106
    if (
106
    if (
107
        my $letter = C4::Letters::GetPreparedLetter(
107
        my $letter = C4::Letters::GetPreparedLetter(
108
            module                 => 'circulation',
108
            module                 => 'circulation',
109
            letter_code            => "AR_$status",
109
            letter_code            => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
110
            message_transport_type => 'email',
110
            message_transport_type => 'email',
111
            tables                 => {
111
            tables                 => {
112
                article_requests => $self->id,
112
                article_requests => $self->id,
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +54 lines)
Lines 30-35 use C4::Members; Link Here
30
use C4::Biblio;
30
use C4::Biblio;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
use Koha::ArticleRequests;
33
use Koha::Biblio;
34
use Koha::Biblio;
34
use Koha::Biblioitem;
35
use Koha::Biblioitem;
35
use Koha::Item;
36
use Koha::Item;
Lines 39-44 use Koha::Serial; Link Here
39
use Koha::Subscription;
40
use Koha::Subscription;
40
use Koha::Suggestion;
41
use Koha::Suggestion;
41
use Koha::Checkout;
42
use Koha::Checkout;
43
use Koha::Notice::Messages;
42
use Koha::Notice::Templates;
44
use Koha::Notice::Templates;
43
use Koha::Patron::Modification;
45
use Koha::Patron::Modification;
44
46
Lines 282-288 $prepared_letter = GetPreparedLetter( Link Here
282
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
284
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
283
285
284
subtest 'regression tests' => sub {
286
subtest 'regression tests' => sub {
285
    plan tests => 1;
287
    plan tests => 2;
286
288
287
    my $library = $builder->build( { source => 'Branch' } );
289
    my $library = $builder->build( { source => 'Branch' } );
288
    my $patron  = $builder->build( { source => 'Borrower' } );
290
    my $patron  = $builder->build( { source => 'Borrower' } );
Lines 323-328 subtest 'regression tests' => sub { Link Here
323
325
324
        is( $tt_letter->{content}, $letter->{content}, );
326
        is( $tt_letter->{content}, $letter->{content}, );
325
    };
327
    };
328
329
    subtest 'AR_*' => sub {
330
        plan tests => 2;
331
        my $code = 'AR_CANCELED';
332
        my $branchcode = $library->{branchcode};
333
334
        my $template = q|
335
            <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)
336
337
            Your request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason:
338
339
            <<article_requests.notes>>
340
341
            Article requested:
342
            Title: <<article_requests.title>>
343
            Author: <<article_requests.author>>
344
            Volume: <<article_requests.volume>>
345
            Issue: <<article_requests.issue>>
346
            Date: <<article_requests.date>>
347
            Pages: <<article_requests.pages>>
348
            Chapters: <<article_requests.chapters>>
349
            Notes: <<article_requests.patron_notes>>
350
        |;
351
        reset_template( { template => $template, code => $code, module => 'circulation' } );
352
        my $article_request = $builder->build({ source => 'ArticleRequest' });
353
        Koha::ArticleRequests->find( $article_request->{id} )->cancel;
354
        my $letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
355
356
        my $tt_template = q|
357
            [% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %])
358
359
            Your request for an article from [% biblio.title %] ([% item.barcode %]) has been canceled for the following reason:
360
361
            [% article_request.notes %]
362
363
            Article requested:
364
            Title: [% article_request.title %]
365
            Author: [% article_request.author %]
366
            Volume: [% article_request.volume %]
367
            Issue: [% article_request.issue %]
368
            Date: [% article_request.date %]
369
            Pages: [% article_request.pages %]
370
            Chapters: [% article_request.chapters %]
371
            Notes: [% article_request.patron_notes %]
372
        |;
373
        reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
374
        Koha::ArticleRequests->find( $article_request->{id} )->cancel;
375
        my $tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
376
        is( $tt_letter->content, $letter->content, 'Compare AR_* notices' );
377
        isnt( $tt_letter->message_id, $letter->message_id, 'Comparing AR_* notices should compare 2 different messages' );
378
    };
326
};
379
};
327
380
328
sub reset_template {
381
sub reset_template {
329
- 

Return to bug 17963