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 134-157 sub cancel { Link Here
134
        error => "The 'reason' parameter is mandatory" )
133
        error => "The 'reason' parameter is mandatory" )
135
      unless defined($params->{reason});
134
      unless defined($params->{reason});
136
135
137
    my $in_transit = $self->in_transit;
138
139
    # Throw exception if item is in transit already
136
    # Throw exception if item is in transit already
140
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $in_transit );
137
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $self->in_transit );
141
138
142
    # Update the cancelled date
139
    # Update the cancelled date
143
    $self->set(
140
    $self->set(
144
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
141
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
145
      ->store;
142
      ->store;
146
143
147
    # Set up return transfer if transfer was force cancelled whilst in transit
148
    # NOTE: We don't catch here, as we're happy to fail if there are already
149
    # other transfers in the queue.
150
    try {
151
        $self->item->request_transfer(
152
            { to => $self->from_library, reason => 'TransferCancellation' } );
153
    };
154
155
    return $self;
144
    return $self;
156
}
145
}
157
146
158
- 

Return to bug 28520