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

(-)a/C4/Circulation.pm (-1 / +5 lines)
Lines 3702-3709 sub LostItem{ Link Here
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
3704
3705
    #If LostItemCancelOutstandingTransfers syspref is enabled then when item is marked lost delete its transfers and set items holdingbranch to the transfer source branch (frombranch)
3705
    if ( C4::Context->preference('LostItemCancelOutstandingTransfers') ) {
3706
    if ( C4::Context->preference('LostItemCancelOutstandingTransfers') ) {
3706
         DeleteTransfer($itemnumber);
3707
        if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3708
            ModItem({holdingbranch => $frombranch}, undef, $itemnumber);
3709
        }
3710
        my $transferdeleted = DeleteTransfer($itemnumber);
3707
    }
3711
    }
3708
3712
3709
}
3713
}
(-)a/t/db_dependent/Circulation.t (-2 / +63 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 2279-2284 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2279
            'The patron balance is the difference between the PF and the credit'
2279
            'The patron balance is the difference between the PF and the credit'
2280
        );
2280
        );
2281
    };
2281
    };
2282
2282
};
2283
};
2283
2284
2284
subtest '_FixOverduesOnReturn' => sub {
2285
subtest '_FixOverduesOnReturn' => sub {
Lines 2406-2411 subtest 'Set waiting flag' => sub { Link Here
2406
    is( $status, 'Waiting', 'Now the hold is waiting');
2407
    is( $status, 'Waiting', 'Now the hold is waiting');
2407
};
2408
};
2408
2409
2410
subtest 'Cancel transfers on lost items' => sub {
2411
    plan tests => 5;
2412
2413
    my $library_1 = $builder->build( { source => 'Branch' } );
2414
    my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2415
    my $library_2 = $builder->build( { source => 'Branch' } );
2416
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2417
    my $biblio = $builder->build( { source => 'Biblio' } );
2418
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
2419
    my $item = $builder->build(
2420
        {
2421
            source => 'Item',
2422
            value => {
2423
                homebranch => $library_1->{branchcode},
2424
                holdingbranch => $library_1->{branchcode},
2425
                notforloan => 0,
2426
                itemlost => 0,
2427
                withdrawn => 0,
2428
                biblionumber => $biblioitem->{biblionumber},
2429
            }
2430
        }
2431
    );
2432
2433
    set_userenv( $library_2 );
2434
    my $reserve_id = AddReserve(
2435
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
2436
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2437
    );
2438
2439
    #Return book and add transfer
2440
    set_userenv( $library_1 );
2441
    my $do_transfer = 1;
2442
    my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} );
2443
    ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id );
2444
    C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} );
2445
    my $hold = Koha::Holds->find( $reserve_id );
2446
    is( $hold->found, 'T', 'Hold is in transit' );
2447
2448
    #With the LostItemCancelOutstandingTransfers syspref disabled simulate item being marked as lost and confirm that the item transfer still exists and the items holding branch is the transfer destination branch
2449
    t::lib::Mocks::mock_preference('LostItemCancelOutstandingTransfers','0');
2450
    ModItem( { itemlost => 1 }, $biblioitem->{biblionumber}, $item->{itemnumber} );
2451
    LostItem( $item->{itemnumber}, 'test', 1 );
2452
    my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2453
    is( $tobranch, $library_2->{branchcode}, 'The transfer on the lost item still exists as LostItemCancelOutstandingTransfer is disabled');
2454
    my $itemcheck = GetItem($item->{itemnumber});
2455
    is( $itemcheck->{holdingbranch}, $library_2->{branchcode}, 'Lost item with cancelled hold has holding branch equalling the transfers destination branch' );
2456
2457
    #Reset itemlost field to 0
2458
    t::lib::Mocks::mock_preference('LostItemCancelOutstandingTransfers','1');
2459
    ModItem( { itemlost => 0 }, $biblio->{biblionumber}, $item->{itemnumber} );
2460
2461
    #With the LostItemCancelOutstandingTransfers syspref enabled simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch
2462
    ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} );
2463
    LostItem( $item->{itemnumber}, 'test', 1 );
2464
    ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber});
2465
    is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled');
2466
    $itemcheck = GetItem($item->{itemnumber});
2467
    is( $itemcheck->{holdingbranch}, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' );
2468
2469
};
2470
2409
subtest 'CanBookBeIssued | is_overdue' => sub {
2471
subtest 'CanBookBeIssued | is_overdue' => sub {
2410
    plan tests => 3;
2472
    plan tests => 3;
2411
2473
2412
- 

Return to bug 21732