View | Details | Raw Unified | Return to bug 36068
Collapse All | Expand All

(-)a/Koha/Acquisition/Order.pm (-4 / +4 lines)
Lines 203-214 sub cancel { Link Here
203
        }
203
        }
204
    }
204
    }
205
205
206
    # Update order status
206
    # Update order status; do not overwrite older cancellation date
207
    $self->datecancellationprinted(dt_from_string) unless $self->datecancellationprinted;
207
    $self->set(
208
    $self->set(
208
        {
209
        {
209
            cancellationreason      => $reason,
210
            cancellationreason => $reason,
210
            datecancellationprinted => \'NOW()',
211
            orderstatus        => 'cancelled',
211
            orderstatus             => 'cancelled',
212
        }
212
        }
213
    )->store;
213
    )->store;
214
214
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-2 / +9 lines)
Lines 659-665 subtest 'creator ()' => sub { Link Here
659
659
660
subtest 'cancel() tests' => sub {
660
subtest 'cancel() tests' => sub {
661
661
662
    plan tests => 56;
662
    plan tests => 58;
663
663
664
    $schema->storage->txn_begin;
664
    $schema->storage->txn_begin;
665
665
Lines 1017-1021 subtest 'cancel() tests' => sub { Link Here
1017
    lives_ok { $order->set($columns)->store; } 'No croak on missing biblionumber when cancelling an order';
1017
    lives_ok { $order->set($columns)->store; } 'No croak on missing biblionumber when cancelling an order';
1018
    throws_ok { $order->orderstatus('new')->store; } qr/Cannot insert order: Mandatory parameter biblionumber is missing/, 'Expected croak';
1018
    throws_ok { $order->orderstatus('new')->store; } qr/Cannot insert order: Mandatory parameter biblionumber is missing/, 'Expected croak';
1019
1019
1020
    # Try to cancel again, not overwriting cancellation date
1021
    my $dt = dt_from_string->subtract( days => 1 );
1022
    $order->biblionumber($biblio_id)->datecancellationprinted($dt)->orderstatus('new')->store;
1023
    $order->cancel;
1024
    $order->discard_changes;
1025
    is( $order->orderstatus,             'cancelled', 'Check status after second cancel' );
1026
    is( $order->datecancellationprinted, $dt->ymd,    'Check date after second cancel' );
1027
1020
    $schema->storage->txn_rollback;
1028
    $schema->storage->txn_rollback;
1021
};
1029
};
1022
- 

Return to bug 36068