@@ -, +, @@ --- Koha/Acquisition/Orders.pm | 1 + t/db_dependent/Koha/Acquisition/Orders.t | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/Koha/Acquisition/Orders.pm +++ a/Koha/Acquisition/Orders.pm @@ -287,6 +287,7 @@ sub cancel { my $count = 0; my @messages; while ( my $order = $self->next ) { + next if $order->orderstatus =~ /complete|cancelled/; _correct_quantity($order); # historical ballast $order->cancel( { delete_biblio => $delete_biblio } ); if ( @{ $order->object_messages } ) { --- a/t/db_dependent/Koha/Acquisition/Orders.t +++ a/t/db_dependent/Koha/Acquisition/Orders.t @@ -196,11 +196,11 @@ subtest 'filter_by_obsolete and cancel' => sub { $rs = Koha::Acquisition::Orders->filter_by_obsolete->search($limit); is( $rs->count, 3, 'Three obsolete' ); my @results = $rs->cancel; - is( $results[0], 3, 'All should be cancelled' ); + is( $results[0], 2, 'Two should be cancelled, one was cancelled already' ); is( @{ $results[1] }, 0, 'No messages' ); is( $order_1->discard_changes->orderstatus, 'cancelled', 'Check orderstatus of order_1' ); isnt( $order_2->discard_changes->datecancellationprinted, undef, 'Cancellation date of order_2 filled' ); - isnt( $order_3->discard_changes->datecancellationprinted, undef, 'Cancellation date of order_3 filled' ); + is( $order_3->discard_changes->datecancellationprinted, undef, 'order_3 was skipped, so date not touched' ); $schema->storage->txn_rollback; }; --