Bugzilla – Attachment 95271 Details for
Bug 24009
Koha::Account->outstanding_debits should support inline filtering
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24009: Add filter_by option to outstanding_debits
Bug-24009-Add-filterby-option-to-outstandingdebits.patch (text/plain), 2.77 KB, created by
Martin Renvoize (ashimema)
on 2019-11-11 15:46:32 UTC
(
hide
)
Description:
Bug 24009: Add filter_by option to outstanding_debits
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-11-11 15:46:32 UTC
Size:
2.77 KB
patch
obsolete
>From 5f39f6efd11fa44cfae7925fe05f5ab49b744f2f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 11 Nov 2019 14:23:44 +0000 >Subject: [PATCH] Bug 24009: Add filter_by option to outstanding_debits > >This patch adds an optional 'filter_by' arguament to >Koha::Account->outstanding_debits which current accepts 'blocks_issue' >and will filter down the result set of outstanding_debits based upon the >values of the following system preferences. > >* `HoldsInNoissuesCharge` >* `RentalsInNoissuesCharge` >* `ManInvInNoissuesCharge` >--- > Koha/Account.pm | 43 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 36 insertions(+), 7 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index b120faee0f..a594607e55 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -605,24 +605,53 @@ sub balance { > > =head3 outstanding_debits > >-my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits; >+ my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits; >+ my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits( { filter_by => 'blocks_issue } ); > > It returns the debit lines with outstanding amounts for the patron. > > In scalar context, it returns a Koha::Account::Lines iterator. In list context, it will > return a list of Koha::Account::Line objects. > >+Optionally a 'filter_by' arguament can be added to pre-filter the result by certain conditions: >+ >+=over >+ >+=item blocks_issue >+ >+Filter outstanding debits to only those which affect whether a patron may have items issued to them. >+ >+=back >+ > =cut > > sub outstanding_debits { >- my ($self) = @_; >+ my ( $self, $args ) = @_; > >- return $self->lines->search( >- { >- amount => { '>' => 0 }, >- amountoutstanding => { '>' => 0 } >+ my $where = { >+ amount => { '>' => 0 }, >+ amountoutstanding => { '>' => 0 } >+ }; >+ >+ if ( exists( $args->{filter_by} ) ) { >+ if ( $args->{filter_by} eq 'blocks_issue' ) { >+ my @not_fines; >+ push @not_fines, 'RESERVE' >+ unless C4::Context->preference('HoldsInNoissuesCharge'); >+ push @not_fines, >+ ( 'RENT', 'RENT_DAILY', 'RENT_RENEW', 'RENT_DAILY_RENEW' ) >+ unless C4::Context->preference('RentalsInNoissuesCharge'); >+ unless ( C4::Context->preference('ManInvInNoissuesCharge') ) { >+ my @man_inv = >+ Koha::Account::DebitTypes->search( { is_system => 0 } ) >+ ->get_column('code'); >+ push @not_fines, @man_inv; >+ } >+ $where->{debit_type_code} = { -not_in => \@not_fines }; > } >- ); >+ } >+ >+ return $self->lines->search($where); > } > > =head3 outstanding_credits >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24009
:
95271
|
95272
|
95345
|
95346
|
99041
|
99042
|
99043