| Lines 2969-2975
          subtest 'Set waiting flag' => sub {
      
      
        Link Here | 
        
          | 2969 | }; | 2969 | }; | 
        
          | 2970 |  | 2970 |  | 
        
          | 2971 | subtest 'Cancel transfers on lost items' => sub { | 2971 | subtest 'Cancel transfers on lost items' => sub { | 
          
            
              | 2972 |     plan tests => 5; | 2972 |     plan tests => 6; | 
        
          | 2973 |     my $library_1 = $builder->build( { source => 'Branch' } ); | 2973 |     my $library_1 = $builder->build( { source => 'Branch' } ); | 
        
          | 2974 |     my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 2974 |     my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 
        
          | 2975 |     my $library_2 = $builder->build( { source => 'Branch' } ); | 2975 |     my $library_2 = $builder->build( { source => 'Branch' } ); | 
  
    | Lines 2996-3010
          subtest 'Cancel transfers on lost items' => sub {
      
      
        Link Here | 
        
          | 2996 |     my $do_transfer = 1; | 2996 |     my $do_transfer = 1; | 
        
          | 2997 |     my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); | 2997 |     my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); | 
        
          | 2998 |     ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); | 2998 |     ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); | 
          
            
              | 2999 |     C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode ); | 2999 |     C4::Circulation::transferbook({ | 
            
              |  |  | 3000 |         from_branch => $library_1->{branchcode}, | 
            
              | 3001 |         to_branch => $library_2->{branchcode}, | 
            
              | 3002 |         barcode   => $item->barcode, | 
            
              | 3003 |     }); | 
        
          | 3000 |     my $hold = Koha::Holds->find( $reserve_id ); | 3004 |     my $hold = Koha::Holds->find( $reserve_id ); | 
        
          | 3001 |     is( $hold->found, 'T', 'Hold is in transit' ); | 3005 |     is( $hold->found, 'T', 'Hold is in transit' ); | 
        
          | 3002 |  | 3006 |  | 
        
          | 3003 |     #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost | 3007 |     #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost | 
        
          | 3004 |     my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); | 3008 |     my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); | 
          
            
              | 3005 |     is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); | 3009 |     is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library'); | 
            
              |  |  | 3010 |     is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library'); | 
        
          | 3006 |     my $itemcheck = Koha::Items->find($item->itemnumber); | 3011 |     my $itemcheck = Koha::Items->find($item->itemnumber); | 
          
            
              | 3007 |     is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origin branch before it is marked as lost' ); | 3012 |     is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' ); | 
        
          | 3008 |  | 3013 |  | 
        
          | 3009 |     #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch | 3014 |     #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch | 
        
          | 3010 |     $item->itemlost(1)->store; | 3015 |     $item->itemlost(1)->store; |