Bugzilla – Attachment 110644 Details for
Bug 25670
Add useful methods to Koha::Acquisition::Orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25670: Add filter_by_active and filter_by_id_including_transfers
Bug-25670-Add-filterbyactive-and-filterbyidincludi.patch (text/plain), 2.79 KB, created by
Martin Renvoize (ashimema)
on 2020-09-24 09:54:39 UTC
(
hide
)
Description:
Bug 25670: Add filter_by_active and filter_by_id_including_transfers
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-09-24 09:54:39 UTC
Size:
2.79 KB
patch
obsolete
>From 0d1455829030db64edfa2af4b72d7acba6ca347f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 3 Jun 2020 16:58:33 -0300 >Subject: [PATCH] Bug 25670: Add filter_by_active and > filter_by_id_including_transfers > >This patch introduces a method to filter on the ordernumber, looking for >it on the aqorders_transfers table ('ordernumber_from' field). > >It also adds a method for filtering on active orders. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Acquisition/Orders.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >lib > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Acquisition/Orders.pm | 54 +++++++++++++++++++++++++++++++++++--- > 1 file changed, 51 insertions(+), 3 deletions(-) > >diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm >index b8ee2f7d65..67b5dd0244 100644 >--- a/Koha/Acquisition/Orders.pm >+++ b/Koha/Acquisition/Orders.pm >@@ -23,6 +23,7 @@ use Koha::Database; > > use Koha::DateUtils qw( dt_from_string ); > use Koha::Acquisition::Order; >+use Koha::Exceptions::Exception; > > use base qw(Koha::Objects); > >@@ -32,7 +33,7 @@ Koha::Acquisition::Orders object set class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods > > =head3 filter_by_lates > >@@ -130,6 +131,23 @@ sub filter_by_lates { > ); > } > >+=head3 filter_by_active >+ >+ my $new_rs = $orders->filter_by_active; >+ >+Returns a new resultset filtering orders that are not active. >+ >+=cut >+ >+sub filter_by_active { >+ my ($self) = @_; >+ return $self->search( >+ { >+ orderstatus => [ 'new', 'ordered', 'partial' ] >+ } >+ ); >+} >+ > =head3 filter_by_current > > $orders->filter_by_current >@@ -164,9 +182,39 @@ sub filter_by_cancelled { > ); > } > >+=head3 filter_by_id_including_transfers >+ >+ my $orders = $orders->filter_by_id_including_transfers( >+ { >+ ordernumber => $ordernumber >+ } >+ ); >+ >+When searching for orders by I<ordernumber>, include the aqorders_transfers table >+so we can find orders that have changed their ordernumber as the result of a transfer >+ >+=cut >+ >+sub filter_by_id_including_transfers { >+ my ( $self, $params ) = @_; >+ >+ Koha::Exceptions::MissingParameter->throw( "The ordernumber param is mandatory" ) >+ unless $params->{ordernumber}; >+ >+ return $self->search( >+ { >+ -or => [ >+ { 'me.ordernumber' => $params->{ordernumber} }, >+ { 'aqorders_transfers_ordernumber_to.ordernumber_from' => $params->{ordernumber} } >+ ] >+ }, >+ { join => 'aqorders_transfers_ordernumber_to' } >+ ); >+} >+ > =head2 Internal methods > >-=head3 _type (internal) >+=head3 _type > > =cut > >@@ -174,7 +222,7 @@ sub _type { > return 'Aqorder'; > } > >-=head3 object_class (internal) >+=head3 object_class > > =cut > >-- >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 25670
:
105534
|
105535
|
109859
|
109860
|
110643
|
110644
|
110700
|
110701
|
114940
|
114941
|
116141