| 
      
            Lines 17-23
          
      
      
        Link Here
      
     | 
  
        
          | 17 | 
           | 
          17 | 
           | 
        
        
          | 18 | 
          use Modern::Perl;  | 
          18 | 
          use Modern::Perl;  | 
        
        
          | 19 | 
           | 
          19 | 
           | 
        
          
            
              | 20 | 
              use Test::More tests => 122;  | 
              20 | 
              use Test::More tests => 123;  | 
            
        
          | 21 | 
           | 
          21 | 
           | 
        
        
          | 22 | 
          use Data::Dumper;  | 
          22 | 
          use Data::Dumper;  | 
        
        
          | 23 | 
          use DateTime;  | 
          23 | 
          use DateTime;  | 
        
  
    | 
      
            Lines 2429-2434
          subtest 'Set waiting flag' => sub {
      
      
        Link Here
      
     | 
  
        
          | 2429 | 
              is( $status, 'Waiting', 'Now the hold is waiting');  | 
          2429 | 
              is( $status, 'Waiting', 'Now the hold is waiting');  | 
        
        
          | 2430 | 
          };  | 
          2430 | 
          };  | 
        
        
          | 2431 | 
           | 
          2431 | 
           | 
        
            
               | 
               | 
              2432 | 
              subtest 'Cancel transfers on lost items' => sub { | 
            
            
              | 2433 | 
                  plan tests => 5;  | 
            
            
              | 2434 | 
                  my $library_1 = $builder->build( { source => 'Branch' } ); | 
            
            
              | 2435 | 
                  my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 
            
            
              | 2436 | 
                  my $library_2 = $builder->build( { source => 'Branch' } ); | 
            
            
              | 2437 | 
                  my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 
            
            
              | 2438 | 
                  my $biblio = $builder->build( { source => 'Biblio' } ); | 
            
            
              | 2439 | 
                  my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); | 
            
            
              | 2440 | 
                  my $item = $builder->build(  | 
            
            
              | 2441 | 
                      { | 
            
            
              | 2442 | 
                          source => 'Item',  | 
            
            
              | 2443 | 
                          value => { | 
            
            
              | 2444 | 
                              homebranch => $library_1->{branchcode}, | 
            
            
              | 2445 | 
                              holdingbranch => $library_1->{branchcode}, | 
            
            
              | 2446 | 
                              notforloan => 0,  | 
            
            
              | 2447 | 
                              itemlost => 0,  | 
            
            
              | 2448 | 
                              withdrawn => 0,  | 
            
            
              | 2449 | 
                              biblionumber => $biblioitem->{biblionumber}, | 
            
            
              | 2450 | 
                          }  | 
            
            
              | 2451 | 
                      }  | 
            
            
              | 2452 | 
                  );  | 
            
            
              | 2453 | 
               | 
            
            
              | 2454 | 
                  set_userenv( $library_2 );  | 
            
            
              | 2455 | 
                  my $reserve_id = AddReserve(  | 
            
            
              | 2456 | 
                      $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, '', 1, undef, undef, '', undef, $item->{itemnumber}, | 
            
            
              | 2457 | 
                  );  | 
            
            
              | 2458 | 
               | 
            
            
              | 2459 | 
                  #Return book and add transfer  | 
            
            
              | 2460 | 
                  set_userenv( $library_1 );  | 
            
            
              | 2461 | 
                  my $do_transfer = 1;  | 
            
            
              | 2462 | 
                  my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} ); | 
            
            
              | 2463 | 
                  ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); | 
            
            
              | 2464 | 
                  C4::Circulation::transferbook( $library_2->{branchcode}, $item->{barcode} ); | 
            
            
              | 2465 | 
                  my $hold = Koha::Holds->find( $reserve_id );  | 
            
            
              | 2466 | 
                  is( $hold->found, 'T', 'Hold is in transit' );  | 
            
            
              | 2467 | 
               | 
            
            
              | 2468 | 
                  #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost  | 
            
            
              | 2469 | 
                  my ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); | 
            
            
              | 2470 | 
                  is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); | 
            
            
              | 2471 | 
                  my $itemcheck = GetItem($item->{itemnumber}); | 
            
            
              | 2472 | 
                  is( $itemcheck->{holdingbranch}, $library_2->{branchcode}, 'Items holding branch is the transfers destination branch before it is marked as lost' ); | 
            
            
              | 2473 | 
               | 
            
            
              | 2474 | 
                  #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch  | 
            
            
              | 2475 | 
                  ModItem( { itemlost => 1 }, $biblio->{biblionumber}, $item->{itemnumber} ); | 
            
            
              | 2476 | 
                  LostItem( $item->{itemnumber}, 'test', 1 ); | 
            
            
              | 2477 | 
                  ($datesent,$frombranch,$tobranch) = GetTransfers($item->{itemnumber}); | 
            
            
              | 2478 | 
                  is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled');  | 
            
            
              | 2479 | 
                  $itemcheck = GetItem($item->{itemnumber}); | 
            
            
              | 2480 | 
                  is( $itemcheck->{holdingbranch}, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); | 
            
            
              | 2481 | 
              };  | 
            
            
              | 2482 | 
               | 
            
        
          | 2432 | 
          subtest 'CanBookBeIssued | is_overdue' => sub { | 
          2483 | 
          subtest 'CanBookBeIssued | is_overdue' => sub { | 
        
        
          | 2433 | 
              plan tests => 3;  | 
          2484 | 
              plan tests => 3;  | 
        
        
          | 2434 | 
           | 
          2485 | 
           | 
        
            
              | 2435 | 
              -   | 
               | 
               |