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

(-)a/Koha/Item.pm (-4 / +17 lines)
Lines 452-464 sub request_transfer { Link Here
452
      unless ( $params->{ignore_limits}
452
      unless ( $params->{ignore_limits}
453
        || $self->can_be_transferred( { to => $params->{to} } ) );
453
        || $self->can_be_transferred( { to => $params->{to} } ) );
454
454
455
    my $request = $self->get_transfer;
455
    # check for active, uncancelled transfers
456
    my $requests = $self->get_transfers;
457
    my $request  = $requests->next;
458
    while ( $request && $request->is_cancelled ) {
459
        $request = $requests->next;
460
    }
456
    Koha::Exceptions::Item::Transfer::InQueue->throw( transfer => $request )
461
    Koha::Exceptions::Item::Transfer::InQueue->throw( transfer => $request )
457
      if ( $request && !$params->{enqueue} && !$params->{replace} );
462
      if ( $request && !$params->{enqueue} && !$params->{replace} );
458
463
464
    # cancel next transfer in the queue if we're replacing it
459
    $request->cancel( { reason => $params->{reason}, force => 1 } )
465
    $request->cancel( { reason => $params->{reason}, force => 1 } )
460
      if ( defined($request) && $params->{replace} );
466
      if ( $request && $params->{replace} );
461
467
468
    # add transfer to the queue
462
    my $transfer = Koha::Item::Transfer->new(
469
    my $transfer = Koha::Item::Transfer->new(
463
        {
470
        {
464
            itemnumber    => $self->itemnumber,
471
            itemnumber    => $self->itemnumber,
Lines 493-500 sub get_transfer { Link Here
493
    my ($self) = @_;
500
    my ($self) = @_;
494
    my $transfer_rs = $self->_result->branchtransfers->search(
501
    my $transfer_rs = $self->_result->branchtransfers->search(
495
        {
502
        {
496
            datearrived   => undef,
503
            datearrived => undef,
497
            datecancelled => undef
504
            [
505
                { datesent => undef, datecancelled => { '!=' => undef } },
506
                {
507
                    datesent      => { '!=' => undef },
508
                    datecancelled => { '!=' => undef }
509
                }
510
            ]
498
        },
511
        },
499
        {
512
        {
500
            order_by =>
513
            order_by =>
(-)a/Koha/Item/Transfer.pm (-1 / +12 lines)
Lines 126-131 sub in_transit { Link Here
126
          && !defined( $self->datearrived ) );
126
          && !defined( $self->datearrived ) );
127
}
127
}
128
128
129
=head3 is_cancelled
130
131
Boolean returning whether the transfer was cancelled or not
132
133
=cut
134
135
sub is_cancelled {
136
    my ($self) = @_;
137
138
    return defined($self->datecancelled);
139
}
140
129
=head3 receive
141
=head3 receive
130
142
131
Receive the transfer by setting the datearrived time.
143
Receive the transfer by setting the datearrived time.
132
- 

Return to bug 28527