| 
      
            Lines 310-316
          subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
      
      
        Link Here
      
     | 
  
        
          | 310 | 
              );  | 
          310 | 
              );  | 
        
        
          | 311 | 
           | 
          311 | 
           | 
        
        
          | 312 | 
              # Patrons from three different branches  | 
          312 | 
              # Patrons from three different branches  | 
        
          
            
              | 313 | 
                  my $patron_borrower = $builder->build_object({ class => 'Koha::Patrons' }); | 
              313 | 
                  my $patron = $builder->build_object({ class => 'Koha::Patrons' }); | 
            
        
          | 314 | 
              my $patron_hold_1   = $builder->build_object({ class => 'Koha::Patrons' }); | 
          314 | 
              my $patron_hold_1   = $builder->build_object({ class => 'Koha::Patrons' }); | 
        
        
          | 315 | 
              my $patron_hold_2   = $builder->build_object({ class => 'Koha::Patrons' }); | 
          315 | 
              my $patron_hold_2   = $builder->build_object({ class => 'Koha::Patrons' }); | 
        
        
          | 316 | 
              my $biblio = $builder->build_sample_biblio();  | 
          316 | 
              my $biblio = $builder->build_sample_biblio();  | 
        
  
    | 
      
            Lines 318-324
          subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
      
      
        Link Here
      
     | 
  
        
          | 318 | 
              # Item at each patron branch  | 
          318 | 
              # Item at each patron branch  | 
        
        
          | 319 | 
              my $item_1 = $builder->build_sample_item({ | 
          319 | 
              my $item_1 = $builder->build_sample_item({ | 
        
        
          | 320 | 
                  biblionumber => $biblio->biblionumber,  | 
          320 | 
                  biblionumber => $biblio->biblionumber,  | 
        
          
            
              | 321 | 
                      homebranch   => $patron_borrower->branchcode  | 
              321 | 
                      homebranch   => $patron->branchcode  | 
            
        
          | 322 | 
              });  | 
          322 | 
              });  | 
        
        
          | 323 | 
              my $item_2 = $builder->build_sample_item({ | 
          323 | 
              my $item_2 = $builder->build_sample_item({ | 
        
        
          | 324 | 
                  biblionumber => $biblio->biblionumber,  | 
          324 | 
                  biblionumber => $biblio->biblionumber,  | 
        
  
    | 
      
            Lines 329-335
          subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
      
      
        Link Here
      
     | 
  
        
          | 329 | 
                  homebranch   => $patron_hold_1->branchcode  | 
          329 | 
                  homebranch   => $patron_hold_1->branchcode  | 
        
        
          | 330 | 
              });  | 
          330 | 
              });  | 
        
        
          | 331 | 
           | 
          331 | 
           | 
        
          
            
              | 332 | 
                  my $issue = AddIssue( $patron_borrower->unblessed, $item_1->barcode);  | 
              332 | 
                  my $issue = AddIssue( $patron->unblessed, $item_1->barcode);  | 
            
        
          | 333 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
          333 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
        
        
          | 334 | 
              is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() );  | 
          334 | 
              is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() );  | 
        
        
          | 335 | 
           | 
          335 | 
           | 
        
  
    | 
      
            Lines 360-376
          subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
      
      
        Link Here
      
     | 
  
        
          | 360 | 
              );  | 
          360 | 
              );  | 
        
        
          | 361 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); | 
          361 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); | 
        
        
          | 362 | 
           | 
          362 | 
           | 
        
          
            
              | 363 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber);  | 
              363 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed($patron, $issue);  | 
            
        
          | 364 | 
              is( $renewokay, 0, 'Cannot renew, reserved');  | 
          364 | 
              is( $renewokay, 0, 'Cannot renew, reserved');  | 
        
        
          | 365 | 
              is( $error, 'on_reserve', 'Cannot renew, reserved (returned error is on_reserve)');  | 
          365 | 
              is( $error, 'on_reserve', 'Cannot renew, reserved (returned error is on_reserve)');  | 
        
        
          | 366 | 
           | 
          366 | 
           | 
        
        
          | 367 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); | 
          367 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); | 
        
        
          | 368 | 
           | 
          368 | 
           | 
        
          
            
              | 369 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber);  | 
              369 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($patron, $issue);  | 
            
        
          | 370 | 
              is( $renewokay, 1, 'Can renew, two items available for two holds');  | 
          370 | 
              is( $renewokay, 1, 'Can renew, two items available for two holds');  | 
        
        
          | 371 | 
              is( $error, undef, 'Can renew, each reserve has an item');  | 
          371 | 
              is( $error, undef, 'Can renew, each reserve has an item');  | 
        
        
          | 372 | 
           | 
          372 | 
           | 
        
            
              | 373 | 
               | 
               | 
               | 
            
        
          | 374 | 
          };  | 
          373 | 
          };  | 
        
        
          | 375 | 
           | 
          374 | 
           | 
        
        
          | 376 | 
          subtest "GetIssuingCharges tests" => sub { | 
          375 | 
          subtest "GetIssuingCharges tests" => sub { | 
        
  
    | 
      
            Lines 463-468
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 463 | 
                  surname => 'Renewal',  | 
          462 | 
                  surname => 'Renewal',  | 
        
        
          | 464 | 
                  categorycode => $patron_category->{categorycode}, | 
          463 | 
                  categorycode => $patron_category->{categorycode}, | 
        
        
          | 465 | 
                  branchcode => $branch,  | 
          464 | 
                  branchcode => $branch,  | 
        
            
               | 
               | 
              465 | 
                      autorenew_checkouts => 1,  | 
            
        
          | 466 | 
              );  | 
          466 | 
              );  | 
        
        
          | 467 | 
           | 
          467 | 
           | 
        
        
          | 468 | 
              my %reserving_borrower_data = (  | 
          468 | 
              my %reserving_borrower_data = (  | 
        
  
    | 
      
            Lines 493-510
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 493 | 
                  categorycode => $patron_category->{categorycode}, | 
          493 | 
                  categorycode => $patron_category->{categorycode}, | 
        
        
          | 494 | 
                  branchcode => $branch,  | 
          494 | 
                  branchcode => $branch,  | 
        
        
          | 495 | 
                  dateexpiry => dt_from_string->subtract( months => 1 ),  | 
          495 | 
                  dateexpiry => dt_from_string->subtract( months => 1 ),  | 
        
            
               | 
               | 
              496 | 
                      autorenew_checkouts => 1,  | 
            
        
          | 496 | 
              );  | 
          497 | 
              );  | 
        
        
          | 497 | 
           | 
          498 | 
           | 
        
          
            
              | 498 | 
                  my $renewing_borrowernumber = Koha::Patron->new(\%renewing_borrower_data)->store->borrowernumber;  | 
              499 | 
                  my $renewing_borrower_obj = Koha::Patron->new(\%renewing_borrower_data)->store;  | 
            
            
               | 
               | 
              500 | 
                  my $renewing_borrowernumber = $renewing_borrower_obj->borrowernumber;  | 
            
        
          | 499 | 
              my $reserving_borrowernumber = Koha::Patron->new(\%reserving_borrower_data)->store->borrowernumber;  | 
          501 | 
              my $reserving_borrowernumber = Koha::Patron->new(\%reserving_borrower_data)->store->borrowernumber;  | 
        
        
          | 500 | 
              my $hold_waiting_borrowernumber = Koha::Patron->new(\%hold_waiting_borrower_data)->store->borrowernumber;  | 
          502 | 
              my $hold_waiting_borrowernumber = Koha::Patron->new(\%hold_waiting_borrower_data)->store->borrowernumber;  | 
        
          
            
              | 501 | 
                  my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber;  | 
              503 | 
                  my $restricted_borrower_obj = Koha::Patron->new(\%restricted_borrower_data)->store;  | 
            
            
              | 502 | 
                  my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber;  | 
               | 
               | 
            
        
          | 503 | 
           | 
          504 | 
           | 
        
          
            
              | 504 | 
                  my $renewing_borrower_obj = Koha::Patrons->find( $renewing_borrowernumber );  | 
              505 | 
                  my $expired_borrower_obj = Koha::Patron->new(\%expired_borrower_data)->store;  | 
            
            
              | 505 | 
                  my $renewing_borrower = $renewing_borrower_obj->unblessed;  | 
               | 
               | 
            
            
              | 506 | 
                  my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed;  | 
            
            
              | 507 | 
                  my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed;  | 
            
        
          | 508 | 
           | 
          506 | 
           | 
        
        
          | 509 | 
              my $bibitems       = '';  | 
          507 | 
              my $bibitems       = '';  | 
        
        
          | 510 | 
              my $priority       = '1';  | 
          508 | 
              my $priority       = '1';  | 
        
  
    | 
      
            Lines 514-532
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 514 | 
              my $checkitem      = undef;  | 
          512 | 
              my $checkitem      = undef;  | 
        
        
          | 515 | 
              my $found          = undef;  | 
          513 | 
              my $found          = undef;  | 
        
        
          | 516 | 
           | 
          514 | 
           | 
        
          
            
              | 517 | 
                  my $issue = AddIssue( $renewing_borrower, $item_1->barcode);  | 
              515 | 
                  my $issue_1 = AddIssue( $renewing_borrower_obj->unblessed, $item_1->barcode);  | 
            
            
              | 518 | 
                  my $datedue = dt_from_string( $issue->date_due() );  | 
              516 | 
                  my $datedue = dt_from_string( $issue_1->date_due() );  | 
            
            
              | 519 | 
                  is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() );  | 
              517 | 
                  is (defined $issue_1->date_due(), 1, "Item 1 checked out, due date: " . $issue_1->date_due() );  | 
            
            
              | 520 | 
               | 
               | 
               | 
            
            
              | 521 | 
                  my $issue2 = AddIssue( $renewing_borrower, $item_2->barcode);  | 
            
            
              | 522 | 
                  $datedue = dt_from_string( $issue->date_due() );  | 
            
            
              | 523 | 
                  is (defined $issue2, 1, "Item 2 checked out, due date: " . $issue2->date_due());  | 
            
        
          | 524 | 
           | 
          518 | 
           | 
        
            
               | 
               | 
              519 | 
                  my $issue_2 = AddIssue( $renewing_borrower_obj->unblessed, $item_2->barcode);  | 
            
            
              | 520 | 
                  is (defined $issue_2, 1, "Item 2 checked out, due date: " . $issue_2->date_due());  | 
            
        
          | 525 | 
           | 
          521 | 
           | 
        
        
          | 526 | 
              my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; | 
          522 | 
              my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; | 
        
          
            
              | 527 | 
                  is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); | 
              523 | 
                  is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to ".$renewing_borrower_obj->firstname." ".$renewing_borrower_obj->surname);  | 
            
        
          | 528 | 
           | 
          524 | 
           | 
        
          
            
              | 529 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);  | 
              525 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1, 1);  | 
            
        
          | 530 | 
              is( $renewokay, 1, 'Can renew, no holds for this title or item');  | 
          526 | 
              is( $renewokay, 1, 'Can renew, no holds for this title or item');  | 
        
        
          | 531 | 
           | 
          527 | 
           | 
        
        
          | 532 | 
           | 
          528 | 
           | 
        
  
    | 
      
            Lines 565-573
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 565 | 
                  }  | 
          561 | 
                  }  | 
        
        
          | 566 | 
              );  | 
          562 | 
              );  | 
        
        
          | 567 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); | 
          563 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); | 
        
          
            
              | 568 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              564 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 569 | 
              is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
          565 | 
              is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
        
          
            
              | 570 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber);  | 
              566 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_2);  | 
            
        
          | 571 | 
              is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
          567 | 
              is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
        
        
          | 572 | 
           | 
          568 | 
           | 
        
        
          | 573 | 
           | 
          569 | 
           | 
        
  
    | 
      
            Lines 585-591
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 585 | 
                      found            => $found,  | 
          581 | 
                      found            => $found,  | 
        
        
          | 586 | 
                  }  | 
          582 | 
                  }  | 
        
        
          | 587 | 
              );  | 
          583 | 
              );  | 
        
          
            
              | 588 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              584 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 589 | 
              is( $renewokay, 0, 'Renewal not possible when single patron\'s holds exceed the number of available items');  | 
          585 | 
              is( $renewokay, 0, 'Renewal not possible when single patron\'s holds exceed the number of available items');  | 
        
        
          | 590 | 
              Koha::Holds->find($reserve_id)->delete;  | 
          586 | 
              Koha::Holds->find($reserve_id)->delete;  | 
        
        
          | 591 | 
           | 
          587 | 
           | 
        
  
    | 
      
            Lines 600-606
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 600 | 
                      reservedate    => '1999-01-01',  | 
          596 | 
                      reservedate    => '1999-01-01',  | 
        
        
          | 601 | 
                  }  | 
          597 | 
                  }  | 
        
        
          | 602 | 
              );  | 
          598 | 
              );  | 
        
          
            
              | 603 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              599 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 604 | 
              is( $renewokay, 0, 'Bug 13919 - Renewal possible with item level hold on item');  | 
          600 | 
              is( $renewokay, 0, 'Bug 13919 - Renewal possible with item level hold on item');  | 
        
        
          | 605 | 
              $hold->delete();  | 
          601 | 
              $hold->delete();  | 
        
        
          | 606 | 
           | 
          602 | 
           | 
        
  
    | 
      
            Lines 616-632
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 616 | 
                      found          => 'W'  | 
          612 | 
                      found          => 'W'  | 
        
        
          | 617 | 
                  }  | 
          613 | 
                  }  | 
        
        
          | 618 | 
              );  | 
          614 | 
              );  | 
        
          
            
              | 619 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              615 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 620 | 
              is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
          616 | 
              is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
        
          
            
              | 621 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber);  | 
              617 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_2);  | 
            
        
          | 622 | 
              is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
          618 | 
              is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');  | 
        
        
          | 623 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); | 
          619 | 
              t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); | 
        
        
          | 624 | 
           | 
          620 | 
           | 
        
          
            
              | 625 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              621 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 626 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');  | 
          622 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');  | 
        
        
          | 627 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');  | 
          623 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');  | 
        
        
          | 628 | 
           | 
          624 | 
           | 
        
          
            
              | 629 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber);  | 
              625 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_2);  | 
            
        
          | 630 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');  | 
          626 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');  | 
        
        
          | 631 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');  | 
          627 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');  | 
        
        
          | 632 | 
           | 
          628 | 
           | 
        
  
    | 
      
            Lines 655-670
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 655 | 
                  }  | 
          651 | 
                  }  | 
        
        
          | 656 | 
              );  | 
          652 | 
              );  | 
        
        
          | 657 | 
           | 
          653 | 
           | 
        
          
            
              | 658 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);  | 
              654 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1, 1);  | 
            
        
          | 659 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved');  | 
          655 | 
              is( $renewokay, 0, '(Bug 10663) Cannot renew, item reserved');  | 
        
        
          | 660 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)');  | 
          656 | 
              is( $error, 'on_reserve', '(Bug 10663) Cannot renew, item reserved (returned error is on_reserve)');  | 
        
        
          | 661 | 
           | 
          657 | 
           | 
        
          
            
              | 662 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber, 1);  | 
              658 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_2, 1);  | 
            
        
          | 663 | 
              is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');  | 
          659 | 
              is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');  | 
        
        
          | 664 | 
           | 
          660 | 
           | 
        
        
          | 665 | 
              # Items can't fill hold for reasons  | 
          661 | 
              # Items can't fill hold for reasons  | 
        
          
            
              | 666 | 
                  $item_1->notforloan(1)->store;  | 
              662 | 
                  $issue_1->item->notforloan(1)->store;  | 
            
            
              | 667 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);  | 
              663 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1, 1);  | 
            
        
          | 668 | 
              is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');  | 
          664 | 
              is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');  | 
        
        
          | 669 | 
              $item_1->set({notforloan => 0, itype => $itemtype })->store; | 
          665 | 
              $item_1->set({notforloan => 0, itype => $itemtype })->store; | 
        
        
          | 670 | 
           | 
          666 | 
           | 
        
  
    | 
      
            Lines 679-691
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 679 | 
                      itype            => $itemtype,  | 
          675 | 
                      itype            => $itemtype,  | 
        
        
          | 680 | 
                  }  | 
          676 | 
                  }  | 
        
        
          | 681 | 
              );  | 
          677 | 
              );  | 
        
          
            
              | 682 | 
                  my $datedue5 = AddIssue($restricted_borrower, $item_5->barcode);  | 
              678 | 
                  my $issue_5 = AddIssue($restricted_borrower_obj->unblessed, $item_5->barcode);  | 
            
            
              | 683 | 
                  is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5");  | 
              679 | 
                  is (defined $issue_5, 1, "Item with date due checked out, due date: ". $issue_5->date_due);  | 
            
        
          | 684 | 
           | 
          680 | 
           | 
        
        
          | 685 | 
              t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); | 
          681 | 
              t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); | 
        
          
            
              | 686 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber);  | 
              682 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_2);  | 
            
        
          | 687 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');  | 
          683 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');  | 
        
          
            
              | 688 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $item_5->itemnumber);  | 
              684 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrower_obj, $issue_5);  | 
            
        
          | 689 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted');  | 
          685 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted');  | 
        
        
          | 690 | 
              is( $error, 'restriction', "Correct error returned");  | 
          686 | 
              is( $error, 'restriction', "Correct error returned");  | 
        
        
          | 691 | 
           | 
          687 | 
           | 
        
  
    | 
      
            Lines 708-751
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 708 | 
                  }  | 
          704 | 
                  }  | 
        
        
          | 709 | 
              );  | 
          705 | 
              );  | 
        
        
          | 710 | 
           | 
          706 | 
           | 
        
          
            
              | 711 | 
                  my $datedue6 = AddIssue( $renewing_borrower, $item_6->barcode);  | 
              707 | 
                  my $issue_6 = AddIssue( $renewing_borrower_obj->unblessed, $item_6->barcode);  | 
            
            
              | 712 | 
                  is (defined $datedue6, 1, "Item 2 checked out, due date: ".$datedue6->date_due);  | 
              708 | 
                  is (defined $issue_6, 1, "Item 2 checked out, due date: ".$issue_6->date_due);  | 
            
        
          | 713 | 
           | 
          709 | 
           | 
        
        
          | 714 | 
              my $now = dt_from_string();  | 
          710 | 
              my $now = dt_from_string();  | 
        
        
          | 715 | 
              my $five_weeks = DateTime::Duration->new(weeks => 5);  | 
          711 | 
              my $five_weeks = DateTime::Duration->new(weeks => 5);  | 
        
        
          | 716 | 
              my $five_weeks_ago = $now - $five_weeks;  | 
          712 | 
              my $five_weeks_ago = $now - $five_weeks;  | 
        
        
          | 717 | 
              t::lib::Mocks::mock_preference('finesMode', 'production'); | 
          713 | 
              t::lib::Mocks::mock_preference('finesMode', 'production'); | 
        
        
          | 718 | 
           | 
          714 | 
           | 
        
          
            
              | 719 | 
                  my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago);  | 
              715 | 
                  my $issue_7 = AddIssue($renewing_borrower_obj->unblessed, $item_7->barcode, $five_weeks_ago);  | 
            
            
              | 720 | 
                  is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due);  | 
              716 | 
                  is (defined $issue_7, 1, "Item with passed date due checked out, due date: " . $issue_7->date_due);  | 
            
        
          | 721 | 
           | 
          717 | 
           | 
        
        
          | 722 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); | 
          718 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); | 
        
          
            
              | 723 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);  | 
              719 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_6);  | 
            
        
          | 724 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');  | 
          720 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');  | 
        
          
            
              | 725 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);  | 
              721 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_7);  | 
            
        
          | 726 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');  | 
          722 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');  | 
        
        
          | 727 | 
           | 
          723 | 
           | 
        
        
          | 728 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','block'); | 
          724 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','block'); | 
        
          
            
              | 729 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);  | 
              725 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_6);  | 
            
        
          | 730 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');  | 
          726 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');  | 
        
        
          | 731 | 
              is( $error, 'overdue', "Correct error returned");  | 
          727 | 
              is( $error, 'overdue', "Correct error returned");  | 
        
          
            
              | 732 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);  | 
              728 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_7);  | 
            
        
          | 733 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');  | 
          729 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');  | 
        
        
          | 734 | 
              is( $error, 'overdue', "Correct error returned");  | 
          730 | 
              is( $error, 'overdue', "Correct error returned");  | 
        
        
          | 735 | 
           | 
          731 | 
           | 
        
        
          | 736 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem'); | 
          732 | 
              t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem'); | 
        
          
            
              | 737 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);  | 
              733 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_6);  | 
            
        
          | 738 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');  | 
          734 | 
              is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');  | 
        
          
            
              | 739 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);  | 
              735 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_7);  | 
            
        
          | 740 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');  | 
          736 | 
              is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');  | 
        
        
          | 741 | 
              is( $error, 'overdue', "Correct error returned");  | 
          737 | 
              is( $error, 'overdue', "Correct error returned");  | 
        
        
          | 742 | 
           | 
          738 | 
           | 
        
          
            
              | 743 | 
                  my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now ); | 
              739 | 
                  my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower_obj->categorycode, $branch, $five_weeks_ago, $now );  | 
            
        
          | 744 | 
              C4::Overdues::UpdateFine(  | 
          740 | 
              C4::Overdues::UpdateFine(  | 
        
        
          | 745 | 
                  { | 
          741 | 
                  { | 
        
          
            
              | 746 | 
                          issue_id       => $passeddatedue1->id(),  | 
              742 | 
                          issue_id       => $issue_7->id(),  | 
            
        
          | 747 | 
                      itemnumber     => $item_7->itemnumber,  | 
          743 | 
                      itemnumber     => $item_7->itemnumber,  | 
        
          
            
              | 748 | 
                          borrowernumber => $renewing_borrower->{borrowernumber}, | 
              744 | 
                          borrowernumber => $renewing_borrower_obj->borrowernumber,  | 
            
        
          | 749 | 
                      amount         => $fine,  | 
          745 | 
                      amount         => $fine,  | 
        
        
          | 750 | 
                      due            => Koha::DateUtils::output_pref($five_weeks_ago)  | 
          746 | 
                      due            => Koha::DateUtils::output_pref($five_weeks_ago)  | 
        
        
          | 751 | 
                  }  | 
          747 | 
                  }  | 
        
  
    | 
      
            Lines 776-782
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 776 | 
              my $old_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          772 | 
              my $old_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
        
          | 777 | 
              my $dt = dt_from_string();  | 
          773 | 
              my $dt = dt_from_string();  | 
        
        
          | 778 | 
              Time::Fake->offset( $dt->epoch );  | 
          774 | 
              Time::Fake->offset( $dt->epoch );  | 
        
          
            
              | 779 | 
                  my $datedue1 = AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); | 
              775 | 
                  my $datedue1 = AddRenewal( $renewing_borrower_obj->borrowernumber, $item_7->itemnumber, $branch );  | 
            
        
          | 780 | 
              my $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          776 | 
              my $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
        
          | 781 | 
              is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog');  | 
          777 | 
              is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog');  | 
        
        
          | 782 | 
              isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate");  | 
          778 | 
              isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate");  | 
        
  
    | 
      
            Lines 785-802
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 785 | 
              t::lib::Mocks::mock_preference('RenewalLog', 1); | 
          781 | 
              t::lib::Mocks::mock_preference('RenewalLog', 1); | 
        
        
          | 786 | 
              $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); | 
          782 | 
              $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); | 
        
        
          | 787 | 
              $old_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          783 | 
              $old_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
          
            
              | 788 | 
                  AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); | 
              784 | 
                  AddRenewal( $renewing_borrower_obj->borrowernumber, $item_7->itemnumber, $branch );  | 
            
        
          | 789 | 
              $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          785 | 
              $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
        
          | 790 | 
              is ($new_log_size, $old_log_size + 1, 'renew log successfully added');  | 
          786 | 
              is ($new_log_size, $old_log_size + 1, 'renew log successfully added');  | 
        
        
          | 791 | 
           | 
          787 | 
           | 
        
          
            
              | 792 | 
                  my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); | 
              788 | 
                  my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower_obj->borrowernumber, itemnumber => $item_7->itemnumber } ); | 
            
        
          | 793 | 
              is( $fines->count, 1, 'AddRenewal left fine' );  | 
          789 | 
              is( $fines->count, 1, 'AddRenewal left fine' );  | 
        
        
          | 794 | 
              is( $fines->next->status, 'RENEWED', 'Fine on renewed item is closed out properly' );  | 
          790 | 
              is( $fines->next->status, 'RENEWED', 'Fine on renewed item is closed out properly' );  | 
        
        
          | 795 | 
              $fines->delete();  | 
          791 | 
              $fines->delete();  | 
        
        
          | 796 | 
           | 
          792 | 
           | 
        
        
          | 797 | 
              my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );  | 
          793 | 
              my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );  | 
        
        
          | 798 | 
              my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          794 | 
              my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
          
            
              | 799 | 
                  AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef ); | 
              795 | 
                  AddIssue(  | 
            
            
               | 
               | 
              796 | 
                      $renewing_borrower_obj->unblessed,  | 
            
            
              | 797 | 
                      $item_7->barcode,  | 
            
            
              | 798 | 
                      Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), | 
            
            
              | 799 | 
                      0,  | 
            
            
              | 800 | 
                      $date,  | 
            
            
              | 801 | 
                      0,  | 
            
            
              | 802 | 
                      undef  | 
            
            
              | 803 | 
                  ); # TODO: Already issued???  | 
            
        
          | 800 | 
              $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
          804 | 
              $new_log_size = Koha::ActionLogs->count( \%params_renewal );  | 
        
        
          | 801 | 
              is ($new_log_size, $old_renew_log_size + 1, 'renew log successfully added when renewed via issuing');  | 
          805 | 
              is ($new_log_size, $old_renew_log_size + 1, 'renew log successfully added when renewed via issuing');  | 
        
        
          | 802 | 
              $new_log_size = Koha::ActionLogs->count( \%params_issue );  | 
          806 | 
              $new_log_size = Koha::ActionLogs->count( \%params_issue );  | 
        
  
    | 
      
            Lines 817-830
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 817 | 
                  }  | 
          821 | 
                  }  | 
        
        
          | 818 | 
              );  | 
          822 | 
              );  | 
        
        
          | 819 | 
           | 
          823 | 
           | 
        
          
            
              | 820 | 
                  $issue = AddIssue( $renewing_borrower, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); | 
              824 | 
                  my $issue_4 = AddIssue( $renewing_borrower_obj->unblessed, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); | 
            
        
          | 821 | 
              my $info;  | 
          825 | 
              my $info;  | 
        
        
          | 822 | 
              ( $renewokay, $error, $info ) =  | 
          826 | 
              ( $renewokay, $error, $info ) =  | 
        
          
            
              | 823 | 
                    CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              827 | 
                    CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 824 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
          828 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
        
        
          | 825 | 
              is( $error, 'auto_too_soon',  | 
          829 | 
              is( $error, 'auto_too_soon',  | 
        
        
          | 826 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' );  | 
          830 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' );  | 
        
          
            
              | 827 | 
                  is( $info->{soonest_renew_date} , dt_from_string($issue->date_due), "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); | 
              831 | 
                  is( $info->{soonest_renew_date} , dt_from_string($issue_4->date_due), "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); | 
            
        
          | 828 | 
              AddReserve(  | 
          832 | 
              AddReserve(  | 
        
        
          | 829 | 
                  { | 
          833 | 
                  { | 
        
        
          | 830 | 
                      branchcode       => $branch,  | 
          834 | 
                      branchcode       => $branch,  | 
        
  
    | 
      
            Lines 840-869
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 840 | 
                      found            => $found  | 
          844 | 
                      found            => $found  | 
        
        
          | 841 | 
                  }  | 
          845 | 
                  }  | 
        
        
          | 842 | 
              );  | 
          846 | 
              );  | 
        
          
            
              | 843 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              847 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 844 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
          848 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
        
        
          | 845 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, reserve checked when not checking for cron' );  | 
          849 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, reserve checked when not checking for cron' );  | 
        
          
            
              | 846 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, undef, 1 );  | 
              850 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4, undef, 1 );  | 
            
        
          | 847 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
          851 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
        
        
          | 848 | 
              is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked when checking for cron' );  | 
          852 | 
              is( $error, 'auto_too_soon', 'returned code is auto_too_soon, reserve not checked when checking for cron' );  | 
        
          
            
              | 849 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due), "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); | 
              853 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_4->date_due), "Due date is returned as earliest renewal date when error is 'auto_too_soon'" ); | 
            
            
              | 850 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 );  | 
              854 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4, 1 );  | 
            
        
          | 851 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
          855 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
        
        
          | 852 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' );  | 
          856 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' );  | 
        
          
            
              | 853 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1, 1 );  | 
              857 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4, 1, 1 );  | 
            
        
          | 854 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
          858 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
        
        
          | 855 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' );  | 
          859 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_too_soon limit is overridden' );  | 
        
        
          | 856 | 
              $dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); | 
          860 | 
              $dbh->do('UPDATE circulation_rules SET rule_value = 0 where rule_name = "norenewalbefore"'); | 
        
        
          | 857 | 
              Koha::Cache::Memory::Lite->flush();  | 
          861 | 
              Koha::Cache::Memory::Lite->flush();  | 
        
          
            
              | 858 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber, 1 );  | 
              862 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4, 1 );  | 
            
        
          | 859 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
          863 | 
              is( $renewokay, 0, 'Still should not be able to renew' );  | 
        
        
          | 860 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_renew only happens if not on reserve' );  | 
          864 | 
              is( $error, 'on_reserve', 'returned code is on_reserve, auto_renew only happens if not on reserve' );  | 
        
        
          | 861 | 
              ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber);  | 
          865 | 
              ModReserveCancelAll($item_4->itemnumber, $reserving_borrowernumber);  | 
        
        
          | 862 | 
           | 
          866 | 
           | 
        
          
            
              | 863 | 
               | 
              867 | 
                  $renewing_borrower_obj = Koha::Patrons->find($renewing_borrower_obj->borrowernumber);  | 
            
            
              | 864 | 
               | 
               | 
               | 
            
        
          | 865 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
          868 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
        
          
            
              | 866 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              869 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 867 | 
              is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' );  | 
          870 | 
              is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' );  | 
        
        
          | 868 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
          871 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
        
        
          | 869 | 
           | 
          872 | 
           | 
        
  
    | 
      
            Lines 880-905
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 880 | 
                  }  | 
          883 | 
                  }  | 
        
        
          | 881 | 
              );  | 
          884 | 
              );  | 
        
        
          | 882 | 
           | 
          885 | 
           | 
        
          
            
              | 883 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              886 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 884 | 
              is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature');  | 
          887 | 
              is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature');  | 
        
        
          | 885 | 
              is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)');  | 
          888 | 
              is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)');  | 
        
          
            
              | 886 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); | 
              889 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_1->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); | 
            
        
          | 887 | 
           | 
          890 | 
           | 
        
        
          | 888 | 
              # Bug 14101  | 
          891 | 
              # Bug 14101  | 
        
        
          | 889 | 
              # Test premature automatic renewal  | 
          892 | 
              # Test premature automatic renewal  | 
        
        
          | 890 | 
              ( $renewokay, $error, $info ) =  | 
          893 | 
              ( $renewokay, $error, $info ) =  | 
        
          
            
              | 891 | 
                    CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              894 | 
                    CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 892 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
          895 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
        
        
          | 893 | 
              is( $error, 'auto_too_soon',  | 
          896 | 
              is( $error, 'auto_too_soon',  | 
        
        
          | 894 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'  | 
          897 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'  | 
        
        
          | 895 | 
              );  | 
          898 | 
              );  | 
        
          
            
              | 896 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'"); | 
              899 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_4->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'"); | 
            
        
          | 897 | 
           | 
          900 | 
           | 
        
        
          | 898 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
          901 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
        
          
            
              | 899 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              902 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 900 | 
              is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' );  | 
          903 | 
              is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' );  | 
        
        
          | 901 | 
              is( $error, 'too_soon', 'Error is too_soon, no auto' );  | 
          904 | 
              is( $error, 'too_soon', 'Error is too_soon, no auto' );  | 
        
          
            
              | 902 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); | 
              905 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_4->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'too_soon'"); | 
            
        
          | 903 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
          906 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
        
        
          | 904 | 
           | 
          907 | 
           | 
        
        
          | 905 | 
              # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date)  | 
          908 | 
              # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date)  | 
        
  
    | 
      
            Lines 907-924
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 907 | 
              $dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); | 
          910 | 
              $dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); | 
        
        
          | 908 | 
              Koha::Cache::Memory::Lite->flush();  | 
          911 | 
              Koha::Cache::Memory::Lite->flush();  | 
        
        
          | 909 | 
              ( $renewokay, $error, $info ) =  | 
          912 | 
              ( $renewokay, $error, $info ) =  | 
        
          
            
              | 910 | 
                    CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              913 | 
                    CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 911 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
          914 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' );  | 
        
        
          | 912 | 
              is( $error, 'auto_too_soon',  | 
          915 | 
              is( $error, 'auto_too_soon',  | 
        
        
          | 913 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)'  | 
          916 | 
                  'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)'  | 
        
        
          | 914 | 
              );  | 
          917 | 
              );  | 
        
          
            
              | 915 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); | 
              918 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_4->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); | 
            
        
          | 916 | 
           | 
          919 | 
           | 
        
        
          | 917 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
          920 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
        
          
            
              | 918 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              921 | 
                  ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 919 | 
              is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' );  | 
          922 | 
              is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' );  | 
        
        
          | 920 | 
              is( $error, 'too_soon', 'Error is too_soon, no auto' );  | 
          923 | 
              is( $error, 'too_soon', 'Error is too_soon, no auto' );  | 
        
          
            
              | 921 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); | 
              924 | 
                  is( $info->{soonest_renew_date}, dt_from_string($issue_4->date_due), "Soonest renew date returned when error is 'auto_too_soon'"); | 
            
        
          | 922 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
          925 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
        
        
          | 923 | 
           | 
          926 | 
           | 
        
        
          | 924 | 
              # Change policy so that loans can be renewed 99 days prior to the due date  | 
          927 | 
              # Change policy so that loans can be renewed 99 days prior to the due date  | 
        
  
    | 
      
            Lines 926-939
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 926 | 
              $dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); | 
          929 | 
              $dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); | 
        
        
          | 927 | 
              Koha::Cache::Memory::Lite->flush();  | 
          930 | 
              Koha::Cache::Memory::Lite->flush();  | 
        
        
          | 928 | 
              ( $renewokay, $error ) =  | 
          931 | 
              ( $renewokay, $error ) =  | 
        
          
            
              | 929 | 
                    CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              932 | 
                    CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 930 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' );  | 
          933 | 
              is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' );  | 
        
        
          | 931 | 
              is( $error, 'auto_renew',  | 
          934 | 
              is( $error, 'auto_renew',  | 
        
        
          | 932 | 
                  'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)'  | 
          935 | 
                  'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)'  | 
        
        
          | 933 | 
              );  | 
          936 | 
              );  | 
        
        
          | 934 | 
           | 
          937 | 
           | 
        
        
          | 935 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
          938 | 
              $renewing_borrower_obj->autorenew_checkouts(0)->store;  | 
        
          
            
              | 936 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber );  | 
              939 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_4 );  | 
            
        
          | 937 | 
              is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' );  | 
          940 | 
              is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' );  | 
        
        
          | 938 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
          941 | 
              $renewing_borrower_obj->autorenew_checkouts(1)->store;  | 
        
        
          | 939 | 
           | 
          942 | 
           | 
        
  
    | 
      
            Lines 948-954
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 948 | 
           | 
          951 | 
           | 
        
        
          | 949 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
          952 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
        
        
          | 950 | 
                  my $ten_days_ahead  = dt_from_string->add( days => 10 );  | 
          953 | 
                  my $ten_days_ahead  = dt_from_string->add( days => 10 );  | 
        
          
            
              | 951 | 
                      AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
              954 | 
                      my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
        
          | 952 | 
           | 
          955 | 
           | 
        
        
          | 953 | 
                  Koha::CirculationRules->set_rules(  | 
          956 | 
                  Koha::CirculationRules->set_rules(  | 
        
        
          | 954 | 
                      { | 
          957 | 
                      { | 
        
  
    | 
      
            Lines 962-968
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 962 | 
                      }  | 
          965 | 
                      }  | 
        
        
          | 963 | 
                  );  | 
          966 | 
                  );  | 
        
        
          | 964 | 
                  ( $renewokay, $error ) =  | 
          967 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 965 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              968 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 966 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          969 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 967 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
          970 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
        
        
          | 968 | 
           | 
          971 | 
           | 
        
  
    | 
      
            Lines 978-984
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 978 | 
                      }  | 
          981 | 
                      }  | 
        
        
          | 979 | 
                  );  | 
          982 | 
                  );  | 
        
        
          | 980 | 
                  ( $renewokay, $error ) =  | 
          983 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 981 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              984 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 982 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          985 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 983 | 
                  is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' );  | 
          986 | 
                  is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' );  | 
        
        
          | 984 | 
           | 
          987 | 
           | 
        
  
    | 
      
            Lines 994-1000
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 994 | 
                      }  | 
          997 | 
                      }  | 
        
        
          | 995 | 
                  );  | 
          998 | 
                  );  | 
        
        
          | 996 | 
                  ( $renewokay, $error ) =  | 
          999 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 997 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1000 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 998 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1001 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 999 | 
                  is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' );  | 
          1002 | 
                  is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' );  | 
        
        
          | 1000 | 
           | 
          1003 | 
           | 
        
  
    | 
      
            Lines 1010-1016
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1010 | 
                      }  | 
          1013 | 
                      }  | 
        
        
          | 1011 | 
                  );  | 
          1014 | 
                  );  | 
        
        
          | 1012 | 
                  ( $renewokay, $error ) =  | 
          1015 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1013 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1016 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1014 | 
                  is( $renewokay, 0,            'Do not renew, renewal is automatic' );  | 
          1017 | 
                  is( $renewokay, 0,            'Do not renew, renewal is automatic' );  | 
        
        
          | 1015 | 
                  is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );  | 
          1018 | 
                  is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );  | 
        
        
          | 1016 | 
           | 
          1019 | 
           | 
        
  
    | 
      
            Lines 1027-1033
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1027 | 
                      }  | 
          1030 | 
                      }  | 
        
        
          | 1028 | 
                  );  | 
          1031 | 
                  );  | 
        
        
          | 1029 | 
                  ( $renewokay, $error ) =  | 
          1032 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1030 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1033 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1031 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1034 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1032 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
          1035 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
        
        
          | 1033 | 
           | 
          1036 | 
           | 
        
  
    | 
      
            Lines 1044-1050
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1044 | 
                      }  | 
          1047 | 
                      }  | 
        
        
          | 1045 | 
                  );  | 
          1048 | 
                  );  | 
        
        
          | 1046 | 
                  ( $renewokay, $error ) =  | 
          1049 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1047 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1050 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1048 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1051 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1049 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
          1052 | 
                  is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' );  | 
        
        
          | 1050 | 
           | 
          1053 | 
           | 
        
  
    | 
      
            Lines 1061-1067
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1061 | 
                      }  | 
          1064 | 
                      }  | 
        
        
          | 1062 | 
                  );  | 
          1065 | 
                  );  | 
        
        
          | 1063 | 
                  ( $renewokay, $error ) =  | 
          1066 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1064 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1067 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1065 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1068 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1066 | 
                  is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );  | 
          1069 | 
                  is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );  | 
        
        
          | 1067 | 
              };  | 
          1070 | 
              };  | 
        
  
    | 
      
            Lines 1077-1083
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1077 | 
           | 
          1080 | 
           | 
        
        
          | 1078 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
          1081 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
        
        
          | 1079 | 
                  my $ten_days_ahead = dt_from_string->add( days => 10 );  | 
          1082 | 
                  my $ten_days_ahead = dt_from_string->add( days => 10 );  | 
        
          
            
              | 1080 | 
                      AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
              1083 | 
                      my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
        
          | 1081 | 
           | 
          1084 | 
           | 
        
        
          | 1082 | 
                  Koha::CirculationRules->set_rules(  | 
          1085 | 
                  Koha::CirculationRules->set_rules(  | 
        
        
          | 1083 | 
                      { | 
          1086 | 
                      { | 
        
  
    | 
      
            Lines 1105-1111
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1105 | 
                      }  | 
          1108 | 
                      }  | 
        
        
          | 1106 | 
                  )->status('RETURNED')->store; | 
          1109 | 
                  )->status('RETURNED')->store; | 
        
        
          | 1107 | 
                  ( $renewokay, $error ) =  | 
          1110 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1108 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1111 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1109 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1112 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1110 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );  | 
          1113 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );  | 
        
        
          | 1111 | 
           | 
          1114 | 
           | 
        
  
    | 
      
            Lines 1119-1125
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1119 | 
                      }  | 
          1122 | 
                      }  | 
        
        
          | 1120 | 
                  )->status('RETURNED')->store; | 
          1123 | 
                  )->status('RETURNED')->store; | 
        
        
          | 1121 | 
                  ( $renewokay, $error ) =  | 
          1124 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1122 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1125 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1123 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1126 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1124 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );  | 
          1127 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );  | 
        
        
          | 1125 | 
           | 
          1128 | 
           | 
        
  
    | 
      
            Lines 1133-1139
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1133 | 
                      }  | 
          1136 | 
                      }  | 
        
        
          | 1134 | 
                  )->status('RETURNED')->store; | 
          1137 | 
                  )->status('RETURNED')->store; | 
        
        
          | 1135 | 
                  ( $renewokay, $error ) =  | 
          1138 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1136 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1139 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1137 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1140 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1138 | 
                  is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );  | 
          1141 | 
                  is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );  | 
        
        
          | 1139 | 
           | 
          1142 | 
           | 
        
  
    | 
      
            Lines 1146-1158
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1146 | 
                      }  | 
          1149 | 
                      }  | 
        
        
          | 1147 | 
                  )->store;  | 
          1150 | 
                  )->store;  | 
        
        
          | 1148 | 
                  ( $renewokay, $error ) =  | 
          1151 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1149 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1152 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1150 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1153 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1151 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit'  );  | 
          1154 | 
                  is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit'  );  | 
        
        
          | 1152 | 
           | 
          1155 | 
           | 
        
        
          | 1153 | 
                  C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); | 
          1156 | 
                  C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); | 
        
        
          | 1154 | 
                  ( $renewokay, $error ) =  | 
          1157 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1155 | 
                        CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1158 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1156 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1159 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1157 | 
                  is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit'  );  | 
          1160 | 
                  is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit'  );  | 
        
        
          | 1158 | 
           | 
          1161 | 
           | 
        
  
    | 
      
            Lines 1187-1223
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1187 | 
                  # Patron is expired and BlockExpiredPatronOpacActions=0  | 
          1190 | 
                  # Patron is expired and BlockExpiredPatronOpacActions=0  | 
        
        
          | 1188 | 
                  # => auto renew is allowed  | 
          1191 | 
                  # => auto renew is allowed  | 
        
        
          | 1189 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); | 
          1192 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); | 
        
          
            
              | 1190 | 
                      my $patron = $expired_borrower;  | 
              1193 | 
                      my $issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
            
              | 1191 | 
                      my $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
               | 
               | 
            
        
          | 1192 | 
                  ( $renewokay, $error ) =  | 
          1194 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1193 | 
                        CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); | 
              1195 | 
                        CanBookBeRenewed( $expired_borrower_obj, $issue );  | 
            
        
          | 1194 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1196 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1195 | 
                  is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' );  | 
          1197 | 
                  is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' );  | 
        
          
            
              | 1196 | 
                      Koha::Checkouts->find( $checkout->issue_id )->delete;  | 
              1198 | 
                      Koha::Checkouts->find( $issue->issue_id )->delete;  | 
            
        
          | 1197 | 
           | 
          1199 | 
           | 
        
        
          | 1198 | 
           | 
          1200 | 
           | 
        
        
          | 1199 | 
                  # Patron is expired and BlockExpiredPatronOpacActions=1  | 
          1201 | 
                  # Patron is expired and BlockExpiredPatronOpacActions=1  | 
        
        
          | 1200 | 
                  # => auto renew is not allowed  | 
          1202 | 
                  # => auto renew is not allowed  | 
        
        
          | 1201 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); | 
          1203 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); | 
        
          
            
              | 1202 | 
                      $patron = $expired_borrower;  | 
              1204 | 
                      $issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
            
              | 1203 | 
                      $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
               | 
               | 
            
        
          | 1204 | 
                  ( $renewokay, $error ) =  | 
          1205 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1205 | 
                        CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); | 
              1206 | 
                        CanBookBeRenewed( $expired_borrower_obj, $issue );  | 
            
        
          | 1206 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1207 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1207 | 
                  is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' );  | 
          1208 | 
                  is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' );  | 
        
          
            
              | 1208 | 
                      Koha::Checkouts->find( $checkout->issue_id )->delete;  | 
              1209 | 
                      $issue->delete;  | 
            
            
              | 1209 | 
               | 
               | 
               | 
            
        
          | 1210 | 
           | 
          1210 | 
           | 
        
        
          | 1211 | 
                  # Patron is not expired and BlockExpiredPatronOpacActions=1  | 
          1211 | 
                  # Patron is not expired and BlockExpiredPatronOpacActions=1  | 
        
        
          | 1212 | 
                  # => auto renew is allowed  | 
          1212 | 
                  # => auto renew is allowed  | 
        
        
          | 1213 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); | 
          1213 | 
                  t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); | 
        
          
            
              | 1214 | 
                      $patron = $renewing_borrower;  | 
              1214 | 
                      $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
            
              | 1215 | 
                      $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
               | 
               | 
            
        
          | 1216 | 
                  ( $renewokay, $error ) =  | 
          1215 | 
                  ( $renewokay, $error ) =  | 
        
          
            
              | 1217 | 
                        CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); | 
              1216 | 
                        CanBookBeRenewed( $renewing_borrower_obj, $issue );  | 
            
        
          | 1218 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
          1217 | 
                  is( $renewokay, 0, 'Do not renew, renewal is automatic' );  | 
        
        
          | 1219 | 
                  is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' );  | 
          1218 | 
                  is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' );  | 
        
          
            
              | 1220 | 
                      Koha::Checkouts->find( $checkout->issue_id )->delete;  | 
              1219 | 
                      $issue->delete;  | 
            
        
          | 1221 | 
              };  | 
          1220 | 
              };  | 
        
        
          | 1222 | 
           | 
          1221 | 
           | 
        
        
          | 1223 | 
              subtest "GetLatestAutoRenewDate" => sub { | 
          1222 | 
              subtest "GetLatestAutoRenewDate" => sub { | 
        
  
    | 
      
            Lines 1231-1237
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1231 | 
           | 
          1230 | 
           | 
        
        
          | 1232 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
          1231 | 
                  my $ten_days_before = dt_from_string->add( days => -10 );  | 
        
        
          | 1233 | 
                  my $ten_days_ahead  = dt_from_string->add( days => 10 );  | 
          1232 | 
                  my $ten_days_ahead  = dt_from_string->add( days => 10 );  | 
        
          
            
              | 1234 | 
                      AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
              1233 | 
                      my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); | 
            
        
          | 1235 | 
                  Koha::CirculationRules->set_rules(  | 
          1234 | 
                  Koha::CirculationRules->set_rules(  | 
        
        
          | 1236 | 
                      { | 
          1235 | 
                      { | 
        
        
          | 1237 | 
                          categorycode => undef,  | 
          1236 | 
                          categorycode => undef,  | 
        
  
    | 
      
            Lines 1244-1250
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1244 | 
                          }  | 
          1243 | 
                          }  | 
        
        
          | 1245 | 
                      }  | 
          1244 | 
                      }  | 
        
        
          | 1246 | 
                  );  | 
          1245 | 
                  );  | 
        
          
            
              | 1247 | 
                      my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1246 | 
                      my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue );  | 
            
        
          | 1248 | 
                  is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after or no_auto_renewal_after_hard_limit are not defined' );  | 
          1247 | 
                  is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after or no_auto_renewal_after_hard_limit are not defined' );  | 
        
        
          | 1249 | 
                  my $five_days_before = dt_from_string->add( days => -5 );  | 
          1248 | 
                  my $five_days_before = dt_from_string->add( days => -5 );  | 
        
        
          | 1250 | 
                  Koha::CirculationRules->set_rules(  | 
          1249 | 
                  Koha::CirculationRules->set_rules(  | 
        
  
    | 
      
            Lines 1259-1265
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1259 | 
                          }  | 
          1258 | 
                          }  | 
        
        
          | 1260 | 
                      }  | 
          1259 | 
                      }  | 
        
        
          | 1261 | 
                  );  | 
          1260 | 
                  );  | 
        
          
            
              | 1262 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1261 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj,, $issue );  | 
            
        
          | 1263 | 
                  is( $latest_auto_renew_date->truncate( to => 'minute' ),  | 
          1262 | 
                  is( $latest_auto_renew_date->truncate( to => 'minute' ),  | 
        
        
          | 1264 | 
                      $five_days_before->truncate( to => 'minute' ),  | 
          1263 | 
                      $five_days_before->truncate( to => 'minute' ),  | 
        
        
          | 1265 | 
                      'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before'  | 
          1264 | 
                      'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before'  | 
        
  
    | 
      
            Lines 1281-1287
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1281 | 
                          }  | 
          1280 | 
                          }  | 
        
        
          | 1282 | 
                      }  | 
          1281 | 
                      }  | 
        
        
          | 1283 | 
                  );  | 
          1282 | 
                  );  | 
        
          
            
              | 1284 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1283 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue );  | 
            
        
          | 1285 | 
                  is( $latest_auto_renew_date->truncate( to => 'minute' ),  | 
          1284 | 
                  is( $latest_auto_renew_date->truncate( to => 'minute' ),  | 
        
        
          | 1286 | 
                      $five_days_ahead->truncate( to => 'minute' ),  | 
          1285 | 
                      $five_days_ahead->truncate( to => 'minute' ),  | 
        
        
          | 1287 | 
                      'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before'  | 
          1286 | 
                      'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before'  | 
        
  
    | 
      
            Lines 1299-1305
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1299 | 
                          }  | 
          1298 | 
                          }  | 
        
        
          | 1300 | 
                      }  | 
          1299 | 
                      }  | 
        
        
          | 1301 | 
                  );  | 
          1300 | 
                  );  | 
        
          
            
              | 1302 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1301 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue );  | 
            
        
          | 1303 | 
                  is( $latest_auto_renew_date->truncate( to => 'day' ),  | 
          1302 | 
                  is( $latest_auto_renew_date->truncate( to => 'day' ),  | 
        
        
          | 1304 | 
                      $two_days_ahead->truncate( to => 'day' ),  | 
          1303 | 
                      $two_days_ahead->truncate( to => 'day' ),  | 
        
        
          | 1305 | 
                      'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after'  | 
          1304 | 
                      'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after'  | 
        
  
    | 
      
            Lines 1316-1322
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1316 | 
                          }  | 
          1315 | 
                          }  | 
        
        
          | 1317 | 
                      }  | 
          1316 | 
                      }  | 
        
        
          | 1318 | 
                  );  | 
          1317 | 
                  );  | 
        
          
            
              | 1319 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );  | 
              1318 | 
                      $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue );  | 
            
        
          | 1320 | 
                  is( $latest_auto_renew_date->truncate( to => 'day' ),  | 
          1319 | 
                  is( $latest_auto_renew_date->truncate( to => 'day' ),  | 
        
        
          | 1321 | 
                      $two_days_ahead->truncate( to => 'day' ),  | 
          1320 | 
                      $two_days_ahead->truncate( to => 'day' ),  | 
        
        
          | 1322 | 
                      'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is < no_auto_renewal_after'  | 
          1321 | 
                      'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is < no_auto_renewal_after'  | 
        
  
    | 
      
            Lines 1338-1344
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1338 | 
                  }  | 
          1337 | 
                  }  | 
        
        
          | 1339 | 
              );  | 
          1338 | 
              );  | 
        
        
          | 1340 | 
           | 
          1339 | 
           | 
        
          
            
              | 1341 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              1340 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 1342 | 
              is( $renewokay, 0, 'Cannot renew, 0 renewals allowed');  | 
          1341 | 
              is( $renewokay, 0, 'Cannot renew, 0 renewals allowed');  | 
        
        
          | 1343 | 
              is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');  | 
          1342 | 
              is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');  | 
        
        
          | 1344 | 
           | 
          1343 | 
           | 
        
  
    | 
      
            Lines 1355-1362
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1355 | 
                  }  | 
          1354 | 
                  }  | 
        
        
          | 1356 | 
              );  | 
          1355 | 
              );  | 
        
        
          | 1357 | 
              t::lib::Mocks::mock_preference('UnseenRenewals', 1); | 
          1356 | 
              t::lib::Mocks::mock_preference('UnseenRenewals', 1); | 
        
          
            
              | 1358 | 
                  $dbh->do('UPDATE issues SET unseen_renewals = 2 where borrowernumber = ? AND itemnumber = ?', undef, ($renewing_borrowernumber, $item_1->itemnumber)); | 
              1357 | 
                  $issue_1->unseen_renewals(2)->store;  | 
            
            
              | 1359 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);  | 
              1358 | 
               | 
            
            
               | 
               | 
              1359 | 
                  ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);  | 
            
        
          | 1360 | 
              is( $renewokay, 0, 'Cannot renew, 0 unseen renewals allowed');  | 
          1360 | 
              is( $renewokay, 0, 'Cannot renew, 0 unseen renewals allowed');  | 
        
        
          | 1361 | 
              is( $error, 'too_unseen', 'Cannot renew, returned code is too_unseen');  | 
          1361 | 
              is( $error, 'too_unseen', 'Cannot renew, returned code is too_unseen');  | 
        
        
          | 1362 | 
              Koha::CirculationRules->set_rules(  | 
          1362 | 
              Koha::CirculationRules->set_rules(  | 
        
  
    | 
      
            Lines 1378-1398
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1378 | 
           | 
          1378 | 
           | 
        
        
          | 1379 | 
              C4::Overdues::UpdateFine(  | 
          1379 | 
              C4::Overdues::UpdateFine(  | 
        
        
          | 1380 | 
                  { | 
          1380 | 
                  { | 
        
          
            
              | 1381 | 
                          issue_id       => $issue->id(),  | 
              1381 | 
                          issue_id       => $issue_1->id(),  | 
            
        
          | 1382 | 
                      itemnumber     => $item_1->itemnumber,  | 
          1382 | 
                      itemnumber     => $item_1->itemnumber,  | 
        
          
            
              | 1383 | 
                          borrowernumber => $renewing_borrower->{borrowernumber}, | 
              1383 | 
                          borrowernumber => $renewing_borrower_obj->borrowernumber,  | 
            
        
          | 1384 | 
                      amount         => 15.00,  | 
          1384 | 
                      amount         => 15.00,  | 
        
        
          | 1385 | 
                      type           => q{}, | 
          1385 | 
                      type           => q{}, | 
        
        
          | 1386 | 
                      due            => Koha::DateUtils::output_pref($datedue)  | 
          1386 | 
                      due            => Koha::DateUtils::output_pref($datedue)  | 
        
        
          | 1387 | 
                  }  | 
          1387 | 
                  }  | 
        
        
          | 1388 | 
              );  | 
          1388 | 
              );  | 
        
        
          | 1389 | 
           | 
          1389 | 
           | 
        
          
            
              | 1390 | 
                  my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); | 
              1390 | 
                  my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower_obj->borrowernumber })->next(); | 
            
        
          | 1391 | 
              is( $line->debit_type_code, 'OVERDUE', 'Account line type is OVERDUE' );  | 
          1391 | 
              is( $line->debit_type_code, 'OVERDUE', 'Account line type is OVERDUE' );  | 
        
        
          | 1392 | 
              is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' );  | 
          1392 | 
              is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' );  | 
        
        
          | 1393 | 
              is( $line->amountoutstanding+0, 15, 'Account line amount outstanding is 15.00' );  | 
          1393 | 
              is( $line->amountoutstanding+0, 15, 'Account line amount outstanding is 15.00' );  | 
        
        
          | 1394 | 
              is( $line->amount+0, 15, 'Account line amount is 15.00' );  | 
          1394 | 
              is( $line->amount+0, 15, 'Account line amount is 15.00' );  | 
        
          
            
              | 1395 | 
                  is( $line->issue_id, $issue->id, 'Account line issue id matches' );  | 
              1395 | 
                  is( $line->issue_id, $issue_1->id, 'Account line issue id matches' );  | 
            
        
          | 1396 | 
           | 
          1396 | 
           | 
        
        
          | 1397 | 
              my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); | 
          1397 | 
              my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); | 
        
        
          | 1398 | 
              is( $offset->type, 'CREATE', 'Account offset type is CREATE' );  | 
          1398 | 
              is( $offset->type, 'CREATE', 'Account offset type is CREATE' );  | 
        
  
    | 
      
            Lines 1414-1420
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1414 | 
           | 
          1414 | 
           | 
        
        
          | 1415 | 
              my $total_due = $dbh->selectrow_array(  | 
          1415 | 
              my $total_due = $dbh->selectrow_array(  | 
        
        
          | 1416 | 
                  'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',  | 
          1416 | 
                  'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',  | 
        
          
            
              | 1417 | 
                      undef, $renewing_borrower->{borrowernumber} | 
              1417 | 
                      undef, $renewing_borrower_obj->borrowernumber  | 
            
        
          | 1418 | 
              );  | 
          1418 | 
              );  | 
        
        
          | 1419 | 
           | 
          1419 | 
           | 
        
        
          | 1420 | 
              is( $total_due+0, 15, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' );  | 
          1420 | 
              is( $total_due+0, 15, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' );  | 
        
  
    | 
      
            Lines 1423-1431
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1423 | 
           | 
          1423 | 
           | 
        
        
          | 1424 | 
              C4::Overdues::UpdateFine(  | 
          1424 | 
              C4::Overdues::UpdateFine(  | 
        
        
          | 1425 | 
                  { | 
          1425 | 
                  { | 
        
          
            
              | 1426 | 
                          issue_id       => $issue2->id(),  | 
              1426 | 
                          issue_id       => $issue_2->id(),  | 
            
        
          | 1427 | 
                      itemnumber     => $item_2->itemnumber,  | 
          1427 | 
                      itemnumber     => $item_2->itemnumber,  | 
        
          
            
              | 1428 | 
                          borrowernumber => $renewing_borrower->{borrowernumber}, | 
              1428 | 
                          borrowernumber => $renewing_borrower_obj->borrowernumber,  | 
            
        
          | 1429 | 
                      amount         => 15.00,  | 
          1429 | 
                      amount         => 15.00,  | 
        
        
          | 1430 | 
                      type           => q{}, | 
          1430 | 
                      type           => q{}, | 
        
        
          | 1431 | 
                      due            => Koha::DateUtils::output_pref($datedue)  | 
          1431 | 
                      due            => Koha::DateUtils::output_pref($datedue)  | 
        
  
    | 
      
            Lines 1440-1446
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1440 | 
           | 
          1440 | 
           | 
        
        
          | 1441 | 
              $total_due = $dbh->selectrow_array(  | 
          1441 | 
              $total_due = $dbh->selectrow_array(  | 
        
        
          | 1442 | 
                  'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',  | 
          1442 | 
                  'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',  | 
        
          
            
              | 1443 | 
                      undef, $renewing_borrower->{borrowernumber} | 
              1443 | 
                      undef, $renewing_borrower_obj->borrowernumber  | 
            
        
          | 1444 | 
              );  | 
          1444 | 
              );  | 
        
        
          | 1445 | 
           | 
          1445 | 
           | 
        
        
          | 1446 | 
              ok( $total_due == 15, 'Borrower only charged fine with both WhenLostForgiveFine and WhenLostChargeReplacementFee disabled' );  | 
          1446 | 
              ok( $total_due == 15, 'Borrower only charged fine with both WhenLostForgiveFine and WhenLostChargeReplacementFee disabled' );  | 
        
  
    | 
      
            Lines 1478-1488
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1478 | 
                  },  | 
          1478 | 
                  },  | 
        
        
          | 1479 | 
              });  | 
          1479 | 
              });  | 
        
        
          | 1480 | 
              my $recall_borrower = $builder->build_object({ class => 'Koha::Patrons' }); | 
          1480 | 
              my $recall_borrower = $builder->build_object({ class => 'Koha::Patrons' }); | 
        
          
            
              | 1481 | 
                  my $recall_biblio = $builder->build_object({ class => 'Koha::Biblios' }); | 
              1481 | 
                  my $recall_biblio = $builder->build_sample_biblio();  | 
            
            
              | 1482 | 
                  my $recall_item1 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $recall_biblio->biblionumber } }); | 
              1482 | 
                  my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); | 
            
            
              | 1483 | 
                  my $recall_item2 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $recall_biblio->biblionumber } }); | 
              1483 | 
                  my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); | 
            
        
          | 1484 | 
           | 
          1484 | 
           | 
        
          
            
              | 1485 | 
                  AddIssue( $renewing_borrower, $recall_item1->barcode );  | 
              1485 | 
                  my $recall_issue = AddIssue( $renewing_borrower_obj->unblessed, $recall_item1->barcode );  | 
            
        
          | 1486 | 
           | 
          1486 | 
           | 
        
        
          | 1487 | 
              # item-level and this item: renewal not allowed  | 
          1487 | 
              # item-level and this item: renewal not allowed  | 
        
        
          | 1488 | 
              my $recall = Koha::Recall->new({ | 
          1488 | 
              my $recall = Koha::Recall->new({ | 
        
  
    | 
      
            Lines 1492-1498
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1492 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
          1492 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
        
        
          | 1493 | 
                  item_level => 1,  | 
          1493 | 
                  item_level => 1,  | 
        
        
          | 1494 | 
              })->store;  | 
          1494 | 
              })->store;  | 
        
          
            
              | 1495 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );  | 
              1495 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );  | 
            
        
          | 1496 | 
              is( $error, 'recalled', 'Cannot renew item that has been recalled' );  | 
          1496 | 
              is( $error, 'recalled', 'Cannot renew item that has been recalled' );  | 
        
        
          | 1497 | 
              $recall->set_cancelled;  | 
          1497 | 
              $recall->set_cancelled;  | 
        
        
          | 1498 | 
           | 
          1498 | 
           | 
        
  
    | 
      
            Lines 1504-1510
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1504 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
          1504 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
        
        
          | 1505 | 
                  item_level => 0,  | 
          1505 | 
                  item_level => 0,  | 
        
        
          | 1506 | 
              })->store;  | 
          1506 | 
              })->store;  | 
        
          
            
              | 1507 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );  | 
              1507 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );  | 
            
        
          | 1508 | 
              is( $error, 'recalled', 'Cannot renew item if biblio is recalled and has no item allocated' );  | 
          1508 | 
              is( $error, 'recalled', 'Cannot renew item if biblio is recalled and has no item allocated' );  | 
        
        
          | 1509 | 
              $recall->set_cancelled;  | 
          1509 | 
              $recall->set_cancelled;  | 
        
        
          | 1510 | 
           | 
          1510 | 
           | 
        
  
    | 
      
            Lines 1516-1522
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1516 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
          1516 | 
                  pickup_library_id => $recall_borrower->branchcode,  | 
        
        
          | 1517 | 
                  item_level => 1,  | 
          1517 | 
                  item_level => 1,  | 
        
        
          | 1518 | 
              })->store;  | 
          1518 | 
              })->store;  | 
        
          
            
              | 1519 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );  | 
              1519 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );  | 
            
        
          | 1520 | 
              is( $renewokay, 1, 'Can renew item if item-level recall on biblio is not on this item' );  | 
          1520 | 
              is( $renewokay, 1, 'Can renew item if item-level recall on biblio is not on this item' );  | 
        
        
          | 1521 | 
              $recall->set_cancelled;  | 
          1521 | 
              $recall->set_cancelled;  | 
        
        
          | 1522 | 
           | 
          1522 | 
           | 
        
  
    | 
      
            Lines 1529-1535
          subtest "CanBookBeRenewed tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1529 | 
                  item_level => 0,  | 
          1529 | 
                  item_level => 0,  | 
        
        
          | 1530 | 
              })->store;  | 
          1530 | 
              })->store;  | 
        
        
          | 1531 | 
              $recall->set_waiting({ item => $recall_item1 }); | 
          1531 | 
              $recall->set_waiting({ item => $recall_item1 }); | 
        
          
            
              | 1532 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );  | 
              1532 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );  | 
            
        
          | 1533 | 
              is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );  | 
          1533 | 
              is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );  | 
        
        
          | 1534 | 
              $recall->set_cancelled;  | 
          1534 | 
              $recall->set_cancelled;  | 
        
        
          | 1535 | 
          };  | 
          1535 | 
          };  | 
        
  
    | 
      
            Lines 1571-1577
          subtest "GetUpcomingDueIssues" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1571 | 
           | 
          1571 | 
           | 
        
        
          | 1572 | 
              my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday );  | 
          1572 | 
              my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday );  | 
        
        
          | 1573 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
          1573 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
        
          
            
              | 1574 | 
                  my $issue2 = AddIssue( $a_borrower, $item_2->barcode, $two_days_ahead );  | 
              1574 | 
                  my $issue_2 = AddIssue( $a_borrower, $item_2->barcode, $two_days_ahead );  | 
            
        
          | 1575 | 
              my $datedue2 = dt_from_string( $issue->date_due() );  | 
          1575 | 
              my $datedue2 = dt_from_string( $issue->date_due() );  | 
        
        
          | 1576 | 
           | 
          1576 | 
           | 
        
        
          | 1577 | 
              my $upcoming_dues;  | 
          1577 | 
              my $upcoming_dues;  | 
        
  
    | 
      
            Lines 1697-1708
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1697 | 
              );  | 
          1697 | 
              );  | 
        
        
          | 1698 | 
           | 
          1698 | 
           | 
        
        
          | 1699 | 
           | 
          1699 | 
           | 
        
          
            
              | 1700 | 
                  my $borrowernumber1 = Koha::Patron->new({ | 
              1700 | 
                  my $borrower1 = Koha::Patron->new({ | 
            
        
          | 1701 | 
                  firstname    => 'Kyle',  | 
          1701 | 
                  firstname    => 'Kyle',  | 
        
        
          | 1702 | 
                  surname      => 'Hall',  | 
          1702 | 
                  surname      => 'Hall',  | 
        
        
          | 1703 | 
                  categorycode => $patron_category->{categorycode}, | 
          1703 | 
                  categorycode => $patron_category->{categorycode}, | 
        
        
          | 1704 | 
                  branchcode   => $library2->{branchcode}, | 
          1704 | 
                  branchcode   => $library2->{branchcode}, | 
        
          
            
              | 1705 | 
                  })->store->borrowernumber;  | 
              1705 | 
                  })->store;  | 
            
        
          | 1706 | 
              my $borrowernumber2 = Koha::Patron->new({ | 
          1706 | 
              my $borrowernumber2 = Koha::Patron->new({ | 
        
        
          | 1707 | 
                  firstname    => 'Chelsea',  | 
          1707 | 
                  firstname    => 'Chelsea',  | 
        
        
          | 1708 | 
                  surname      => 'Hall',  | 
          1708 | 
                  surname      => 'Hall',  | 
        
  
    | 
      
            Lines 1726-1737
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1726 | 
                  branchcode   => $library2->{branchcode}, | 
          1726 | 
                  branchcode   => $library2->{branchcode}, | 
        
        
          | 1727 | 
              })->store->borrowernumber;  | 
          1727 | 
              })->store->borrowernumber;  | 
        
        
          | 1728 | 
           | 
          1728 | 
           | 
        
          
            
              | 1729 | 
                  my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed;  | 
              1729 | 
                  my $issue = AddIssue( $borrower1->unblessed, $item_1->barcode );  | 
            
            
              | 1730 | 
                  my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed;  | 
               | 
               | 
            
            
              | 1731 | 
               | 
            
            
              | 1732 | 
                  my $issue = AddIssue( $borrower1, $item_1->barcode );  | 
            
        
          | 1733 | 
           | 
          1730 | 
           | 
        
          
            
              | 1734 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1731 | 
                  my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1735 | 
              is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' );  | 
          1732 | 
              is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' );  | 
        
        
          | 1736 | 
           | 
          1733 | 
           | 
        
        
          | 1737 | 
              AddReserve(  | 
          1734 | 
              AddReserve(  | 
        
  
    | 
      
            Lines 1754-1764
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1754 | 
                  }  | 
          1751 | 
                  }  | 
        
        
          | 1755 | 
              );  | 
          1752 | 
              );  | 
        
        
          | 1756 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );  | 
          1753 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );  | 
        
          
            
              | 1757 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1754 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1758 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );  | 
          1755 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );  | 
        
        
          | 1759 | 
           | 
          1756 | 
           | 
        
        
          | 1760 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );  | 
          1757 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );  | 
        
          
            
              | 1761 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1758 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1762 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );  | 
          1759 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );  | 
        
        
          | 1763 | 
           | 
          1760 | 
           | 
        
        
          | 1764 | 
              Koha::CirculationRules->set_rules(  | 
          1761 | 
              Koha::CirculationRules->set_rules(  | 
        
  
    | 
      
            Lines 1772-1782
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1772 | 
                  }  | 
          1769 | 
                  }  | 
        
        
          | 1773 | 
              );  | 
          1770 | 
              );  | 
        
        
          | 1774 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );  | 
          1771 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );  | 
        
          
            
              | 1775 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1772 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1776 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );  | 
          1773 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );  | 
        
        
          | 1777 | 
           | 
          1774 | 
           | 
        
        
          | 1778 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );  | 
          1775 | 
              t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );  | 
        
          
            
              | 1779 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1776 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1780 | 
              is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );  | 
          1777 | 
              is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );  | 
        
        
          | 1781 | 
           | 
          1778 | 
           | 
        
        
          | 1782 | 
              AddReserve(  | 
          1779 | 
              AddReserve(  | 
        
  
    | 
      
            Lines 1788-1794
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1788 | 
                  }  | 
          1785 | 
                  }  | 
        
        
          | 1789 | 
              );  | 
          1786 | 
              );  | 
        
        
          | 1790 | 
           | 
          1787 | 
           | 
        
          
            
              | 1791 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1788 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1792 | 
              is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and one other item on record' );  | 
          1789 | 
              is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and one other item on record' );  | 
        
        
          | 1793 | 
           | 
          1790 | 
           | 
        
        
          | 1794 | 
              my $item_3= $builder->build_sample_item(  | 
          1791 | 
              my $item_3= $builder->build_sample_item(  | 
        
  
    | 
      
            Lines 1799-1805
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1799 | 
                  }  | 
          1796 | 
                  }  | 
        
        
          | 1800 | 
              );  | 
          1797 | 
              );  | 
        
        
          | 1801 | 
           | 
          1798 | 
           | 
        
          
            
              | 1802 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1799 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1803 | 
              is( $renewokay, 1, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );  | 
          1800 | 
              is( $renewokay, 1, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );  | 
        
        
          | 1804 | 
           | 
          1801 | 
           | 
        
        
          | 1805 | 
              Koha::CirculationRules->set_rules(  | 
          1802 | 
              Koha::CirculationRules->set_rules(  | 
        
  
    | 
      
            Lines 1813-1819
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1813 | 
                  }  | 
          1810 | 
                  }  | 
        
        
          | 1814 | 
              );  | 
          1811 | 
              );  | 
        
        
          | 1815 | 
           | 
          1812 | 
           | 
        
          
            
              | 1816 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1813 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1817 | 
              is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record, but only one of those holds can be filled when AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );  | 
          1814 | 
              is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record, but only one of those holds can be filled when AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );  | 
        
        
          | 1818 | 
           | 
          1815 | 
           | 
        
        
          | 1819 | 
              Koha::CirculationRules->set_rules(  | 
          1816 | 
              Koha::CirculationRules->set_rules(  | 
        
  
    | 
      
            Lines 1830-1836
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1830 | 
              # Setting item not checked out to be not for loan but holdable  | 
          1827 | 
              # Setting item not checked out to be not for loan but holdable  | 
        
        
          | 1831 | 
              $item_2->notforloan(-1)->store;  | 
          1828 | 
              $item_2->notforloan(-1)->store;  | 
        
        
          | 1832 | 
           | 
          1829 | 
           | 
        
          
            
              | 1833 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1830 | 
                  ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1834 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );  | 
          1831 | 
              is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );  | 
        
        
          | 1835 | 
           | 
          1832 | 
           | 
        
        
          | 1836 | 
              my $mock_circ = Test::MockModule->new("C4::Circulation"); | 
          1833 | 
              my $mock_circ = Test::MockModule->new("C4::Circulation"); | 
        
  
    | 
      
            Lines 1844-1850
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1844 | 
              # Two items total, one item available, one issued, two holds on record  | 
          1841 | 
              # Two items total, one item available, one issued, two holds on record  | 
        
        
          | 1845 | 
           | 
          1842 | 
           | 
        
        
          | 1846 | 
              warnings_are{ | 
          1843 | 
              warnings_are{ | 
        
          
            
              | 1847 | 
                     ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1844 | 
                     ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1848 | 
              } [], "CanItemBeReserved not called when there are more possible holds than available items";  | 
          1845 | 
              } [], "CanItemBeReserved not called when there are more possible holds than available items";  | 
        
        
          | 1849 | 
              is( $renewokay, 0, 'Borrower cannot renew when there are more holds than available items' );  | 
          1846 | 
              is( $renewokay, 0, 'Borrower cannot renew when there are more holds than available items' );  | 
        
        
          | 1850 | 
           | 
          1847 | 
           | 
        
  
    | 
      
            Lines 1868-1874
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1868 | 
              );  | 
          1865 | 
              );  | 
        
        
          | 1869 | 
           | 
          1866 | 
           | 
        
        
          | 1870 | 
              warnings_are{ | 
          1867 | 
              warnings_are{ | 
        
          
            
              | 1871 | 
                     ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );  | 
              1868 | 
                     ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );  | 
            
        
          | 1872 | 
              } ["Checked","Checked"], "CanItemBeReserved only called once per available item if it returns a negative result for all items for a borrower";  | 
          1869 | 
              } ["Checked","Checked"], "CanItemBeReserved only called once per available item if it returns a negative result for all items for a borrower";  | 
        
        
          | 1873 | 
              is( $renewokay, 0, 'Borrower cannot renew when there are more holds than available items' );  | 
          1870 | 
              is( $renewokay, 0, 'Borrower cannot renew when there are more holds than available items' );  | 
        
        
          | 1874 | 
           | 
          1871 | 
           | 
        
  
    | 
      
            Lines 1889-1905
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1889 | 
                  }  | 
          1886 | 
                  }  | 
        
        
          | 1890 | 
              );  | 
          1887 | 
              );  | 
        
        
          | 1891 | 
           | 
          1888 | 
           | 
        
          
            
              | 1892 | 
                  my $borrowernumber = Koha::Patron->new({ | 
              1889 | 
                  my $borrower = Koha::Patron->new({ | 
            
        
          | 1893 | 
                  firstname =>  'fn',  | 
          1890 | 
                  firstname =>  'fn',  | 
        
        
          | 1894 | 
                  surname => 'dn',  | 
          1891 | 
                  surname => 'dn',  | 
        
        
          | 1895 | 
                  categorycode => $patron_category->{categorycode}, | 
          1892 | 
                  categorycode => $patron_category->{categorycode}, | 
        
        
          | 1896 | 
                  branchcode => $branch,  | 
          1893 | 
                  branchcode => $branch,  | 
        
          
            
              | 1897 | 
                  })->store->borrowernumber;  | 
              1894 | 
                  })->store;  | 
            
            
              | 1898 | 
               | 
               | 
               | 
            
            
              | 1899 | 
                  my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;  | 
            
        
          | 1900 | 
           | 
          1895 | 
           | 
        
          
            
              | 1901 | 
                  my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); | 
              1896 | 
                  my $issue = AddIssue( $borrower->unblessed, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); | 
            
            
              | 1902 | 
                  my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber );  | 
              1897 | 
                  my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue );  | 
            
        
          | 1903 | 
              is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' );  | 
          1898 | 
              is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' );  | 
        
        
          | 1904 | 
              is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' );  | 
          1899 | 
              is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' );  | 
        
        
          | 1905 | 
          }  | 
          1900 | 
          }  | 
        
  
    | 
      
            Lines 1916-1939
          subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 1916 | 
                      itype            => $itemtype,  | 
          1911 | 
                      itype            => $itemtype,  | 
        
        
          | 1917 | 
                  }  | 
          1912 | 
                  }  | 
        
        
          | 1918 | 
              );  | 
          1913 | 
              );  | 
        
            
               | 
               | 
              1914 | 
                  my $patron = $builder->build_object( { class => 'Koha::Patrons',  value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 
            
        
          | 1919 | 
           | 
          1915 | 
           | 
        
          
            
              | 1920 | 
                  my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); | 
              1916 | 
                  my $issue = AddIssue( $patron->unblessed, $item->barcode );  | 
            
            
              | 1921 | 
               | 
               | 
               | 
            
            
              | 1922 | 
                  my $issue = AddIssue( $patron, $item->barcode );  | 
            
        
          | 1923 | 
              UpdateFine(  | 
          1917 | 
              UpdateFine(  | 
        
        
          | 1924 | 
                  { | 
          1918 | 
                  { | 
        
          
            
              | 1925 | 
                          issue_id       => $issue->id(),  | 
              1919 | 
                          issue_id       => $issue->id,  | 
            
        
          | 1926 | 
                      itemnumber     => $item->itemnumber,  | 
          1920 | 
                      itemnumber     => $item->itemnumber,  | 
        
          
            
              | 1927 | 
                          borrowernumber => $patron->{borrowernumber}, | 
              1921 | 
                          borrowernumber => $patron->borrowernumber,  | 
            
        
          | 1928 | 
                      amount         => 1,  | 
          1922 | 
                      amount         => 1,  | 
        
        
          | 1929 | 
                      type           => q{} | 
          1923 | 
                      type           => q{} | 
        
        
          | 1930 | 
                  }  | 
          1924 | 
                  }  | 
        
        
          | 1931 | 
              );  | 
          1925 | 
              );  | 
        
        
          | 1932 | 
              UpdateFine(  | 
          1926 | 
              UpdateFine(  | 
        
        
          | 1933 | 
                  { | 
          1927 | 
                  { | 
        
          
            
              | 1934 | 
                          issue_id       => $issue->id(),  | 
              1928 | 
                          issue_id       => $issue->id,  | 
            
        
          | 1935 | 
                      itemnumber     => $item->itemnumber,  | 
          1929 | 
                      itemnumber     => $item->itemnumber,  | 
        
          
            
              | 1936 | 
                          borrowernumber => $patron->{borrowernumber}, | 
              1930 | 
                          borrowernumber => $patron->borrowernumber,  | 
            
        
          | 1937 | 
                      amount         => 2,  | 
          1931 | 
                      amount         => 2,  | 
        
        
          | 1938 | 
                      type           => q{} | 
          1932 | 
                      type           => q{} | 
        
        
          | 1939 | 
                  }  | 
          1933 | 
                  }  | 
        
  
    | 
      
            Lines 2349-2357
          subtest 'MultipleReserves' => sub {
      
      
        Link Here
      
     | 
  
        
          | 2349 | 
                  categorycode => $patron_category->{categorycode}, | 
          2343 | 
                  categorycode => $patron_category->{categorycode}, | 
        
        
          | 2350 | 
                  branchcode => $branch,  | 
          2344 | 
                  branchcode => $branch,  | 
        
        
          | 2351 | 
              );  | 
          2345 | 
              );  | 
        
          
            
              | 2352 | 
                  my $renewing_borrowernumber = Koha::Patron->new(\%renewing_borrower_data)->store->borrowernumber;  | 
              2346 | 
                  my $patron = Koha::Patron->new(\%renewing_borrower_data)->store;  | 
            
            
              | 2353 | 
                  my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed;  | 
              2347 | 
                  my $issue = AddIssue( $patron->unblessed, $item_1->barcode);  | 
            
            
              | 2354 | 
                  my $issue = AddIssue( $renewing_borrower, $item_1->barcode);  | 
               | 
               | 
            
        
          | 2355 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
          2348 | 
              my $datedue = dt_from_string( $issue->date_due() );  | 
        
        
          | 2356 | 
              is (defined $issue->date_due(), 1, "item 1 checked out");  | 
          2349 | 
              is (defined $issue->date_due(), 1, "item 1 checked out");  | 
        
        
          | 2357 | 
              my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; | 
          2350 | 
              my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; | 
        
  
    | 
      
            Lines 2399-2405
          subtest 'MultipleReserves' => sub {
      
      
        Link Here
      
     | 
  
        
          | 2399 | 
              );  | 
          2392 | 
              );  | 
        
        
          | 2400 | 
           | 
          2393 | 
           | 
        
        
          | 2401 | 
              { | 
          2394 | 
              { | 
        
          
            
              | 2402 | 
                      my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);  | 
              2395 | 
                      my ( $renewokay, $error ) = CanBookBeRenewed($patron, $issue, 1);  | 
            
        
          | 2403 | 
                  is($renewokay, 0, 'Bug 17941 - should cover the case where 2 books are both reserved, so failing');  | 
          2396 | 
                  is($renewokay, 0, 'Bug 17941 - should cover the case where 2 books are both reserved, so failing');  | 
        
        
          | 2404 | 
              }  | 
          2397 | 
              }  | 
        
        
          | 2405 | 
           | 
          2398 | 
           | 
        
  
    | 
      
            Lines 2413-2419
          subtest 'MultipleReserves' => sub {
      
      
        Link Here
      
     | 
  
        
          | 2413 | 
              );  | 
          2406 | 
              );  | 
        
        
          | 2414 | 
           | 
          2407 | 
           | 
        
        
          | 2415 | 
              { | 
          2408 | 
              { | 
        
          
            
              | 2416 | 
                      my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);  | 
              2409 | 
                      my ( $renewokay, $error ) = CanBookBeRenewed($patron, $issue, 1);  | 
            
        
          | 2417 | 
                  is($renewokay, 1, 'Bug 17941 - should cover the case where 2 books are reserved, but a third one is available');  | 
          2410 | 
                  is($renewokay, 1, 'Bug 17941 - should cover the case where 2 books are reserved, but a third one is available');  | 
        
        
          | 2418 | 
              }  | 
          2411 | 
              }  | 
        
        
          | 2419 | 
          };  | 
          2412 | 
          };  | 
        
  
    | 
      
            Lines 3966-3972
          subtest 'Set waiting flag' => sub {
      
      
        Link Here
      
     | 
  
        
          | 3966 | 
              my $hold = Koha::Holds->find( $reserve_id );  | 
          3959 | 
              my $hold = Koha::Holds->find( $reserve_id );  | 
        
        
          | 3967 | 
              is( $hold->found, 'T', 'Hold is in transit' );  | 
          3960 | 
              is( $hold->found, 'T', 'Hold is in transit' );  | 
        
        
          | 3968 | 
           | 
          3961 | 
           | 
        
          
            
              | 3969 | 
                  my ( $status ) = CheckReserves($item->itemnumber);  | 
              3962 | 
                  my ( $status ) = CheckReserves($item);  | 
            
        
          | 3970 | 
              is( $status, 'Transferred', 'Hold is not waiting yet');  | 
          3963 | 
              is( $status, 'Transferred', 'Hold is not waiting yet');  | 
        
        
          | 3971 | 
           | 
          3964 | 
           | 
        
        
          | 3972 | 
              set_userenv( $library_2 );  | 
          3965 | 
              set_userenv( $library_2 );  | 
        
  
    | 
      
            Lines 3975-3981
          subtest 'Set waiting flag' => sub {
      
      
        Link Here
      
     | 
  
        
          | 3975 | 
              ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );  | 
          3968 | 
              ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id );  | 
        
        
          | 3976 | 
              $hold = Koha::Holds->find( $reserve_id );  | 
          3969 | 
              $hold = Koha::Holds->find( $reserve_id );  | 
        
        
          | 3977 | 
              is( $hold->found, 'W', 'Hold is waiting' );  | 
          3970 | 
              is( $hold->found, 'W', 'Hold is waiting' );  | 
        
          
            
              | 3978 | 
                  ( $status ) = CheckReserves($item->itemnumber);  | 
              3971 | 
                  ( $status ) = CheckReserves($item);  | 
            
        
          | 3979 | 
              is( $status, 'Waiting', 'Now the hold is waiting');  | 
          3972 | 
              is( $status, 'Waiting', 'Now the hold is waiting');  | 
        
        
          | 3980 | 
           | 
          3973 | 
           | 
        
        
          | 3981 | 
              #Bug 21944 - Waiting transfer checked in at branch other than pickup location  | 
          3974 | 
              #Bug 21944 - Waiting transfer checked in at branch other than pickup location  | 
        
  
    | 
      
            Lines 4160-4173
          subtest 'ItemsDeniedRenewal rules are checked' => sub {
      
      
        Link Here
      
     | 
  
        
          | 4160 | 
              my $mock_item_class = Test::MockModule->new("Koha::Item"); | 
          4153 | 
              my $mock_item_class = Test::MockModule->new("Koha::Item"); | 
        
        
          | 4161 | 
              $mock_item_class->mock( 'is_denied_renewal', sub { return 1; } ); | 
          4154 | 
              $mock_item_class->mock( 'is_denied_renewal', sub { return 1; } ); | 
        
        
          | 4162 | 
           | 
          4155 | 
           | 
        
          
            
              | 4163 | 
                  my ( $mayrenew, $error ) = CanBookBeRenewed( $idr_borrower->borrowernumber, $issue->itemnumber );  | 
              4156 | 
                  my ( $mayrenew, $error ) = CanBookBeRenewed( $idr_borrower, $issue );  | 
            
        
          | 4164 | 
              is( $mayrenew, 0, 'Renewal blocked when $item->is_denied_renewal returns true' );  | 
          4157 | 
              is( $mayrenew, 0, 'Renewal blocked when $item->is_denied_renewal returns true' );  | 
        
        
          | 4165 | 
              is( $error, 'item_denied_renewal', 'Renewal blocked when $item->is_denied_renewal returns true' );  | 
          4158 | 
              is( $error, 'item_denied_renewal', 'Renewal blocked when $item->is_denied_renewal returns true' );  | 
        
        
          | 4166 | 
           | 
          4159 | 
           | 
        
        
          | 4167 | 
              $mock_item_class->unmock( 'is_denied_renewal' );  | 
          4160 | 
              $mock_item_class->unmock( 'is_denied_renewal' );  | 
        
        
          | 4168 | 
              $mock_item_class->mock( 'is_denied_renewal', sub { return 0; } ); | 
          4161 | 
              $mock_item_class->mock( 'is_denied_renewal', sub { return 0; } ); | 
        
        
          | 4169 | 
           | 
          4162 | 
           | 
        
          
            
              | 4170 | 
                  ( $mayrenew, $error ) = CanBookBeRenewed( $idr_borrower->borrowernumber, $issue->itemnumber );  | 
              4163 | 
                  ( $mayrenew, $error ) = CanBookBeRenewed( $idr_borrower, $issue );  | 
            
        
          | 4171 | 
              is( $mayrenew, 1, 'Renewal allowed when $item->is_denied_renewal returns false' );  | 
          4164 | 
              is( $mayrenew, 1, 'Renewal allowed when $item->is_denied_renewal returns false' );  | 
        
        
          | 4172 | 
              is( $error, undef, 'Renewal allowed when $item->is_denied_renewal returns false' );  | 
          4165 | 
              is( $error, undef, 'Renewal allowed when $item->is_denied_renewal returns false' );  | 
        
        
          | 4173 | 
           | 
          4166 | 
           | 
        
  
    | 
      
            Lines 5654-5660
          subtest "GetSoonestRenewDate tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 5654 | 
              # Test 'exact time' setting for syspref NoRenewalBeforePrecision  | 
          5647 | 
              # Test 'exact time' setting for syspref NoRenewalBeforePrecision  | 
        
        
          | 5655 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' );  | 
          5648 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' );  | 
        
        
          | 5656 | 
              is(  | 
          5649 | 
              is(  | 
        
          
            
              | 5657 | 
                      GetSoonestRenewDate( $issue ),  | 
              5650 | 
                      GetSoonestRenewDate( $patron, $issue ),  | 
            
        
          | 5658 | 
                  $datedue->clone->add( days => -7 ),  | 
          5651 | 
                  $datedue->clone->add( days => -7 ),  | 
        
        
          | 5659 | 
                  'Bug 14395: Renewals permitted 7 days before due date, as expected'  | 
          5652 | 
                  'Bug 14395: Renewals permitted 7 days before due date, as expected'  | 
        
        
          | 5660 | 
              );  | 
          5653 | 
              );  | 
        
  
    | 
      
            Lines 5663-5669
          subtest "GetSoonestRenewDate tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 5663 | 
              # Test 'date' setting for syspref NoRenewalBeforePrecision  | 
          5656 | 
              # Test 'date' setting for syspref NoRenewalBeforePrecision  | 
        
        
          | 5664 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' );  | 
          5657 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' );  | 
        
        
          | 5665 | 
              is(  | 
          5658 | 
              is(  | 
        
          
            
              | 5666 | 
                      GetSoonestRenewDate( $issue ),  | 
              5659 | 
                      GetSoonestRenewDate( $patron, $issue ),  | 
            
        
          | 5667 | 
                  $datedue->clone->add( days => -7 )->truncate( to => 'day' ),  | 
          5660 | 
                  $datedue->clone->add( days => -7 )->truncate( to => 'day' ),  | 
        
        
          | 5668 | 
                  'Bug 14395: Renewals permitted 7 days before due date, as expected'  | 
          5661 | 
                  'Bug 14395: Renewals permitted 7 days before due date, as expected'  | 
        
        
          | 5669 | 
              );  | 
          5662 | 
              );  | 
        
  
    | 
      
            Lines 5680-5686
          subtest "GetSoonestRenewDate tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 5680 | 
              );  | 
          5673 | 
              );  | 
        
        
          | 5681 | 
           | 
          5674 | 
           | 
        
        
          | 5682 | 
              is(  | 
          5675 | 
              is(  | 
        
          
            
              | 5683 | 
                      GetSoonestRenewDate( $issue ),  | 
              5676 | 
                      GetSoonestRenewDate( $patron, $issue ),  | 
            
        
          | 5684 | 
                  dt_from_string,  | 
          5677 | 
                  dt_from_string,  | 
        
        
          | 5685 | 
                  'Checkouts without auto-renewal can be renewed immediately if no norenewalbefore'  | 
          5678 | 
                  'Checkouts without auto-renewal can be renewed immediately if no norenewalbefore'  | 
        
        
          | 5686 | 
              );  | 
          5679 | 
              );  | 
        
  
    | 
      
            Lines 5688-5700
          subtest "GetSoonestRenewDate tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 5688 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' );  | 
          5681 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' );  | 
        
        
          | 5689 | 
              $issue->auto_renew(1)->store;  | 
          5682 | 
              $issue->auto_renew(1)->store;  | 
        
        
          | 5690 | 
              is(  | 
          5683 | 
              is(  | 
        
          
            
              | 5691 | 
                      GetSoonestRenewDate( $issue ),  | 
              5684 | 
                      GetSoonestRenewDate( $patron, $issue ),  | 
            
        
          | 5692 | 
                  $datedue->clone->truncate( to => 'day' ),  | 
          5685 | 
                  $datedue->clone->truncate( to => 'day' ),  | 
        
        
          | 5693 | 
                  'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'  | 
          5686 | 
                  'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'  | 
        
        
          | 5694 | 
              );  | 
          5687 | 
              );  | 
        
        
          | 5695 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact' );  | 
          5688 | 
              t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact' );  | 
        
        
          | 5696 | 
              is(  | 
          5689 | 
              is(  | 
        
          
            
              | 5697 | 
                      GetSoonestRenewDate( $issue ),  | 
              5690 | 
                      GetSoonestRenewDate( $patron, $issue ),  | 
            
        
          | 5698 | 
                  $datedue,  | 
          5691 | 
                  $datedue,  | 
        
        
          | 5699 | 
                  'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'  | 
          5692 | 
                  'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'  | 
        
        
          | 5700 | 
              );  | 
          5693 | 
              );  | 
        
  
    | 
      
            Lines 5707-5713
          subtest "CanBookBeIssued + needsconfirmation message" => sub {
      
      
        Link Here
      
     | 
  
        
          | 5707 | 
              my $library = $builder->build_object( { class => 'Koha::Libraries' } ); | 
          5700 | 
              my $library = $builder->build_object( { class => 'Koha::Libraries' } ); | 
        
        
          | 5708 | 
              my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); | 
          5701 | 
              my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); | 
        
        
          | 5709 | 
              my $biblioitem = $builder->build_object({ class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber }}); | 
          5702 | 
              my $biblioitem = $builder->build_object({ class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber }}); | 
        
          
            
              | 5710 | 
                  my $item = $builder->build_object({ class => 'Koha::Items' , value => { biblionumber => $biblio->biblionumber }}); | 
              5703 | 
                  my $item = $builder->build_object({ class => 'Koha::Items' , value => { itype => $itemtype, biblionumber => $biblio->biblionumber }}); | 
            
        
          | 5711 | 
           | 
          5704 | 
           | 
        
        
          | 5712 | 
              my $hold = $builder->build_object({ class => 'Koha::Holds', value => { | 
          5705 | 
              my $hold = $builder->build_object({ class => 'Koha::Holds', value => { | 
        
        
          | 5713 | 
                  biblionumber => $item->biblionumber,  | 
          5706 | 
                  biblionumber => $item->biblionumber,  |