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

(-)a/Koha/Item.pm (-8 / +9 lines)
Lines 402-413 sub holds { Link Here
402
=head3 request_transfer
402
=head3 request_transfer
403
403
404
  my $transfer = $item->request_transfer(
404
  my $transfer = $item->request_transfer(
405
      { to => $to_library, reason => $reason, force => 0 } );
405
      { to => $to_library, reason => $reason, ignore_limits => 0 } );
406
406
407
Add a transfer request for this item to the given branch for the given reason.
407
Add a transfer request for this item to the given branch for the given reason.
408
408
409
An exception will be thrown if the BranchTransferLimits would prevent the requested
409
An exception will be thrown if the BranchTransferLimits would prevent the requested
410
transfer, unless 'force' is passed to override the limits.
410
transfer, unless 'ignore_limits' is passed to override the limits.
411
411
412
Note: At this time, only one active transfer (i.e pending arrival date) may exist
412
Note: At this time, only one active transfer (i.e pending arrival date) may exist
413
at a time for any given item. An exception will be thrown should you attempt to
413
at a time for any given item. An exception will be thrown should you attempt to
Lines 431-440 sub request_transfer { Link Here
431
    my $request;
431
    my $request;
432
    Koha::Exceptions::Item::Transfer::Found->throw( transfer => $request )
432
    Koha::Exceptions::Item::Transfer::Found->throw( transfer => $request )
433
      if ( $request = $self->get_transfer );
433
      if ( $request = $self->get_transfer );
434
    # FIXME: Add override functionality to allow for queing transfers
435
434
436
    Koha::Exceptions::Item::Transfer::Limit->throw()
435
    Koha::Exceptions::Item::Transfer::Limit->throw()
437
      unless ( $params->{force} || $self->can_be_transferred( { to => $params->{to} } ) );
436
      unless ( $params->{ignore_limits}
437
        || $self->can_be_transferred( { to => $params->{to} } ) );
438
438
439
    my $transfer = Koha::Item::Transfer->new(
439
    my $transfer = Koha::Item::Transfer->new(
440
        {
440
        {
Lines 455-463 sub request_transfer { Link Here
455
455
456
Return the active transfer request or undef
456
Return the active transfer request or undef
457
457
458
Note: Transfers are retrieved in a LIFO (Last In First Out) order using this method.
458
Note: Transfers are retrieved in a Modified FIFO (First In First Out) order 
459
whereby the most recently sent, but not recieved, transfer will be returned
460
if it exists, otherwise the oldest unsatisfied transfer will be returned.
459
461
460
FIXME: Add Tests for LIFO functionality
462
FIXME: Add Tests for FIFO functionality
461
463
462
=cut
464
=cut
463
465
Lines 466-472 sub get_transfer { Link Here
466
    my $transfer_rs = $self->_result->branchtransfers->search(
468
    my $transfer_rs = $self->_result->branchtransfers->search(
467
        { datearrived => undef },
469
        { datearrived => undef },
468
        {
470
        {
469
            order_by => [ { -asc => 'datesent' }, { -asc => 'daterequested' } ],
471
            order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ],
470
            rows     => 1
472
            rows     => 1
471
        }
473
        }
472
    )->first;
474
    )->first;
473
- 

Return to bug 25755