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