diff --git a/installer/data/mysql/atomicupdate/bug_22809.perl b/installer/data/mysql/atomicupdate/bug_22809.perl
new file mode 100644
index 0000000000..cbee8090da
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_22809.perl
@@ -0,0 +1,61 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
+('circulation', 'ACCOUNT_DEBIT', '', 'Account fee', 0, 'Account fee', '
+ [% IF ( LibraryName ) %]
+
+
+ [% LibraryName | html %]
+ |
+
+ [% END %]
+
+
+
+ INVOICE
+ |
+
+
+
+ [% Branches.GetName( patron.branchcode ) | html %]
+ |
+
+
+
+ Bill to: [% patron.firstname | html %] [% patron.surname | html %]
+ Card number: [% patron.cardnumber | html %]
+ |
+
+
+ | Date |
+ Description of charges |
+ Note |
+ Amount |
+ Amount outstanding |
+
+
+ [% FOREACH account IN accounts %]
+
+ | [% account.date | $KohaDates%] |
+
+ [% PROCESS account_type_description account=account %]
+ [%- IF account.description %], [% account.description | html %][% END %]
+ |
+ [% account.note | html %] |
+ [% IF ( account.amountcredit ) %][% ELSE %] | [% END %][% account.amount | $Price %] |
+ [% IF ( account.amountoutstandingcredit ) %][% ELSE %] | [% END %][% account.amountoutstanding | $Price %] |
+
+ [% END %]
+
+
+
+ | Total outstanding dues as on date: |
+ [% IF ( totalcredit ) %][% ELSE %] | [% END %][% total | $Price %] |
+
+
+
', 'print', 'default');
+ });
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
+}
diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql
index 80b5fa0612..0f38c53b70 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.sql
+++ b/installer/data/mysql/en/mandatory/sample_notices.sql
@@ -233,5 +233,60 @@ INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`
', 'print', 'default');
+INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
+('circulation', 'ACCOUNT_DEBIT', '', 'Account fee', 0, 'Account fee', '
+ [% IF ( LibraryName ) %]
+
+
+ [% LibraryName | html %]
+ |
+
+ [% END %]
+
+
+
+ INVOICE
+ |
+
+
+
+ [% Branches.GetName( patron.branchcode ) | html %]
+ |
+
+
+
+ Bill to: [% patron.firstname | html %] [% patron.surname | html %]
+ Card number: [% patron.cardnumber | html %]
+ |
+
+
+ | Date |
+ Description of charges |
+ Note |
+ Amount |
+ Amount outstanding |
+
+
+ [% FOREACH account IN accounts %]
+
+ | [% account.date | $KohaDates%] |
+
+ [% PROCESS account_type_description account=account %]
+ [%- IF account.description %], [% account.description | html %][% END %]
+ |
+ [% account.note | html %] |
+ [% IF ( account.amountcredit ) %][% ELSE %] | [% END %][% account.amount | $Price %] |
+ [% IF ( account.amountoutstandingcredit ) %][% ELSE %] | [% END %][% account.amountoutstanding | $Price %] |
+
+ [% END %]
+
+
+
+ | Total outstanding dues as on date: |
+ [% IF ( totalcredit ) %][% ELSE %] | [% END %][% total | $Price %] |
+
+
+
', 'print', 'default');
+
INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES
('circulation', 'SR_SLIP', '', 'Stock rotation slip', 0, 'Stock rotation report', 'Stock rotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason != \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email');
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
index a28ac03e34..f4c25f4e30 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
@@ -17,59 +17,7 @@
-
-
-[% IF ( LibraryName ) %]
-
-
- [% LibraryName | html %]
- |
-
-[% END %]
-
-
- INVOICE
- |
-
-
-
- [% Branches.GetName( patron.branchcode ) | html %]
- |
-
-
-
- Bill to: [% patron.firstname | html %] [% patron.surname | html %]
- Card number: [% patron.cardnumber | html %]
- |
-
-
- | Date |
- Description of charges |
- Note |
- Amount |
- Amount outstanding |
-
-
- [% FOREACH account IN accounts %]
-
- | [% account.date | $KohaDates%] |
-
- [% PROCESS account_type_description account=account %]
- [%- IF account.description %], [% account.description | html %][% END %]
- |
- [% account.note | html %] |
- [% IF ( account.amountcredit ) %][% ELSE %] | [% END %][% account.amount | $Price %] |
- [% IF ( account.amountoutstandingcredit ) %][% ELSE %] | [% END %][% account.amountoutstanding | $Price %] |
-
-
- [% END %]
-
-
- | Total outstanding dues as on date: |
- [% IF ( totalcredit ) %][% ELSE %] | [% END %][% total | $Price %] |
-
-
-
+ [% letter.content | evaltt %]
[% MACRO jsinclude BLOCK %]
diff --git a/members/printinvoice.pl b/members/printinvoice.pl
index 81b5b9f54e..98ff1c50fd 100755
--- a/members/printinvoice.pl
+++ b/members/printinvoice.pl
@@ -55,7 +55,8 @@ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log
#get account details
my $total = $patron->account->balance;
-my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed;
+my $accountline_object = Koha::Account::Lines->find($accountlines_id);
+my $accountline = $accountline_object->unblessed;
my $totalcredit;
if ( $total <= 0 ) {
@@ -85,12 +86,21 @@ my %row = (
'note' => $accountline->{'note'},
);
+my @account_offsets = Koha::Account::Offsets->search( { debit_id => $accountline_object->id } );
+
+my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_DEBIT', C4::Context::mybranch, 'print', $patron->lang );
+
$template->param(
- patron => $patron,
- finesview => 1,
- total => sprintf( "%.2f", $total ),
- totalcredit => $totalcredit,
- accounts => [$accountline], # FIXME There is always only 1 row!
+ letter => $letter,
+ patron => $patron,
+ library => C4::Context::mybranch,
+ offsets => \@account_offsets,
+ debit => $accountline_object,
+
+ finesview => 1,
+ total => sprintf( "%.2f", $total ),
+ totalcredit => $totalcredit,
+ accounts => [$accountline], # FIXME There is always only 1 row!
);
output_html_with_http_headers $input, $cookie, $template->output;