Bug 28374: Convert printreceipt to use GetPreparedLetter

This patch converts the point of sale receipt printer controller to
using GetPreparedLetter instead of calling getletter directly.

Test plan
1. Setup for testing:
   i.   Enable EnablePointOfSale and UseCashRegisters system preferences
   ii.  Add a new cash register
        (Administration > Accounting > Cash registers)
   iii. Add one or two products for sale
        (Administration > Accounting > Debit types, make sure 'Can be sold?' is ticked)
2. Go to Home > Point of sale
3. Add some items for purchase to a sale
4. Click confirm
5. Click on 'Print receipt' and save the PDF file somewhere
6. Apply patches
7. Update database: updatedatabase
8. Repeat steps 2-5
9. Compare receipt PDFs - should be no changes
10. Check that the default RECEIPT is updated - for print, HTML should be ticked
11. Sign off!

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2021-05-18 16:15:53 +01:00 committed by Jonathan Druart
parent 88e9cca359
commit b1fbae1580
2 changed files with 33 additions and 19 deletions

View file

@ -1,14 +1,15 @@
[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE Branches %]
[% USE Price %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Print receipt</title>
[% INCLUDE 'doc-head-close.inc' %]
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
[% INCLUDE 'blocking_errors.inc' %]
</head>
@ -16,7 +17,17 @@
<body id="pat_printfeercpt" class="pat">
<div id="receipt">
[% letter.content | $raw | evaltt %]
[% IF slip %]
[% IF plain %]
<pre>
[% slip | html %]
</pre>
[% ELSE %]
[% slip | $raw %]
[% END %]
[% ELSE %]
No print template found
[% END %]
</div>
[% MACRO jsinclude BLOCK %]

View file

@ -29,9 +29,9 @@ my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "pos/printreceipt.tt",
query => $input,
type => "intranet",
template_name => "pos/printreceipt.tt",
query => $input,
type => "intranet",
}
);
@ -51,22 +51,25 @@ output_and_exit_if_error(
) if $patron; # Payment could have been anonymous
my $lang = $patron ? $patron->lang : $template->lang;
my $letter = Koha::Notice::Templates->find_effective_template(
{
module => 'pos',
code => 'RECEIPT',
branchcode => C4::Context::mybranch,
message_transport_type => 'print',
lang => $lang
my $letter = C4::Letters::GetPreparedLetter(
module => 'pos',
letter_code => 'RECEIPT',
branchcode => C4::Context::mybranch,
message_transport_type => 'print',
lang => $lang,
tables => {
credits => $payment_id,
borrowers => $patron ? $patron->borrowernumber : undef
},
substitute => {
collected => scalar $input->param('collected'),
change => scalar $input->param('change')
}
);
$template->param(
letter => $letter,
payment => $payment,
tendered => scalar $input->param('tendered'),
change => scalar $input->param('change')
slip => $letter->{content},
plain => !$letter->{is_html}
);
output_html_with_http_headers $input, $cookie, $template->output;