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

(-)a/C4/Circulation.pm (+6 lines)
Lines 3701-3706 sub LostItem{ Link Here
3701
3701
3702
        MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$patron->privacy) if $mark_returned;
3702
        MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$patron->privacy) if $mark_returned;
3703
    }
3703
    }
3704
3705
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3706
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3707
        ModItem({holdingbranch => $frombranch}, undef, $itemnumber);
3708
    }
3709
    my $transferdeleted = DeleteTransfer($itemnumber);
3704
}
3710
}
3705
3711
3706
sub GetOfflineOperations {
3712
sub GetOfflineOperations {
(-)a/t/db_dependent/Circulation.t (-2 / +52 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 119;
20
use Test::More tests => 120;
21
21
22
use Data::Dumper;
22
use Data::Dumper;
23
use DateTime;
23
use DateTime;
Lines 2406-2411 subtest 'Set waiting flag' => sub { Link Here
2406
    is( $status, 'Waiting', 'Now the hold is waiting');
2406
    is( $status, 'Waiting', 'Now the hold is waiting');
2407
};
2407
};
2408
2408
2409
subtest 'Cancel transfers on lost items' => sub {
2410
    plan tests => 5;
2411
    my $library_1 = $builder->build( { source => 'Branch' } );
2412
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2413
    my $library_2 = $builder->build( { source => 'Branch' } );
2414
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2415
    my $biblio = $builder->build( { source => 'Biblio' } );
2416
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
2417
    my $item = $builder->build(
2418
        {
2419
            source => 'Item',
2420
            value => {
2421
                homebranch => $library_1->{branchcode},
2422
                holdingbranch => $library_1->{branchcode},
2423
                notforloan => 0,
2424
                itemlost => 0,
2425
                withdrawn => 0,
2426
                biblionumber => $biblioitem->{biblionumber},
2427
            }
2428
        }
2429
    );
2430
2431
    set_userenv( $library_2 );
2432
    my $reserve_id = AddReserve(
2433
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, '', 1, undef, undef, '', undef, $item->{itemnumber},
2434
    );
2435
2436
    #Return book and add transfer
2437
    set_userenv( $library_1 );
2438
    my $do_transfer = 1;
2439
    my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} );
2440
    ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id );
2441
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} );
2442
    my $hold = Koha::Holds->find( $reserve_id );
2443
    is( $hold->found, 'T', 'Hold is in transit' );
2444
2445
    #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost
2446
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2447
    is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table');
2448
    my $itemcheck = GetItem($item->{itemnumber});
2449
    is( $itemcheck->{holdingbranch}, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' );
2450
2451
    #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2452
    ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} );
2453
    LostItem( $item->{itemnumber}, 'test', 1 );
2454
    ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2455
    is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled');
2456
    $itemcheck = GetItem($item->{itemnumber});
2457
    is( $itemcheck->{holdingbranch}, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' );
2458
};
2459
2409
subtest 'CanBookBeIssued | is_overdue' => sub {
2460
subtest 'CanBookBeIssued | is_overdue' => sub {
2410
    plan tests => 3;
2461
    plan tests => 3;
2411
2462
2412
- 

Return to bug 21754