From b7c6869e60c9b5435ca50fcc95eaeb2d7789142a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 15 Oct 2018 12:53:27 -0400 Subject: [PATCH] Bug 20629 - Pass accountline objects to template instead of hashref --- .../prog/en/modules/members/boraccount.tt | 8 ++--- members/boraccount.pl | 31 +------------------ 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index 2a41a9bcb8..72c84b0a37 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -67,17 +67,17 @@  [% IF ( account.itemnumber ) %][% account.item.biblio.title | html %][% END %] [% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %] [% account.note | html_line_break %] - [% IF ( account.amountcredit ) %][% ELSE %][% END %][% account.amount | $Price %] - [% IF ( account.amountoutstandingcredit ) %][% ELSE %][% END %][% account.amountoutstanding | $Price %] + [% IF account.amount <= 0 %][% ELSE %][% END %][% account.amount | $Price %] + [% IF account.amountoutstanding <= 0 %][% ELSE %][% END %][% account.amountoutstanding | $Price %] - [% IF ( account.payment ) %] + [% IF ( account.is_credit ) %] Print [% ELSE %] Print [% END %] Details [% IF ( reverse_col) %] - [% IF account.object.is_credit %] + [% IF account.is_credit %] Void [% ELSE %]   diff --git a/members/boraccount.pl b/members/boraccount.pl index a36979aed2..7f94bf2e45 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -69,7 +69,7 @@ if ( $action eq 'void' ) { #get account details my $total = $patron->account->balance; -my $accts = Koha::Account::Lines->search( +my @accountlines = Koha::Account::Lines->search( { borrowernumber => $patron->borrowernumber }, { order_by => { -desc => 'accountlines_id' } } ); @@ -80,35 +80,6 @@ if($total <= 0){ } my $reverse_col = 0; # Flag whether we need to show the reverse column -my @accountlines; -while ( my $line = $accts->next ) { - # FIXME We should pass the $accts iterator to the template and do this formatting part there - my $accountline = $line->unblessed; - $accountline->{object} = $line; - $accountline->{amount} += 0.00; - if ($accountline->{amount} <= 0 ) { - $accountline->{amountcredit} = 1; - } - $accountline->{amountoutstanding} += 0.00; - if ( $accountline->{amountoutstanding} <= 0 ) { - $accountline->{amountoutstandingcredit} = 1; - } - - $accountline->{amount} = sprintf '%.2f', $accountline->{amount}; - $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding}; - if ($accountline->{amount} < 0) { - $accountline->{payment} = 1 - if ( $accountline->{accounttype} =~ /^Pay/ ); - - $reverse_col = 1; - } - - if ( $accountline->{itemnumber} ) { - # Because we will not have access to the object from the template - $accountline->{item} = $line->item; - } - push @accountlines, $accountline; -} if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($borrowernumber); -- 2.17.1 (Apple Git-112)