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

(-)a/Koha/Item.pm (+12 lines)
Lines 804-809 sub request_transfer { Link Here
804
        }
804
        }
805
    }
805
    }
806
806
807
    my $matching_transfers = Koha::Item::Transfers->search(
808
        {
809
            tobranch      => $params->{to}->branchcode,
810
            frombranch    => $self->holdingbranch,
811
            itemnumber    => $self->itemnumber,
812
            reason        => $params->{reason},
813
            datearrived   => undef,
814
            datecancelled => undef
815
        }
816
    );
817
    return $matching_transfers->next if $matching_transfers->count;
818
807
    Koha::Exceptions::Item::Transfer::Limit->throw()
819
    Koha::Exceptions::Item::Transfer::Limit->throw()
808
        unless ( $params->{ignore_limits}
820
        unless ( $params->{ignore_limits}
809
        || $self->can_be_transferred( { to => $params->{to} } ) );
821
        || $self->can_be_transferred( { to => $params->{to} } ) );
(-)a/t/db_dependent/Koha/Item.t (-2 / +12 lines)
Lines 1119-1125 subtest 'pickup_locations() tests' => sub { Link Here
1119
1119
1120
subtest 'request_transfer() tests' => sub {
1120
subtest 'request_transfer() tests' => sub {
1121
1121
1122
    plan tests => 18;
1122
    plan tests => 20;
1123
1123
1124
    $schema->storage->txn_begin;
1124
    $schema->storage->txn_begin;
1125
1125
Lines 1174-1179 subtest 'request_transfer() tests' => sub { Link Here
1174
1174
1175
    my $original_transfer = $transfer->get_from_storage;
1175
    my $original_transfer = $transfer->get_from_storage;
1176
1176
1177
    # Duplicated request
1178
    $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } );
1179
    is(
1180
        ref($transfer), 'Koha::Item::Transfer',
1181
        'Koha::Item->request_transfer should return a Koha::Item::Transfer object'
1182
    );
1183
    is(
1184
        $transfer->branchtransfer_id, $original_transfer->branchtransfer_id,
1185
        "When a matching transfer is requested we update the existing one"
1186
    );
1187
1177
    # Transfer already in progress
1188
    # Transfer already in progress
1178
    throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) }
1189
    throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) }
1179
    'Koha::Exceptions::Item::Transfer::InQueue',
1190
    'Koha::Exceptions::Item::Transfer::InQueue',
1180
- 

Return to bug 40331