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

(-)a/t/db_dependent/Circulation.t (-21 / +15 lines)
Lines 2401-2448 subtest 'Cancel transfers on lost items' => sub { Link Here
2401
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2401
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2402
    my $library_2 = $builder->build( { source => 'Branch' } );
2402
    my $library_2 = $builder->build( { source => 'Branch' } );
2403
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2403
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2404
    my $biblio = $builder->build( { source => 'Biblio' } );
2404
    my $biblio = $builder->build_sample_biblio({branchcode => $library->{branchcode}});
2405
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
2405
    my $item   = $builder->build_sample_item(
2406
    my $item = $builder->build(
2407
        {
2406
        {
2408
            source => 'Item',
2407
            class => 'Koha::Items',
2409
            value => {
2408
            value => {
2410
                homebranch => $library_1->{branchcode},
2409
                biblionumber => $biblio->biblionumber,
2411
                holdingbranch => $library_1->{branchcode},
2410
                library      => $library_1->{branchcode},
2412
                notforloan => 0,
2413
                itemlost => 0,
2414
                withdrawn => 0,
2415
                biblionumber => $biblioitem->{biblionumber},
2416
            }
2411
            }
2417
        }
2412
        }
2418
    );
2413
    );
2419
2414
2420
    set_userenv( $library_2 );
2415
    set_userenv( $library_2 );
2421
    my $reserve_id = AddReserve(
2416
    my $reserve_id = AddReserve(
2422
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, '', 1, undef, undef, '', undef, $item->{itemnumber},
2417
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $item->biblionumber, '', 1, undef, undef, '', undef, $item->itemnumber,
2423
    );
2418
    );
2424
2419
2425
    #Return book and add transfer
2420
    #Return book and add transfer
2426
    set_userenv( $library_1 );
2421
    set_userenv( $library_1 );
2427
    my $do_transfer = 1;
2422
    my $do_transfer = 1;
2428
    my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} );
2423
    my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} );
2429
    ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id );
2424
    ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );
2430
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} );
2425
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode );
2431
    my $hold = Koha::Holds->find( $reserve_id );
2426
    my $hold = Koha::Holds->find( $reserve_id );
2432
    is( $hold->found, 'T', 'Hold is in transit' );
2427
    is( $hold->found, 'T', 'Hold is in transit' );
2433
2428
2434
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
2429
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
2435
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2430
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
2436
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
2431
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
2437
    my $itemcheck = Koha::Items->find($item->{itemnumber});
2432
    my $itemcheck = Koha::Items->find($item->itemnumber);
2438
    is( $itemcheck->holdingbranch, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' );
2433
    is( $itemcheck->holdingbranch, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' );
2439
2434
2440
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2435
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2441
    ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} );
2436
    ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber );
2442
    LostItem( $item->{itemnumber}, 'test', 1 );
2437
    LostItem( $item->itemnumber, 'test', 1 );
2443
    ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2438
    ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber);
2444
    is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled');
2439
    is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled');
2445
    $itemcheck = Koha::Items->find($item->{itemnumber});
2440
    $itemcheck = Koha::Items->find($item->itemnumber);
2446
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' );
2441
    is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' );
2447
};
2442
};
2448
2443
2449
- 

Return to bug 21985