Bugzilla – Attachment 77452 Details for
Bug 20366
More information about orders linked to subscriptions on "Acquisition details" tab
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20366: Add new method Koha::Acquisition::Order->subscription
Bug-20366-Add-new-method-KohaAcquisitionOrder-subs.patch (text/plain), 2.78 KB, created by
Katrin Fischer
on 2018-08-02 16:17:06 UTC
(
hide
)
Description:
Bug 20366: Add new method Koha::Acquisition::Order->subscription
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-08-02 16:17:06 UTC
Size:
2.78 KB
patch
obsolete
>From 2ece535ee708f5f409f455142f57f713e852859c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 8 May 2018 13:30:44 -0300 >Subject: [PATCH] Bug 20366: Add new method > Koha::Acquisition::Order->subscription > >Can be moved to a separate bug report. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Acquisition/Order.pm | 16 ++++++++++++++++ > t/db_dependent/Koha/Acquisition/Order.t | 31 ++++++++++++++++++++++++++++++- > 2 files changed, 46 insertions(+), 1 deletion(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index c35fcdf..5620cf6 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -22,6 +22,7 @@ use Carp qw( croak ); > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Funds; > use Koha::Acquisition::Invoices; >+use Koha::Subscriptions; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); > >@@ -151,6 +152,21 @@ sub invoice { > return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs ); > } > >+=head3 subscription >+ >+ my $subscription = $order->subscription >+ >+Returns the subscription associated to the order. >+ >+=cut >+ >+sub subscription { >+ my ( $self ) = @_; >+ my $subscription_rs = $self->_result->subscriptionid; >+ return unless $subscription_rs; >+ return Koha::Subscription->_new_from_dbic( $subscription_rs ); >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index c662e79..75d369a 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 => 4; >+use Test::More tests => 5; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -143,3 +143,32 @@ subtest 'invoice' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'subscription' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ my $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { subscriptionid => undef }, # not linked to a subscription >+ } >+ ); >+ >+ my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( $order->subscription, undef, >+ '->subscription should return undef if not created from a subscription'); >+ >+ $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ # Will be linked to a subscription by TestBuilder >+ } >+ ); >+ >+ $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( ref( $order->subscription ), 'Koha::Subscription', >+ '->subscription should return a Koha::Subscription object if created from a subscription'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.1.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 20366
:
75174
|
75175
|
75176
|
77438
|
77439
|
77440
|
77441
|
77452
|
77453
|
77454
|
77455
|
77508
|
77509
|
77510
|
77511
|
78070
|
78071
|
78072
|
78073