Bug 22390: (bug 15184 follow-up) Use aqorders.subscriptionid instead of biblio.serial
It seems that we made a wrong assumption on bug 15184, see
commit d658cb6f7e
Bug 15184: Do copy items for not a serial OR if items are created on ordering
To know if an order has been created from a subscription we should check
$order->subscriptionid instead of the $biblio->serial flag
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
ea3cbef473
commit
ec78d0cddb
2 changed files with 73 additions and 2 deletions
|
@ -248,7 +248,7 @@ sub duplicate_to {
|
|||
|
||||
$new_order = Koha::Acquisition::Order->new($order_info)->store;
|
||||
|
||||
if ( not $self->biblio->serial || $self->basket->effective_create_items eq 'ordering') { # Do copy items if not a serial OR if items are created on ordering
|
||||
if ( ! $self->subscriptionid || $self->basket->effective_create_items eq 'ordering') { # Do copy items if not a serial OR if items are created on ordering
|
||||
my $items = $self->items;
|
||||
while ( my ($item) = $items->next ) {
|
||||
my $item_info = $item->unblessed;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 6;
|
||||
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
@ -172,3 +172,74 @@ subtest 'subscription' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'duplicate_to | add_item' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $item = $builder->build_sample_item;
|
||||
my $order_no_sub = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Acquisition::Orders',
|
||||
value =>
|
||||
{
|
||||
biblionumber => $item->biblionumber,
|
||||
subscriptionid => undef, # not linked to a subscription
|
||||
}
|
||||
}
|
||||
);
|
||||
$order_no_sub->basket->create_items(undef)->store; # use syspref
|
||||
$order_no_sub->add_item( $item->itemnumber );
|
||||
|
||||
$item = $builder->build_sample_item;
|
||||
my $order_from_sub = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Acquisition::Orders',
|
||||
value =>
|
||||
{
|
||||
biblionumber => $item->biblionumber,
|
||||
# Will be linked to a subscription by TestBuilder
|
||||
}
|
||||
}
|
||||
);
|
||||
$order_from_sub->basket->create_items(undef)->store; # use syspref
|
||||
$order_from_sub->add_item( $item->itemnumber );
|
||||
|
||||
my $basket_to = $builder->build_object(
|
||||
{ class => 'Koha::Acquisition::Baskets' });
|
||||
|
||||
subtest 'Create item on receiving' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
t::lib::Mocks::mock_preference('AcqCreateItem', 'receiving');
|
||||
|
||||
my $duplicated_order = $order_no_sub->duplicate_to($basket_to);
|
||||
is( $duplicated_order->items->count, 1,
|
||||
'Items should be copied if the original order is not created from a subscription'
|
||||
);
|
||||
|
||||
$duplicated_order = $order_from_sub->duplicate_to($basket_to);
|
||||
is( $duplicated_order->items->count, 0,
|
||||
'Items should not be copied if the original order is created from a subscription'
|
||||
);
|
||||
};
|
||||
|
||||
subtest 'Create item on ordering' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
t::lib::Mocks::mock_preference('AcqCreateItem', 'ordering');
|
||||
|
||||
my $duplicated_order = $order_no_sub->duplicate_to($basket_to);
|
||||
is( $duplicated_order->items->count, 1,
|
||||
'Items should be copied if items are created on ordering'
|
||||
);
|
||||
|
||||
$duplicated_order = $order_from_sub->duplicate_to($basket_to);
|
||||
is( $duplicated_order->items->count, 1,
|
||||
'Items should be copied if items are created on ordering, even if created from subscription'
|
||||
);
|
||||
};
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue