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 => |