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 148-171 sub cancel { Link Here
148
        error => "The 'reason' parameter is mandatory" )
147
        error => "The 'reason' parameter is mandatory" )
149
      unless defined($params->{reason});
148
      unless defined($params->{reason});
150
149
151
    my $in_transit = $self->in_transit;
152
153
    # Throw exception if item is in transit already
150
    # Throw exception if item is in transit already
154
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $in_transit );
151
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $self->in_transit );
155
152
156
    # Update the cancelled date
153
    # Update the cancelled date
157
    $self->set(
154
    $self->set(
158
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
155
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
159
      ->store;
156
      ->store;
160
157
161
    # Set up return transfer if transfer was force cancelled whilst in transit
162
    # NOTE: We don't catch here, as we're happy to fail if there are already
163
    # other transfers in the queue.
164
    try {
165
        $self->item->request_transfer(
166
            { to => $self->from_library, reason => 'TransferCancellation' } );
167
    };
168
169
    return $self;
158
    return $self;
170
}
159
}
171
160
172
- 

Return to bug 28520