Bugzilla – Attachment 110623 Details for
Bug 26524
Add Koha::Acquisition::Basket->orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26524: Add Koha::Acquisition::Basket->orders
Bug-26524-Add-KohaAcquisitionBasket-orders.patch (text/plain), 2.13 KB, created by
David Nind
on 2020-09-23 20:01:40 UTC
(
hide
)
Description:
Bug 26524: Add Koha::Acquisition::Basket->orders
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-09-23 20:01:40 UTC
Size:
2.13 KB
patch
obsolete
>From c237545f8fb9dbf4504a39f6d3fd937119548956 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 23 Sep 2020 15:56:41 -0300 >Subject: [PATCH] Bug 26524: Add Koha::Acquisition::Basket->orders > >This patch adds a handy accessor for a basket's orders. It can be used >to embed orders on an API call or be used in controller scripts to >replace C4::* methods. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Acquisition/Basket.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Acquisition/Basket.pm | 17 +++++++++++++++++ > Koha/Schema/Result/Aqbasket.pm | 7 +++++++ > 2 files changed, 24 insertions(+) > >diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm >index 1aad128a7e..4b89fd08f4 100644 >--- a/Koha/Acquisition/Basket.pm >+++ b/Koha/Acquisition/Basket.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Acquisition::BasketGroups; >+use Koha::Acquisition::Orders; > use Koha::Patrons; > > use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields ); >@@ -77,6 +78,22 @@ sub basket_group { > return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs ); > } > >+=head3 orders >+ >+ my $orders = $basket->orders; >+ >+Returns a Koha::Acquisition::Orders resultset, with the orders linked >+to this basket. >+ >+=cut >+ >+sub orders { >+ my ($self) = @_; >+ >+ my $orders_rs = $self->_result->orders; >+ return Koha::Acquisition::Orders->_new_from_dbic( $orders_rs ); >+} >+ > =head3 effective_create_items > > Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset. >diff --git a/Koha/Schema/Result/Aqbasket.pm b/Koha/Schema/Result/Aqbasket.pm >index e90d3c61e7..60d5633a58 100644 >--- a/Koha/Schema/Result/Aqbasket.pm >+++ b/Koha/Schema/Result/Aqbasket.pm >@@ -340,6 +340,13 @@ __PACKAGE__->belongs_to( > }, > ); > >+__PACKAGE__->has_many( >+ "orders", >+ "Koha::Schema::Result::Aqorder", >+ { "foreign.basketno" => "self.basketno" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > sub koha_object_class { > 'Koha::Acquisition::Basket'; > } >-- >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 26524
:
110616
|
110617
|
110622
|
110623
|
110797
|
110798
|
110914