Bug 22588: (follow-up) Simplify getting accounts even more
authorJosef Moravec <josef.moravec@gmail.com>
Thu, 28 Mar 2019 08:53:46 +0000 (08:53 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 16 Apr 2019 13:17:33 +0000 (13:17 +0000)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
opac/opac-account.pl
opac/sco/sco-main.pl

index 1b88abf..0974880 100644 (file)
@@ -60,8 +60,8 @@
                         [%- IF ACCOUNT_LINE.description %][% ACCOUNT_LINE.description | html %][% END %]
                         [% IF ACCOUNT_LINE.itemnumber %]([% ACCOUNT_LINE.item.biblio.title | html %])[% END %]
                     </td>
-                    [% IF ( ACCOUNT_LINE.amount <= 0 ) %]<td class="credit">[% ACCOUNT_LINE.amount * -1 | $Price %][% ELSE %]<td class="debit">[% ACCOUNT_LINE.amount | $Price %][% END %]</td>
-                    [% IF ( ACCOUNT_LINE.amountoutstanding <= 0 ) %]<td class="credit">[% ACCOUNT_LINE.amountoutstanding * -1 | $Price %][% ELSE %]<td class="debit">[% ACCOUNT_LINE.amountoutstanding | $Price %][% END %]</td>
+                    [% IF ( ACCOUNT_LINE.is_credit ) %]<td class="credit">[% ACCOUNT_LINE.amount * -1 | $Price %][% ELSE %]<td class="debit">[% ACCOUNT_LINE.amount | $Price %][% END %]</td>
+                    [% IF ( ACCOUNT_LINE.is_credit ) %]<td class="credit">[% ACCOUNT_LINE.amountoutstanding * -1 | $Price %][% ELSE %]<td class="debit">[% ACCOUNT_LINE.amountoutstanding | $Price %][% END %]</td>
                 </tr>
             [% END %]
         </tbody>
index 4e4d789..9c47e35 100755 (executable)
@@ -40,14 +40,12 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 );
 
 my $patron = Koha::Patrons->find( $borrowernumber );
-my $total = $patron->account->balance;
-my @accts = Koha::Account::Lines->search(
-    { borrowernumber => $patron->borrowernumber },
-    { order_by       => { -desc => 'accountlines_id' } }
-);
+my $account = $patron->account;
+my $total = $account->balance;
+my $accountlines = $account->lines;
 
 $template->param(
-    ACCOUNT_LINES => \@accts,
+    ACCOUNT_LINES => $accountlines,
     total         => $total,
     accountview   => 1,
     message       => scalar $query->param('message') || q{},
index 83c7f2a..bbaaf70 100755 (executable)
@@ -278,11 +278,9 @@ if ($borrower) {
         m/priority/ and $show_priority = 1;
     }
 
-    my $total = $patron->account->balance;
-    my @accts = Koha::Account::Lines->search(
-        { borrowernumber => $borrower->{borrowernumber} },
-        { order_by       => { -desc => 'accountlines_id' } }
-    );
+    my $account = $patron->account;
+    my $total = $account->balance;
+    my $accountlines = $account->lines;
 
     my $holds = $patron->holds;
 
@@ -301,7 +299,7 @@ if ($borrower) {
         SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
         AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
         howpriority   => $show_priority,
-        ACCOUNT_LINES => \@accts,
+        ACCOUNT_LINES => $accountlines,
         total => $total,
     );