|
Lines 606-629
sub balance {
Link Here
|
| 606 |
|
606 |
|
| 607 |
=head3 outstanding_debits |
607 |
=head3 outstanding_debits |
| 608 |
|
608 |
|
| 609 |
my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits; |
609 |
my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits; |
|
|
610 |
my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits( { filter_by => 'blocks_issue } ); |
| 610 |
|
611 |
|
| 611 |
It returns the debit lines with outstanding amounts for the patron. |
612 |
It returns the debit lines with outstanding amounts for the patron. |
| 612 |
|
613 |
|
| 613 |
In scalar context, it returns a Koha::Account::Lines iterator. In list context, it will |
614 |
In scalar context, it returns a Koha::Account::Lines iterator. In list context, it will |
| 614 |
return a list of Koha::Account::Line objects. |
615 |
return a list of Koha::Account::Line objects. |
| 615 |
|
616 |
|
|
|
617 |
Optionally a 'filter_by' arguament can be added to pre-filter the result by certain conditions: |
| 618 |
|
| 619 |
=over |
| 620 |
|
| 621 |
=item blocks_issue |
| 622 |
|
| 623 |
Filter outstanding debits to only those which affect whether a patron may have items issued to them. |
| 624 |
|
| 625 |
=back |
| 626 |
|
| 616 |
=cut |
627 |
=cut |
| 617 |
|
628 |
|
| 618 |
sub outstanding_debits { |
629 |
sub outstanding_debits { |
| 619 |
my ($self) = @_; |
630 |
my ( $self, $args ) = @_; |
| 620 |
|
631 |
|
| 621 |
return $self->lines->search( |
632 |
my $where = { |
| 622 |
{ |
633 |
amount => { '>' => 0 }, |
| 623 |
amount => { '>' => 0 }, |
634 |
amountoutstanding => { '>' => 0 } |
| 624 |
amountoutstanding => { '>' => 0 } |
635 |
}; |
|
|
636 |
|
| 637 |
if ( exists( $args->{filter_by} ) ) { |
| 638 |
if ( $args->{filter_by} eq 'blocks_issue' ) { |
| 639 |
my @not_fines; |
| 640 |
push @not_fines, 'RESERVE' |
| 641 |
unless C4::Context->preference('HoldsInNoissuesCharge'); |
| 642 |
push @not_fines, |
| 643 |
( 'RENT', 'RENT_DAILY', 'RENT_RENEW', 'RENT_DAILY_RENEW' ) |
| 644 |
unless C4::Context->preference('RentalsInNoissuesCharge'); |
| 645 |
unless ( C4::Context->preference('ManInvInNoissuesCharge') ) { |
| 646 |
my @man_inv = |
| 647 |
Koha::Account::DebitTypes->search( { is_system => 0 } ) |
| 648 |
->get_column('code'); |
| 649 |
push @not_fines, @man_inv; |
| 650 |
} |
| 651 |
$where->{debit_type_code} = { -not_in => \@not_fines }; |
| 625 |
} |
652 |
} |
| 626 |
); |
653 |
} |
|
|
654 |
|
| 655 |
return $self->lines->search($where); |
| 627 |
} |
656 |
} |
| 628 |
|
657 |
|
| 629 |
=head3 outstanding_credits |
658 |
=head3 outstanding_credits |
| 630 |
- |
|
|