Lines 431-449
my ( $total, $lines ) = Koha::Account->new({ patron_id => $patron_id })->outstan
Link Here
|
431 |
sub outstanding_credits { |
431 |
sub outstanding_credits { |
432 |
my ($self) = @_; |
432 |
my ($self) = @_; |
433 |
|
433 |
|
434 |
my $outstanding_credits = Koha::Account::Lines->search( |
|
|
435 |
{ borrowernumber => $self->{patron_id}, |
436 |
amountoutstanding => { '<' => 0 } |
437 |
}, |
438 |
{ select => [ { sum => 'amountoutstanding' } ], |
439 |
as => ['outstanding_credits_total'], |
440 |
} |
441 |
); |
442 |
my $total |
443 |
= ( $outstanding_credits->count ) |
444 |
? $outstanding_credits->next->get_column('outstanding_credits_total') + 0 |
445 |
: 0; |
446 |
|
447 |
my $lines = Koha::Account::Lines->search( |
434 |
my $lines = Koha::Account::Lines->search( |
448 |
{ |
435 |
{ |
449 |
borrowernumber => $self->{patron_id}, |
436 |
borrowernumber => $self->{patron_id}, |
Lines 451-456
sub outstanding_credits {
Link Here
|
451 |
} |
438 |
} |
452 |
); |
439 |
); |
453 |
|
440 |
|
|
|
441 |
# sum returns undef if list is empty |
442 |
my $total = sum0( $lines->get_column('amountoutstanding') ); |
443 |
|
454 |
return ( $total, $lines ); |
444 |
return ( $total, $lines ); |
455 |
} |
445 |
} |
456 |
|
446 |
|