@@ -, +, @@ Koha::Acquisition::Order $ kshell k$ prove t/db_dependent/Koha/Acquisition/Order.t --- Koha/Acquisition/Order.pm | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) --- a/Koha/Acquisition/Order.pm +++ a/Koha/Acquisition/Order.pm @@ -25,6 +25,7 @@ use Koha::Acquisition::Invoices; use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Biblios; +use Koha::Holds; use Koha::Items; use Koha::Subscriptions; @@ -169,6 +170,44 @@ sub subscription { return Koha::Subscription->_new_from_dbic( $subscription_rs ); } +=head3 holds + + my $holds = $order->holds + +Returns the holds associated to the order. It returns a I +resultset in scalar context or a list of I objects in list context. + +=cut + +sub holds { + my ($self) = @_; + + my $items_rs = $self->_result->aqorders_items; + my @item_numbers = $items_rs->get_column( 'itemnumber' )->all; + + return Koha::Holds->search( + { + itemnumber => { + -in => \@item_numbers + } + } + ); +} + +=head3 holds_count + + my $count = $order->holds_count + +Returns the holds count associated to the order. + +=cut + +sub holds_count { + my ($self) = @_; + + return $self->holds->count; +} + =head3 items my $items = $order->items --