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

(-)a/C4/RotatingCollections.pm (-1 / +1 lines)
Lines 457-463 sub TransferCollection { Link Here
457
            );    # Request transfer
457
            );    # Request transfer
458
        }
458
        }
459
        catch {
459
        catch {
460
            if ( $_->isa('Koha::Exceptions::Item::Transfer::Found') ) {
460
            if ( $_->isa('Koha::Exceptions::Item::Transfer::InQueue') ) {
461
                my $exception      = $_;
461
                my $exception      = $_;
462
                my $found_transfer = $_->transfer;
462
                my $found_transfer = $_->transfer;
463
                if (   $found_transfer->in_transit
463
                if (   $found_transfer->in_transit
(-)a/Koha/Exceptions/Item/Transfer.pm (-6 / +6 lines)
Lines 22-28 use Exception::Class ( Link Here
22
    'Koha::Exceptions::Item::Transfer' => {
22
    'Koha::Exceptions::Item::Transfer' => {
23
        description => 'Something went wrong'
23
        description => 'Something went wrong'
24
    },
24
    },
25
    'Koha::Exceptions::Item::Transfer::Found' => {
25
    'Koha::Exceptions::Item::Transfer::InQueue' => {
26
        isa         => 'Koha::Exceptions::Item::Transfer',
26
        isa         => 'Koha::Exceptions::Item::Transfer',
27
        description => "Active item transfer already exists",
27
        description => "Active item transfer already exists",
28
        fields      => ['transfer']
28
        fields      => ['transfer']
Lines 31-41 use Exception::Class ( Link Here
31
        isa         => 'Koha::Exceptions::Item::Transfer',
31
        isa         => 'Koha::Exceptions::Item::Transfer',
32
        description => "Transfer not allowed"
32
        description => "Transfer not allowed"
33
    },
33
    },
34
    'Koha::Exceptions::Item::Transfer::Out' => {
34
    'Koha::Exceptions::Item::Transfer::OnLoan' => {
35
        isa         => 'Koha::Exceptions::Item::Transfer',
35
        isa         => 'Koha::Exceptions::Item::Transfer',
36
        description => "Transfer item is currently checked out"
36
        description => "Transfer item is currently checked out"
37
    },
37
    },
38
    'Koha::Exceptions::Item::Transfer::Transit' => {
38
    'Koha::Exceptions::Item::Transfer::InTransit' => {
39
        isa         => 'Koha::Exceptions::Item::Transfer',
39
        isa         => 'Koha::Exceptions::Item::Transfer',
40
        description => "Transfer item is currently in transit"
40
        description => "Transfer item is currently in transit"
41
    }
41
    }
Lines 51-57 Koha::Exceptions::Item::Transfer - Base class for Transfer exceptions Link Here
51
51
52
Generic Item::Transfer exception
52
Generic Item::Transfer exception
53
53
54
=head2 Koha::Exceptions::Item::Transfer::Found
54
=head2 Koha::Exceptions::Item::Transfer::InQueue
55
55
56
Exception to be used when an active item transfer prevents a transfer action.
56
Exception to be used when an active item transfer prevents a transfer action.
57
57
Lines 59-69 Exception to be used when an active item transfer prevents a transfer action. Link Here
59
59
60
Exception to be used when transfer limits prevent a transfer action.
60
Exception to be used when transfer limits prevent a transfer action.
61
61
62
=head2 Koha::Exceptions::Item::Transfer::Out
62
=head2 Koha::Exceptions::Item::Transfer::OnLoan
63
63
64
Exception to be used when an active checkout prevents a transfer action.
64
Exception to be used when an active checkout prevents a transfer action.
65
65
66
=head2 Koha::Exceptions::Item::Transfer::Transit
66
=head2 Koha::Exceptions::Item::Transfer::InTransit
67
67
68
Exception to be used when an in transit transfer prevents a transfer action.
68
Exception to be used when an in transit transfer prevents a transfer action.
69
69
(-)a/Koha/Item.pm (-1 / +1 lines)
Lines 444-450 sub request_transfer { Link Here
444
        || $self->can_be_transferred( { to => $params->{to} } ) );
444
        || $self->can_be_transferred( { to => $params->{to} } ) );
445
445
446
    my $request = $self->get_transfer;
446
    my $request = $self->get_transfer;
447
    Koha::Exceptions::Item::Transfer::Found->throw( transfer => $request )
447
    Koha::Exceptions::Item::Transfer::InQueue->throw( transfer => $request )
448
      if ( $request && !$params->{enqueue} && !$params->{replace} );
448
      if ( $request && !$params->{enqueue} && !$params->{replace} );
449
449
450
    $request->cancel( { reason => $params->{reason}, force => 1 } )
450
    $request->cancel( { reason => $params->{reason}, force => 1 } )
(-)a/Koha/Item/Transfer.pm (-3 / +3 lines)
Lines 63-69 sub transit { Link Here
63
    my ($self) = @_;
63
    my ($self) = @_;
64
64
65
    # Throw exception if item is still checked out
65
    # Throw exception if item is still checked out
66
    Koha::Exceptions::Item::Transfer::Out->throw() if ( $self->item->checkout );
66
    Koha::Exceptions::Item::Transfer::OnLoan->throw() if ( $self->item->checkout );
67
67
68
    # Remove the 'shelving cart' location status if it is being used (Bug 3701)
68
    # Remove the 'shelving cart' location status if it is being used (Bug 3701)
69
    CartToShelf( $self->item->itemnumber )
69
    CartToShelf( $self->item->itemnumber )
Lines 107-113 sub receive { Link Here
107
    my ($self) = @_;
107
    my ($self) = @_;
108
108
109
    # Throw exception if item is checked out
109
    # Throw exception if item is checked out
110
    Koha::Exceptions::Item::Transfer::Out->throw() if ($self->item->checkout);
110
    Koha::Exceptions::Item::Transfer::OnLoan->throw() if ($self->item->checkout);
111
111
112
    # Update the arrived date
112
    # Update the arrived date
113
    $self->set({ datearrived => dt_from_string })->store;
113
    $self->set({ datearrived => dt_from_string })->store;
Lines 132-138 sub cancel { Link Here
132
      unless defined($params->{reason});
132
      unless defined($params->{reason});
133
133
134
    # Throw exception if item is in transit already
134
    # Throw exception if item is in transit already
135
    Koha::Exceptions::Item::Transfer::Transit->throw() if ( !$params->{force} && $self->in_transit );
135
    Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $self->in_transit );
136
136
137
    # Update the cancelled date
137
    # Update the cancelled date
138
    $self->set(
138
    $self->set(
(-)a/Koha/StockRotationItem.pm (-1 / +1 lines)
Lines 242-248 sub advance { Link Here
242
        );                                              # Add transfer
242
        );                                              # Add transfer
243
    }
243
    }
244
    catch {
244
    catch {
245
        if ( $_->isa('Koha::Exceptions::Item::Transfer::Found') ) {
245
        if ( $_->isa('Koha::Exceptions::Item::Transfer::InQueue') ) {
246
            my $exception = $_;
246
            my $exception = $_;
247
            my $found_transfer = $_->transfer;
247
            my $found_transfer = $_->transfer;
248
            if (   $found_transfer->in_transit
248
            if (   $found_transfer->in_transit
(-)a/t/db_dependent/Koha/Item.t (-1 / +1 lines)
Lines 483-489 subtest 'request_transfer' => sub { Link Here
483
483
484
    # Transfer already in progress
484
    # Transfer already in progress
485
    throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) }
485
    throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) }
486
    'Koha::Exceptions::Item::Transfer::Found',
486
    'Koha::Exceptions::Item::Transfer::InQueue',
487
      'Exception thrown if transfer is already in progress';
487
      'Exception thrown if transfer is already in progress';
488
488
489
    my $exception = $@;
489
    my $exception = $@;
(-)a/t/db_dependent/Koha/Item/Transfer.t (-4 / +3 lines)
Lines 92-98 subtest 'transit tests' => sub { Link Here
92
    is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' );
92
    is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' );
93
93
94
    throws_ok { $transfer->transit() }
94
    throws_ok { $transfer->transit() }
95
    'Koha::Exceptions::Item::Transfer::Out',
95
    'Koha::Exceptions::Item::Transfer::OnLoan',
96
      'Exception thrown if item is checked out';
96
      'Exception thrown if item is checked out';
97
97
98
    $checkout->delete;
98
    $checkout->delete;
Lines 155-161 subtest 'receive tests' => sub { Link Here
155
    is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' );
155
    is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' );
156
156
157
    throws_ok { $transfer->receive() }
157
    throws_ok { $transfer->receive() }
158
    'Koha::Exceptions::Item::Transfer::Out',
158
    'Koha::Exceptions::Item::Transfer::OnLoan',
159
      'Exception thrown if item is checked out';
159
      'Exception thrown if item is checked out';
160
160
161
    $checkout->delete;
161
    $checkout->delete;
Lines 246-252 subtest 'cancel tests' => sub { Link Here
246
246
247
    # Item in transit should result in failure
247
    # Item in transit should result in failure
248
    throws_ok { $transfer->cancel({ reason => $cancellation_reason }) }
248
    throws_ok { $transfer->cancel({ reason => $cancellation_reason }) }
249
    'Koha::Exceptions::Item::Transfer::Transit',
249
    'Koha::Exceptions::Item::Transfer::InTransit',
250
      'Exception thrown if item is in transit';
250
      'Exception thrown if item is in transit';
251
251
252
    $transfer->cancel({ reason => $cancellation_reason, force => 1});
252
    $transfer->cancel({ reason => $cancellation_reason, force => 1});
253
- 

Return to bug 26618