|
Lines 36-43
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 36 |
); |
36 |
); |
| 37 |
|
37 |
|
| 38 |
my $payment_id = $input->param('accountlines_id'); |
38 |
my $payment_id = $input->param('accountlines_id'); |
| 39 |
my $payment = Koha::Account::Lines->find($payment_id); |
39 |
my $accountline = Koha::Account::Lines->find($payment_id); |
| 40 |
my $patron = $payment->patron; |
40 |
my $patron = $accountline->patron; |
| 41 |
|
41 |
|
| 42 |
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in"; |
42 |
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in"; |
| 43 |
output_and_exit_if_error( |
43 |
output_and_exit_if_error( |
|
Lines 51-64
output_and_exit_if_error(
Link Here
|
| 51 |
) if $patron; # Payment could have been anonymous |
51 |
) if $patron; # Payment could have been anonymous |
| 52 |
|
52 |
|
| 53 |
my $lang = $patron ? $patron->lang : $template->lang; |
53 |
my $lang = $patron ? $patron->lang : $template->lang; |
|
|
54 |
# Determine template and table based on account line type |
| 55 |
my ($letter_code, $table_key, $table_id); |
| 56 |
if ($accountline->is_credit) { |
| 57 |
$letter_code = 'RECEIPT'; |
| 58 |
$table_key = 'credits'; |
| 59 |
$table_id = $accountline->accountlines_id; |
| 60 |
} elsif ($accountline->is_debit && $accountline->debit_type_code eq 'PAYOUT') { |
| 61 |
$letter_code = 'PAYOUT'; |
| 62 |
$table_key = 'debits'; |
| 63 |
$table_id = $accountline->accountlines_id; |
| 64 |
} else { |
| 65 |
die "Account line " . $payment_id . " is not a credit or supported payout transaction"; |
| 66 |
} |
| 67 |
|
| 54 |
my $letter = C4::Letters::GetPreparedLetter( |
68 |
my $letter = C4::Letters::GetPreparedLetter( |
| 55 |
module => 'pos', |
69 |
module => 'pos', |
| 56 |
letter_code => 'RECEIPT', |
70 |
letter_code => $letter_code, |
| 57 |
branchcode => C4::Context::mybranch, |
71 |
branchcode => C4::Context::mybranch, |
| 58 |
message_transport_type => 'print', |
72 |
message_transport_type => 'print', |
| 59 |
lang => $lang, |
73 |
lang => $lang, |
| 60 |
tables => { |
74 |
tables => { |
| 61 |
credits => $payment_id, |
75 |
$table_key => $table_id, |
| 62 |
borrowers => $patron ? $patron->borrowernumber : undef |
76 |
borrowers => $patron ? $patron->borrowernumber : undef |
| 63 |
}, |
77 |
}, |
| 64 |
substitute => { |
78 |
substitute => { |
| 65 |
- |
|
|