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

(-)a/Koha/ArticleRequest.pm (-30 / +10 lines)
Lines 104-138 sub cancel { Link Here
104
    $self->notes($notes) if $notes;
104
    $self->notes($notes) if $notes;
105
    if ( $self->debit_line_id ) {
105
    if ( $self->debit_line_id ) {
106
        my $line = Koha::Account::Lines->find( $self->debit_line_id );
106
        my $line = Koha::Account::Lines->find( $self->debit_line_id );
107
        if ( $line->amount != $line->amountoutstanding ) {
107
        $line->cancel(
108
            $self->borrower->account->add_credit(
108
            {
109
                {
109
                  branch => C4::Context->userenv
110
                    amount  => $line->amount,
110
                ? C4::Context->userenv->{'branch'}
111
                    user_id => C4::Context->userenv
111
                : undef,
112
                    ? C4::Context->userenv->{'number'}
112
                staff_id => C4::Context->userenv
113
                    : undef,
113
                ? C4::Context->userenv->{'number'}
114
                    interface  => C4::Context->interface,
114
                : undef,
115
                    library_id => C4::Context->userenv
115
            }
116
                    ? C4::Context->userenv->{'branch'}
116
        );
117
                    : undef,
118
                    type        => 'CREDIT',
119
                    description => 'Article request cancelled',
120
                    item_id     => $self->itemnumber
121
                }
122
            );
123
        }
124
        else {
125
            $line->cancel(
126
                {
127
                    branch => C4::Context->userenv
128
                    ? C4::Context->userenv->{'branch'}
129
                    : undef,
130
                    staff_id => C4::Context->userenv
131
                    ? C4::Context->userenv->{'number'}
132
                    : undef,
133
                }
134
            ) unless $line->status && $line->status eq 'CANCELLED';
135
        }
136
    }
117
    }
137
118
138
    $self->store();
119
    $self->store();
139
- 

Return to bug 27946