Bugzilla – Attachment 109001 Details for
Bug 23166
Simplify code related to orders in catalogue/*detail.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23166: Add filter_by_current and _cancelled Koha::Acq::Orders methods
Bug-23166-Add-filterbycurrent-and-cancelled-KohaAc.patch (text/plain), 3.20 KB, created by
Joonas Kylmälä
on 2020-08-24 15:11:15 UTC
(
hide
)
Description:
Bug 23166: Add filter_by_current and _cancelled Koha::Acq::Orders methods
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2020-08-24 15:11:15 UTC
Size:
3.20 KB
patch
obsolete
>From c7dffec1b058cdbb2079e1db07766899d1a2d14b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 5 May 2020 15:50:17 +0200 >Subject: [PATCH] Bug 23166: Add filter_by_current and _cancelled > Koha::Acq::Orders methods >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Acquisition/Orders.pm | 35 +++++++++++++++++++++++ > t/db_dependent/Koha/Acquisition/Order.t | 50 ++++++++++++++++++++++++++++++++- > 2 files changed, 84 insertions(+), 1 deletion(-) > >diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm >index 2636b482a5..28b8fb80fe 100644 >--- a/Koha/Acquisition/Orders.pm >+++ b/Koha/Acquisition/Orders.pm >@@ -130,6 +130,41 @@ sub filter_by_lates { > ); > } > >+=head3 filter_by_current >+ >+ $orders->filter_by_current >+ >+Return the orders of the set that have not been cancelled. >+ >+=cut >+ >+sub filter_by_current { >+ my ($self) = @_; >+ return $self->search( >+ { >+ datecancellationprinted => [ undef, '0000-00-00' ] >+ } >+ ); >+} >+ >+=head3 filter_by_cancelled >+ >+ $orders->filter_by_cancelled >+ >+Return the orders of the set that have been cancelled. >+ >+=cut >+ >+sub filter_by_cancelled { >+ my ($self) = @_; >+ return $self->search( >+ { >+ datecancellationprinted => >+ [ { '!=' => [ -and => ( undef, '0000-00-00' ) ] } ] >+ } >+ ); >+} >+ > =head2 Internal methods > > =head3 _type (internal) >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index 3cbdc82b0e..2fa7310ae6 100644 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 11; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -536,3 +536,51 @@ subtest 'filter_by_late' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'filter_by_current & filter_by_cancelled' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ my $now = dt_from_string; >+ my $order_1 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ datecancellationprinted => undef, >+ } >+ } >+ ); >+ my $order_2 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ datecancellationprinted => undef, >+ } >+ } >+ ); >+ my $order_3 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ datecancellationprinted => dt_from_string, >+ } >+ } >+ ); >+ >+ my $orders = Koha::Acquisition::Orders->search( >+ { >+ ordernumber => { >+ -in => [ >+ $order_1->ordernumber, $order_2->ordernumber, >+ $order_3->ordernumber, >+ ] >+ } >+ } >+ ); >+ >+ is( $orders->filter_by_current->count, 2); >+ is( $orders->filter_by_cancelled->count, 1); >+ >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.11.0
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 23166
:
90824
|
90825
|
90826
|
90827
|
90828
|
104365
|
104366
|
104367
|
104368
|
104369
|
104370
|
108991
|
108992
|
108993
|
108994
|
108995
|
108996
|
108997
|
108998
|
108999
|
109000
|
109001
|
109002
|
109019
|
109020
|
109021
|
109022
|
109023
|
109024
|
109025
|
109026
|
109037
|
109038
|
109039
|
109040
|
109041
|
109042
|
109043
|
109044
|
109045
|
109046
|
109047
|
109048
|
109049
|
109050
|
109058
|
109059