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

(-)a/Koha/Acquisition/Order.pm (+13 lines)
Lines 21-26 use Carp qw( croak ); Link Here
21
21
22
use C4::Biblio qw( DelBiblio );
22
use C4::Biblio qw( DelBiblio );
23
use C4::Acquisition;
23
use C4::Acquisition;
24
use C4::Suggestions qw( ModSuggestion );
24
25
25
use Koha::Acquisition::Baskets;
26
use Koha::Acquisition::Baskets;
26
use Koha::Acquisition::Funds;
27
use Koha::Acquisition::Funds;
Lines 143-148 sub cancel { Link Here
143
        }
144
        }
144
    }
145
    }
145
146
147
    # If ordered from a suggestion, revert the suggestion status to ACCEPTED
148
    my $suggestion = Koha::Suggestions->find({ biblionumber => $self->biblionumber, status => "ORDERED" });
149
    if ( $suggestion and $suggestion->id ) {
150
        ModSuggestion(
151
            {
152
                suggestionid => $suggestion->id,
153
                biblionumber => $self->biblionumber,
154
                STATUS       => 'ACCEPTED',
155
            }
156
        );
157
    }
158
146
    my $biblio = $self->biblio;
159
    my $biblio = $self->biblio;
147
    if ( $biblio and $delete_biblio ) {
160
    if ( $biblio and $delete_biblio ) {
148
161
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-2 / +42 lines)
Lines 624-630 subtest 'filter_by_current & filter_by_cancelled' => sub { Link Here
624
624
625
subtest 'cancel() tests' => sub {
625
subtest 'cancel() tests' => sub {
626
626
627
    plan tests => 54;
627
    plan tests => 56;
628
628
629
    $schema->storage->txn_begin;
629
    $schema->storage->txn_begin;
630
630
Lines 860-865 subtest 'cancel() tests' => sub { Link Here
860
    @messages = @{ $order->object_messages };
860
    @messages = @{ $order->object_messages };
861
    is( scalar @messages, 0, 'No errors' );
861
    is( scalar @messages, 0, 'No errors' );
862
862
863
    # Scenario:
864
    # * order made from a suggestion with same biblionumber
865
    # => order is cancelled
866
    # => suggestion status is changed to ACCEPTED
867
868
    $item      = $builder->build_sample_item;
869
    $biblio_id = $item->biblionumber;
870
871
    # Add the suggestion
872
    my $suggestion = $builder->build_object(
873
        {
874
            class => 'Koha::Suggestions',
875
            value => {
876
                biblionumber => $biblio_id,
877
                suggesteddate => dt_from_string,
878
                STATUS => 'ORDERED',
879
                archived => 0,
880
            }
881
        }
882
    );
883
884
    $order = $builder->build_object(
885
        {
886
            class => 'Koha::Acquisition::Orders',
887
            value => {
888
                orderstatus             => 'new',
889
                biblionumber            => $biblio_id,
890
                datecancellationprinted => undef,
891
                cancellationreason      => undef,
892
            }
893
        }
894
    );
895
896
    $order->cancel({ reason => $reason })
897
          ->discard_changes;
898
899
    $suggestion = Koha::Suggestions->find( $suggestion->id );
900
901
    is( $order->orderstatus, 'cancelled', 'Order is marked as cancelled' );
902
    is( $suggestion->STATUS, 'ACCEPTED', 'Suggestion status is correctly reverted after order is cancelled' );
903
863
    # Scenario:
904
    # Scenario:
864
    # * order with two items attached
905
    # * order with two items attached
865
    # * one of the items is on loan
906
    # * one of the items is on loan
866
- 

Return to bug 33098