@@ -, +, @@ $ kshell k$ prove t/db_dependent/Koha/Acquisition/Basket.t --- Koha/Acquisition/Basket.pm | 17 +++++++++++++++++ Koha/Schema/Result/Aqbasket.pm | 7 +++++++ 2 files changed, 24 insertions(+) --- a/Koha/Acquisition/Basket.pm +++ a/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 for this basket, falling back to C if unset. --- a/Koha/Schema/Result/Aqbasket.pm +++ a/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'; } --