Bugzilla – Attachment 99042 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.88 KB, created by
Bouzid Fergani
on 2020-02-14 21:04:33 UTC
(
hide
)
Description:
Bug 24009: Add filter_by option to outstanding_debits
Filename:
MIME Type:
Creator:
Bouzid Fergani
Created:
2020-02-14 21:04:33 UTC
Size:
2.88 KB
patch
obsolete
>From de81de92677de108699c7e37de5696e32a7b3e24 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' argument 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` > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> >--- > Koha/Account.pm | 43 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 36 insertions(+), 7 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 6fc4641..263d26a 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -606,24 +606,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.7.4
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