Bugzilla – Attachment 75709 Details for
Bug 20726
Display acquisition details on the subscription detail page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20726: Add new method Acquisition::Order->invoice
Bug-20726-Add-new-method-AcquisitionOrder-invoice.patch (text/plain), 5.56 KB, created by
Séverine Queune
on 2018-05-31 16:02:02 UTC
(
hide
)
Description:
Bug 20726: Add new method Acquisition::Order->invoice
Filename:
MIME Type:
Creator:
Séverine Queune
Created:
2018-05-31 16:02:02 UTC
Size:
5.56 KB
patch
obsolete
>From 61062b25010a326d74ee0fef6fc70c879d4696a3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 7 May 2018 19:46:05 -0300 >Subject: [PATCH] Bug 20726: Add new method Acquisition::Order->invoice >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Can be moved to a separate bug report. > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > Koha/Acquisition/Invoice.pm | 40 ++++++++++++++++++++++++++ > Koha/Acquisition/Invoices.pm | 50 +++++++++++++++++++++++++++++++++ > Koha/Acquisition/Order.pm | 16 +++++++++++ > t/db_dependent/Koha/Acquisition/Order.t | 31 +++++++++++++++++++- > 4 files changed, 136 insertions(+), 1 deletion(-) > create mode 100644 Koha/Acquisition/Invoice.pm > create mode 100644 Koha/Acquisition/Invoices.pm > >diff --git a/Koha/Acquisition/Invoice.pm b/Koha/Acquisition/Invoice.pm >new file mode 100644 >index 0000000..6117322 >--- /dev/null >+++ b/Koha/Acquisition/Invoice.pm >@@ -0,0 +1,40 @@ >+package Koha::Acquisition::Invoice; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Acquisition::Invoice object class >+ >+=head1 API >+ >+=head2 Internal methods >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'Aqinvoice'; >+} >+ >+1; >diff --git a/Koha/Acquisition/Invoices.pm b/Koha/Acquisition/Invoices.pm >new file mode 100644 >index 0000000..134c309 >--- /dev/null >+++ b/Koha/Acquisition/Invoices.pm >@@ -0,0 +1,50 @@ >+package Koha::Acquisition::Invoices; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use Koha::Acquisition::Invoice; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Acquisition::Invoices object set class >+ >+=head1 API >+ >+=head2 Internal methods >+ >+=head3 _type (internal) >+ >+=cut >+ >+sub _type { >+ return 'Aqinvoice'; >+} >+ >+=head3 object_class (internal) >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Acquisition::Invoice'; >+} >+ >+1; >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 702e5b6..dee03ed 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -21,6 +21,7 @@ use Carp qw( croak ); > > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Funds; >+use Koha::Acquisition::Invoices; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); > >@@ -128,6 +129,21 @@ sub fund { > return Koha::Acquisition::Fund->_new_from_dbic( $fund_rs ); > } > >+=head3 invoice >+ >+ my $invoice = $order->invoice >+ >+Returns the invoice associated to the order. >+ >+=cut >+ >+sub invoice { >+ my ( $self ) = @_; >+ my $invoice_rs = $self->_result->invoiceid; >+ return unless $invoice_rs; >+ return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_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 f5a20a8..c662e79 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 => 3; >+use Test::More tests => 4; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -114,3 +114,32 @@ subtest 'fund' => sub { > '->fund should return a Koha::Acquisition::Fund object' ); > $schema->storage->txn_rollback; > }; >+ >+subtest 'invoice' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ my $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { cancellationreason => 'XXXXXXXX', invoiceid => undef }, # not received yet >+ } >+ ); >+ >+ my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( $order->invoice, undef, >+ '->invoice should return undef if no invoice defined yet'); >+ >+ my $invoice = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Invoices', >+ }, >+ ); >+ >+ $o->invoiceid( $invoice->invoiceid )->store; >+ $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( ref( $order->invoice ), 'Koha::Acquisition::Invoice', >+ '->invoice should return a Koha::Acquisition::Invoice object if an invoice is defined'); >+ >+ $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 20726
:
75146
|
75147
|
75148
|
75149
|
75150
|
75650
|
75651
|
75666
|
75708
|
75709
|
75710
|
75711
|
75712
|
75713
|
75794
|
77428
|
77429
|
77430
|
77431
|
77432
|
77433
|
77434
|
77500
|
77501
|
77502
|
77503
|
77504
|
77505
|
77506
|
78062
|
78063
|
78064
|
78065
|
78066
|
78067
|
78068