Bugzilla – Attachment 61628 Details for
Bug 17967
TT syntax for notices - Prove that ODUE is compatible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17967: TT syntax for notices - Prove that ODUE is compatible
Bug-17967-TT-syntax-for-notices---Prove-that-ODUE-.patch (text/plain), 8.07 KB, created by
Jonathan Druart
on 2017-03-24 18:13:47 UTC
(
hide
)
Description:
Bug 17967: TT syntax for notices - Prove that ODUE is compatible
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-03-24 18:13:47 UTC
Size:
8.07 KB
patch
obsolete
>From 490ebbcc655a7645b067bd8a54ce781a61704eb1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 19 Jan 2017 20:14:51 +0100 >Subject: [PATCH] Bug 17967: TT syntax for notices - Prove that ODUE is > compatible > >Nothing new here, unless we are introducing a regression. >The items.fine is a trick of our historical syntax. >We need to provide a way to access this value from the a notice template >using the TT syntax. >A bug 17976 has been opened for discussion. > >Test plan: >Define ODUE and OVERDUES_SLIP notice templates and use it to generate >overdue notices from the cronjob script (misc/cronjobs/overdue_notices.pl) >or the interface (members/print_overdues.pl). > >You should be able to generate the same notices with and without using >the TT syntax >--- > C4/Overdues.pm | 3 + > t/db_dependent/Letters/TemplateToolkit.t | 138 ++++++++++++++++++++++++++++++- > 2 files changed, 140 insertions(+), 1 deletion(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 4f255ad..0a7a2f6 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -1028,6 +1028,9 @@ sub parse_overdues_letter { > letter_code => $params->{'letter_code'}, > branchcode => $params->{'branchcode'}, > tables => \%tables, >+ loops => { >+ overdues => [ map { $_->{items}->{itemnumber} } @item_tables ], >+ }, > substitute => $substitute, > repeat => { item => \@item_tables }, > message_transport_type => $params->{message_transport_type}, >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index cefae4f..e95ddb6 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -286,7 +286,7 @@ $prepared_letter = GetPreparedLetter( > is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); > > subtest 'regression tests' => sub { >- plan tests => 6; >+ plan tests => 7; > > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower' } ); >@@ -716,7 +716,143 @@ EOF > > is( $first_tt_slip->{content}, $first_slip->{content}, ); > is( $second_tt_slip->{content}, $second_slip->{content}, ); >+ >+ # Cleanup >+ AddReturn( $item1->{barcode} ); >+ AddReturn( $item2->{barcode} ); >+ AddReturn( $item3->{barcode} ); > }; >+ >+ subtest 'ODUE|items.content|item' => sub { >+ plan tests => 1; >+ >+ my $code = 'ODUE'; >+ >+ my $branchcode = $library->{branchcode}; >+ >+ # historic syntax >+ # FIXME items.fine does not work with TT notices >+ # See bug 17976 >+ # <item> should contain Fine: <<items.fine>></item> >+ my $template = <<EOF; >+Dear <<borrowers.firstname>> <<borrowers.surname>>, >+ >+According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible. >+ >+<<branches.branchname>> >+<<branches.branchaddress1>> >+<<branches.branchaddress2>> <<branches.branchaddress3>> >+Phone: <<branches.branchphone>> >+Fax: <<branches.branchfax>> >+Email: <<branches.branchemail>> >+ >+If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned. >+ >+The following item(s) is/are currently overdue: >+ >+<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>></item> >+ >+<<items.content>> >+ >+Thank-you for your prompt attention to this matter. >+ >+<<branches.branchname>> Staff >+EOF >+ >+ reset_template( { template => $template, code => $code, module => 'circulation' } ); >+ >+ my $yesterday = dt_from_string->subtract( days => 1 ); >+ my $two_days_ago = dt_from_string->subtract( days => 2 ); >+ my $issue1 = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout >+ my $issue2 = C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue >+ my $issue3 = C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue >+ $issue1 = Koha::Checkout->_new_from_dbic( $issue1 )->unblessed; # ->unblessed should be enough but AddIssue does not return a Koha::Checkout object >+ $issue2 = Koha::Checkout->_new_from_dbic( $issue2 )->unblessed; >+ $issue3 = Koha::Checkout->_new_from_dbic( $issue3 )->unblessed; >+ >+ # For items.content >+ my @item_fields = qw( date_due title barcode author itemnumber ); >+ my $items_content = C4::Letters::get_item_content( { %$item1, %$biblio1, %$issue1 }, @item_fields ); >+ $items_content .= C4::Letters::get_item_content( { %$item2, %$biblio2, %$issue2 }, @item_fields ); >+ $items_content .= C4::Letters::get_item_content( { %$item3, %$biblio3, %$issue3 }, @item_fields ); >+ >+ my @items = ( $item1, $item2, $item3 ); >+ my $letter = C4::Overdues::parse_overdues_letter( >+ { >+ letter_code => $code, >+ borrowernumber => $patron->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ items => \@items, >+ substitute => { >+ bib => $library->{branchname}, >+ 'items.content' => $items_content, >+ count => scalar( @items ), >+ message_transport_type => 'email', >+ } >+ } >+ ); >+ >+ # Cleanup >+ AddReturn( $item1->{barcode} ); >+ AddReturn( $item2->{barcode} ); >+ AddReturn( $item3->{barcode} ); >+ >+ >+ # historic syntax >+ my $tt_template = <<EOF; >+Dear [% borrower.firstname %] [% borrower.surname %], >+ >+According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible. >+ >+[% branch.branchname %] >+[% branch.branchaddress1 %] >+[% branch.branchaddress2 %] [% branch.branchaddress3 %] >+Phone: [% branch.branchphone %] >+Fax: [% branch.branchfax %] >+Email: [% branch.branchemail %] >+ >+If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned. >+ >+The following item(s) is/are currently overdue: >+ >+[% FOREACH overdue IN overdues %] >+[%~ SET item = overdue.item ~%] >+"[% item.biblio.title %]" by [% item.biblio.author %], [% item.itemcallnumber %], Barcode: [% item.barcode %] >+[% END %] >+[% FOREACH overdue IN overdues %] >+[%~ SET item = overdue.item ~%] >+[% overdue.date_due | \$KohaDates %]\t[% item.biblio.title %]\t[% item.barcode %]\t[% item.biblio.author %]\t[% item.itemnumber %] >+[% END %] >+ >+Thank-you for your prompt attention to this matter. >+ >+[% branch.branchname %] Staff >+EOF >+ >+ reset_template( { template => $tt_template, code => $code, module => 'circulation' } ); >+ >+ C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout >+ C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue >+ C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue >+ >+ my $tt_letter = C4::Overdues::parse_overdues_letter( >+ { >+ letter_code => $code, >+ borrowernumber => $patron->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ items => \@items, >+ substitute => { >+ bib => $library->{branchname}, >+ 'items.content' => $items_content, >+ count => scalar( @items ), >+ message_transport_type => 'email', >+ } >+ } >+ ); >+ >+ is( $tt_letter->{content}, $letter->{content}, ); >+ }; >+ > }; > > subtest 'loops' => sub { >-- >2.9.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17967
:
59451
|
61628
|
63977
|
65686
|
66774