View | Details | Raw Unified | Return to bug 20946
Collapse All | Expand All

(-)a/Koha/Account.pm (-14 / +6 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
use Data::Dumper;
23
use Data::Dumper;
24
use List::MoreUtils qw( uniq );
24
use List::MoreUtils qw( uniq );
25
use List::Util qw( sum );
25
26
26
use C4::Log qw( logaction );
27
use C4::Log qw( logaction );
27
use C4::Stats qw( UpdateStats );
28
use C4::Stats qw( UpdateStats );
Lines 297-315 my ( $total, $lines ) = Koha::Account->new({ patron_id => $patron_id })->outstan Link Here
297
sub outstanding_debits {
298
sub outstanding_debits {
298
    my ($self) = @_;
299
    my ($self) = @_;
299
300
300
    my $outstanding_debits = Koha::Account::Lines->search(
301
        {   borrowernumber    => $self->{patron_id},
302
            amountoutstanding => { '>' => 0 }
303
        },
304
        {   select => [ { sum => 'amountoutstanding' } ],
305
            as     => ['outstanding_debits_total'],
306
        }
307
    );
308
    my $total
309
        = ( $outstanding_debits->count )
310
        ? $outstanding_debits->next->get_column('outstanding_debits_total') + 0
311
        : 0;
312
313
    my $lines = Koha::Account::Lines->search(
301
    my $lines = Koha::Account::Lines->search(
314
        {
302
        {
315
            borrowernumber    => $self->{patron_id},
303
            borrowernumber    => $self->{patron_id},
Lines 317-322 sub outstanding_debits { Link Here
317
        }
305
        }
318
    );
306
    );
319
307
308
    my $total =
309
      ( $lines->count )
310
      ? sum( $lines->get_column('amountoutstanding') ) + 0
311
      : 0;
312
320
    return ( $total, $lines );
313
    return ( $total, $lines );
321
}
314
}
322
315
323
- 

Return to bug 20946