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