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

(-)a/Koha/ArticleRequest.pm (-1 / +4 lines)
Lines 122-128 Marks the article as cancelled. Send a notification if appropriate. Link Here
122
=cut
122
=cut
123
123
124
sub cancel {
124
sub cancel {
125
    my ( $self, $cancellation_reason, $notes ) = @_;
125
    my ( $self, $params ) = @_;
126
127
    my $cancellation_reason = $params->{cancellation_reason};
128
    my $notes = $params->{notes};
126
129
127
    $self->status(Koha::ArticleRequest::Status::Canceled);
130
    $self->status(Koha::ArticleRequest::Status::Canceled);
128
    $self->cancellation_reason($cancellation_reason) if $cancellation_reason;
131
    $self->cancellation_reason($cancellation_reason) if $cancellation_reason;
(-)a/Koha/REST/V1/ArticleRequests.pm (-4 / +14 lines)
Lines 52-62 sub cancel { Link Here
52
    }
52
    }
53
53
54
    my $reason = $c->validation->param('cancellation_reason');
54
    my $reason = $c->validation->param('cancellation_reason');
55
    my $notes = $c->validation->param('notes');
55
    my $notes  = $c->validation->param('notes');
56
56
57
    return try {
57
    return try {
58
58
59
        $article_request->cancel($reason, $notes);
59
        $article_request->cancel(
60
            {
61
                cancellation_reason => $reason,
62
                notes               => $notes
63
            }
64
        );
60
        return $c->render(
65
        return $c->render(
61
            status  => 204,
66
            status  => 204,
62
            openapi => q{}
67
            openapi => q{}
Lines 96-106 sub patron_cancel { Link Here
96
    }
101
    }
97
102
98
    my $reason = $c->validation->param('cancellation_reason');
103
    my $reason = $c->validation->param('cancellation_reason');
99
    my $notes = $c->validation->param('notes');
104
    my $notes  = $c->validation->param('notes');
100
105
101
    return try {
106
    return try {
102
107
103
        $article_request->cancel( $reason, $notes );
108
        $article_request->cancel(
109
            {
110
                cancellation_reason => $reason,
111
                notes               => $notes
112
            }
113
        );
104
        return $c->render(
114
        return $c->render(
105
            status  => 204,
115
            status  => 204,
106
            openapi => q{}
116
            openapi => q{}
(-)a/svc/article_request (-1 / +1 lines)
Lines 45-51 my $ar = Koha::ArticleRequests->find($id); Link Here
45
45
46
if ($ar) {
46
if ($ar) {
47
    if ( $action eq 'cancel' ) {
47
    if ( $action eq 'cancel' ) {
48
        $ar = $ar->cancel( $notes );
48
        $ar = $ar->cancel({ notes => $notes });
49
    }
49
    }
50
    elsif ( $action eq 'process' ) {
50
    elsif ( $action eq 'process' ) {
51
        $ar = $ar->process();
51
        $ar = $ar->process();
(-)a/t/db_dependent/Koha/ArticleRequest.t (-3 / +7 lines)
Lines 116-122 subtest 'complete() tests' => sub { Link Here
116
116
117
subtest 'cancel() tests' => sub {
117
subtest 'cancel() tests' => sub {
118
118
119
    plan tests => 2;
119
    plan tests => 4;
120
120
121
    $schema->storage->txn_begin;
121
    $schema->storage->txn_begin;
122
122
Lines 129-137 subtest 'cancel() tests' => sub { Link Here
129
        }
129
        }
130
    );
130
    );
131
131
132
    $ar->cancel()->discard_changes;
132
    my $reason = "Hey, ho";
133
    my $notes  = "Let's go!";
134
135
    $ar->cancel({ cancellation_reason => $reason, notes => $notes })->discard_changes;
133
136
134
    is( $ar->status, Koha::ArticleRequest::Status::Canceled );
137
    is( $ar->status, Koha::ArticleRequest::Status::Canceled );
138
    is( $ar->cancellation_reason, $reason, 'Cancellation reason stored correctly' );
139
    is( $ar->notes, $notes, 'Notes stored correctly' );
135
140
136
    $schema->storage->txn_rollback;
141
    $schema->storage->txn_rollback;
137
};
142
};
138
- 

Return to bug 27947