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

(-)a/Koha/Item/Transfer.pm (-13 / +1 lines)
Lines 18-24 package Koha::Item::Transfer; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Carp;
20
use Carp;
21
use Try::Tiny;
22
21
23
use C4::Items;
22
use C4::Items;
24
23
Lines 162-185 sub cancel { Link Here
162
        error => "The 'reason' parameter is mandatory" )
161
        error => "The 'reason' parameter is mandatory" )
163
      unless defined($params->{reason});
162
      unless defined($params->{reason});
164
163
165
    my $in_transit = $self->in_transit;
166
167
    # Throw exception if item is in transit already
164
    # Throw exception if item is in transit already
168
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $in_transit );
165
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $self->in_transit );
169
166
170
    # Update the cancelled date
167
    # Update the cancelled date
171
    $self->set(
168
    $self->set(
172
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
169
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
173
      ->store;
170
      ->store;
174
171
175
    # Set up return transfer if transfer was force cancelled whilst in transit
176
    # NOTE: We don't catch here, as we're happy to fail if there are already
177
    # other transfers in the queue.
178
    try {
179
        $self->item->request_transfer(
180
            { to => $self->from_library, reason => 'TransferCancellation' } );
181
    };
182
183
    return $self;
172
    return $self;
184
}
173
}
185
174
186
- 

Return to bug 28520