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

(-)a/C4/Reserves.pm (+5 lines)
Lines 303-308 sub CanBookBeReserved{ Link Here
303
         notReservable,   if holds on this item are not allowed
303
         notReservable,   if holds on this item are not allowed
304
         libraryNotFound  if given branchcode is not an existing library
304
         libraryNotFound  if given branchcode is not an existing library
305
         libraryNotPickupLocation if given branchcode is not configured to be a pickup location
305
         libraryNotPickupLocation if given branchcode is not configured to be a pickup location
306
         cannotBeTransferred if branch transfer limit applies on given item and branchcode
306
307
307
=cut
308
=cut
308
309
Lines 441-452 sub CanItemBeReserved { Link Here
441
        my $destination = Koha::Libraries->find({
442
        my $destination = Koha::Libraries->find({
442
            branchcode => $pickup_branchcode,
443
            branchcode => $pickup_branchcode,
443
        });
444
        });
445
444
        unless ($destination) {
446
        unless ($destination) {
445
            return 'libraryNotFound';
447
            return 'libraryNotFound';
446
        }
448
        }
447
        unless ($destination->pickup_location) {
449
        unless ($destination->pickup_location) {
448
            return 'libraryNotPickupLocation';
450
            return 'libraryNotPickupLocation';
449
        }
451
        }
452
        unless ($item->can_be_transferred({ to => $destination->branchcode })) {
453
            return 'cannotBeTransferred';
454
        }
450
    }
455
    }
451
456
452
    return 'OK';
457
    return 'OK';
(-)a/t/db_dependent/Holds.t (-4 / +11 lines)
Lines 19-24 use Koha::Database; Link Here
19
use Koha::DateUtils qw( dt_from_string output_pref );
19
use Koha::DateUtils qw( dt_from_string output_pref );
20
use Koha::Biblios;
20
use Koha::Biblios;
21
use Koha::Holds;
21
use Koha::Holds;
22
use Koha::Item::Transfer::Limits;
22
use Koha::Items;
23
use Koha::Items;
23
use Koha::Libraries;
24
use Koha::Libraries;
24
25
Lines 422-441 subtest 'Pickup location availability tests' => sub { Link Here
422
    my $item = Koha::Items->find($itemnumber);
423
    my $item = Koha::Items->find($itemnumber);
423
    my $branch_to = $builder->build({ source => 'Branch' })->{ branchcode };
424
    my $branch_to = $builder->build({ source => 'Branch' })->{ branchcode };
424
    my $library = Koha::Libraries->find($branch_to);
425
    my $library = Koha::Libraries->find($branch_to);
426
    $library->pickup_location('1')->store;
425
    my $patron = $builder->build({ source => 'Borrower' })->{ borrowernumber };
427
    my $patron = $builder->build({ source => 'Borrower' })->{ borrowernumber };
426
428
427
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1);
429
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1);
428
    t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype');
430
    t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype');
429
    $library->pickup_location('1')->store;
431
432
    my $limit = Koha::Item::Transfer::Limit->new({
433
        fromBranch => $item->holdingbranch,
434
        toBranch => $branch_to,
435
        itemtype => $item->effective_itemtype,
436
    })->store;
430
    is(CanItemBeReserved($patron, $item->itemnumber, $branch_to),
437
    is(CanItemBeReserved($patron, $item->itemnumber, $branch_to),
431
       'OK', 'Library is a pickup location');
438
       'cannotBeTransferred', 'Item cannot be transferred');
439
    $limit->delete;
432
    $library->pickup_location('0')->store;
440
    $library->pickup_location('0')->store;
433
    is(CanItemBeReserved($patron, $item->itemnumber, $branch_to),
441
    is(CanItemBeReserved($patron, $item->itemnumber, $branch_to),
434
       'libraryNotPickupLocation', 'Library is not a pickup location');
442
       'libraryNotPickupLocation', 'Library is not a pickup location');
435
    is(CanItemBeReserved($patron, $item->itemnumber, 'nonexistent'),
443
    is(CanItemBeReserved($patron, $item->itemnumber, 'nonexistent'),
436
       'libraryNotFound', 'Cannot set unknown library as pickup location');
444
       'libraryNotFound', 'Cannot set unknown library as pickup location');
437
};
445
};
438
446
my ( $bibnum, $title, $bibitemnum );
439
# Helper method to set up a Biblio.
447
# Helper method to set up a Biblio.
440
sub create_helper_biblio {
448
sub create_helper_biblio {
441
    my $itemtype = shift;
449
    my $itemtype = shift;
442
- 

Return to bug 7614