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