my $action = $input->param('action') || '';
my $accountlines_id = $input->param('accountlines_id');
-my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
+my $logged_in_user = Koha::Patrons->find( $loggedinuser );
my $patron = Koha::Patrons->find( $borrowernumber );
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
#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 ) {
$accountline->{'amountoutstandingcredit'} = 1;
}
-my %row = (
- 'date' => dt_from_string( $accountline->{'date'} ),
- 'amountcredit' => $accountline->{'amountcredit'},
- 'amountoutstandingcredit' => $accountline->{'amountoutstandingcredit'},
- 'description' => $accountline->{'description'},
- 'amount' => sprintf( "%.2f", $accountline->{'amount'} ),
- 'amountoutstanding' =>
- sprintf( "%.2f", $accountline->{'amountoutstanding'} ),
- 'accountno' => $accountline->{'accountno'},
- accounttype => $accountline->{accounttype},
- '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;