=head3 active_orders_count
-my $orders_count = $biblio->active_orders_count();
+my $active_orders = $biblio->active_orders();
-Returns the number of active acquisition orders related to this biblio.
+Returns the active acquisition orders related to this biblio.
An order is considered active when it is not cancelled (i.e. when datecancellation
is not undef).
=cut
-sub active_orders_count {
+sub active_orders {
my ( $self ) = @_;
- return $self->orders->search({ datecancellationprinted => undef })->count;
+ return $self->orders->search({ datecancellationprinted => undef });
}
=head3 can_article_request
return Koha::Items->_new_from_dbic( $items_rs );
}
-=head3 items_count
-
-my $items_count = $biblio->items();
-
-Returns the count of the the related Koha::Items object for this biblio
-
-=cut
-
-sub items_count {
- my ($self) = @_;
-
- return $self->_result->items->count;
-}
-
=head3 itemtype
my $itemtype = $biblio->itemtype();
return $self->{_subscriptions};
}
-=head3 subscriptions_count
-
-my $subscriptions_count = $self->subscriptions_count
-
-Returns the count of the the related Koha::Subscriptions object for this biblio
-
-IMPORTANT: this method is temporary and should not be used.
-
-=cut
-
-sub subscriptions_count {
- my ($self) = @_;
-
- return $self->subscriptions->count;
-}
-
=head3 has_items_waiting_or_intransit
my $itemsWaitingOrInTransit = $biblio->has_items_waiting_or_intransit
foreach my $myorder (@orders){
my $biblionumber = $myorder->{'biblionumber'};
my $biblio = Koha::Biblios->find( $biblionumber );
- my $countbiblio = $biblio->active_orders_count;
+ my $countbiblio = $biblio->active_orders->count;
my $ordernumber = $myorder->{'ordernumber'};
my $cnt_subscriptions = $biblio->subscriptions->count;
my $itemcount = $biblio->items->count;
my $biblionumber = $order->{'biblionumber'};
if ( $biblionumber ) { # The biblio still exists
my $biblio = Koha::Biblios->find( $biblionumber );
- my $countbiblio = $biblio->active_orders_count;
+ my $countbiblio = $biblio->active_orders->count;
my $ordernumber = $order->{'ordernumber'};
my $cnt_subscriptions = $biblio->subscriptions->count;
$schema->storage->txn_rollback;
};
-subtest 'items() and items_count() tests' => sub {
+subtest 'items() tests' => sub {
- plan tests => 5;
+ plan tests => 4;
$schema->storage->txn_begin;
my $biblio = $builder->build_sample_biblio();
- is( $biblio->items_count, 0, 'No items, count is 0' );
+ is( $biblio->items->count, 0, 'No items, count is 0' );
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
my $items = $biblio->items;
is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' );
is( $items->count, 2, 'Two items in resultset' );
- is( $biblio->items_count, $items->count, 'items_count returns the expected value' );
my @items = $biblio->items->as_list;
is( scalar @items, 2, 'Same result, but in list context' );
$schema->storage->txn_rollback;
};
-subtest 'orders() and active_orders_count() tests' => sub {
+subtest 'orders() and active_orders() tests' => sub {
- plan tests => 4;
+ plan tests => 5;
$schema->storage->txn_begin;
my $biblio = $builder->build_sample_biblio();
- my $orders = $biblio->orders;
- my $active_orders_count = $biblio->active_orders_count;
+ my $orders = $biblio->orders;
+ my $active_orders = $biblio->active_orders;
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
- is( $orders->count, $active_orders_count, '->orders_count returns the count for the resultset' );
+ is( $biblio->orders->count, $biblio->active_orders->count, '->orders_count returns the count for the resultset' );
# Add a couple orders
foreach (1..2) {
);
$orders = $biblio->orders;
- $active_orders_count = $biblio->active_orders_count;
+ $active_orders = $biblio->active_orders;
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
- is( $orders->count, $active_orders_count + 2, '->active_orders_count returns the rigt count' );
+ is( ref($active_orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
+ is( $orders->count, $active_orders->count + 2, '->active_orders_count returns the rigt count' );
$schema->storage->txn_rollback;
};
-subtest 'subscriptions() and subscriptions_count() tests' => sub {
+subtest 'subscriptions() tests' => sub {
- plan tests => 6;
+ plan tests => 4;
$schema->storage->txn_begin;
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
);
is( $subscriptions->count, 0, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
- is( $biblio->subscriptions_count, 0, 'subscriptions_count returns the correct number' );
# Add two subscriptions
foreach (1..2) {
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
);
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
- is( $biblio->subscriptions_count, 2, 'subscriptions_count returns the correct number' );
$schema->storage->txn_rollback;
};