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

(-)a/t/db_dependent/Circulation.t (-77 / +104 lines)
Lines 420-426 subtest "GetIssuingCharges tests" => sub { Link Here
420
420
421
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
421
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
422
subtest "CanBookBeRenewed tests" => sub {
422
subtest "CanBookBeRenewed tests" => sub {
423
    plan tests => 105;
423
    plan tests => 104;
424
424
425
    C4::Context->set_preference('ItemsDeniedRenewal','');
425
    C4::Context->set_preference('ItemsDeniedRenewal','');
426
    # Generate test biblio
426
    # Generate test biblio
Lines 463-468 subtest "CanBookBeRenewed tests" => sub { Link Here
463
        surname => 'Renewal',
463
        surname => 'Renewal',
464
        categorycode => $patron_category->{categorycode},
464
        categorycode => $patron_category->{categorycode},
465
        branchcode => $branch,
465
        branchcode => $branch,
466
        autorenew_checkouts => 1
466
    );
467
    );
467
468
468
    my %reserving_borrower_data = (
469
    my %reserving_borrower_data = (
Lines 493-498 subtest "CanBookBeRenewed tests" => sub { Link Here
493
        categorycode => $patron_category->{categorycode},
494
        categorycode => $patron_category->{categorycode},
494
        branchcode => $branch,
495
        branchcode => $branch,
495
        dateexpiry => dt_from_string->subtract( months => 1 ),
496
        dateexpiry => dt_from_string->subtract( months => 1 ),
497
        autorenew_checkouts => 1,
496
    );
498
    );
497
499
498
    my $renewing_borrowernumber = Koha::Patron->new(\%renewing_borrower_data)->store->borrowernumber;
500
    my $renewing_borrowernumber = Koha::Patron->new(\%renewing_borrower_data)->store->borrowernumber;
Lines 719-724 subtest "CanBookBeRenewed tests" => sub { Link Here
719
    my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago);
721
    my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago);
720
    is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due);
722
    is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due);
721
723
724
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow');
725
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
726
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
727
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
728
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');
729
730
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
731
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
732
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');
733
    is( $error, 'overdue', "Correct error returned");
734
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
735
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');
736
    is( $error, 'overdue', "Correct error returned");
737
738
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
739
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
740
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
741
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
742
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');
743
    is( $error, 'overdue', "Correct error returned");
744
722
    my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
745
    my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
723
    C4::Overdues::UpdateFine(
746
    C4::Overdues::UpdateFine(
724
        {
747
        {
Lines 765-797 subtest "CanBookBeRenewed tests" => sub { Link Here
765
    is ($new_log_size, $old_log_size + 1, 'renew log successfully added');
788
    is ($new_log_size, $old_log_size + 1, 'renew log successfully added');
766
789
767
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
790
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
768
    is( $fines->count, 2, 'AddRenewal left both fines' );
791
    is( $fines->count, 1, 'AddRenewal left fine' );
769
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
792
    is( $fines->next->status, 'RENEWED', 'Fine on renewed item is closed out properly' );
770
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
771
    $fines->delete();
793
    $fines->delete();
772
794
773
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow');
774
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
775
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
776
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
777
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');
778
779
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
780
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
781
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');
782
    is( $error, 'overdue', "Correct error returned");
783
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
784
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');
785
    is( $error, 'overdue', "Correct error returned");
786
787
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
788
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
789
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
790
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
791
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');
792
    is( $error, 'overdue', "Correct error returned");
793
794
795
    my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );
795
    my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );
796
    my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );
796
    my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );
797
    AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef );
797
    AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef );
Lines 995-1001 subtest "CanBookBeRenewed tests" => sub { Link Here
995
            }
995
            }
996
        );
996
        );
997
        ( $renewokay, $error ) =
997
        ( $renewokay, $error ) =
998
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber );
998
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber, undef, 1 ); #$cron must be set for returing 'auto_to_soon'
999
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
999
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1000
        is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' );
1000
        is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' );
1001
1001
Lines 4102-4108 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
4102
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
4102
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
4103
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
4103
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
4104
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works");
4104
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works");
4105
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef);
4105
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef);
4106
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
4106
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
4107
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
4107
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
4108
};
4108
};
Lines 4697-4704 subtest 'Incremented fee tests' => sub { Link Here
4697
4697
4698
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4698
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4699
4699
4700
    my $library =
4700
    my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store;
4701
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4702
4701
4703
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4702
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4704
4703
Lines 4723-4737 subtest 'Incremented fee tests' => sub { Link Here
4723
4722
4724
    my $item = $builder->build_sample_item(
4723
    my $item = $builder->build_sample_item(
4725
        {
4724
        {
4726
            library  => $library->{branchcode},
4725
            library  => $library->id,
4727
            itype    => $itemtype->id,
4726
            itype    => $itemtype->id,
4728
        }
4727
        }
4729
    );
4728
    );
4730
4729
4731
    is( $itemtype->rentalcharge_daily+0,
4730
    is( $itemtype->rentalcharge_daily + 0,1, 'Daily rental charge stored and retreived correctly' );
4732
        1, 'Daily rental charge stored and retreived correctly' );
4731
    is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item" );
4733
    is( $item->effective_itemtype, $itemtype->id,
4734
        "Itemtype set correctly for item" );
4735
4732
4736
    my $now         = dt_from_string;
4733
    my $now         = dt_from_string;
4737
    my $dt_from     = $now->clone;
4734
    my $dt_from     = $now->clone;
Lines 4742-4755 subtest 'Incremented fee tests' => sub { Link Here
4742
    my $issue =
4739
    my $issue =
4743
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4740
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4744
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4741
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4745
    is( $accountline->amount+0, 7,
4742
    is(
4746
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4743
        $accountline->amount + 0,
4744
        7,
4745
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4747
    );
4746
    );
4748
    $accountline->delete();
4747
    $accountline->delete();
4749
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4748
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4750
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4749
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4751
    is( $accountline->amount+0, 6,
4750
    is(
4752
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4751
        $accountline->amount + 0,
4752
        6,
4753
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4753
    );
4754
    );
4754
    $accountline->delete();
4755
    $accountline->delete();
4755
    $issue->delete();
4756
    $issue->delete();
Lines 4759-4772 subtest 'Incremented fee tests' => sub { Link Here
4759
    $issue =
4760
    $issue =
4760
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4761
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4761
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4762
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4762
    is( $accountline->amount+0, 7,
4763
    is(
4763
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4764
        $accountline->amount + 0,
4765
        7,
4766
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4764
    );
4767
    );
4765
    $accountline->delete();
4768
    $accountline->delete();
4766
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4769
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4767
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4770
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4768
    is( $accountline->amount+0, 6,
4771
    is(
4769
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4772
        $accountline->amount + 0,
4773
        6,
4774
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4770
    );
4775
    );
4771
    $accountline->delete();
4776
    $accountline->delete();
4772
    $issue->delete();
4777
    $issue->delete();
Lines 4786-4822 subtest 'Incremented fee tests' => sub { Link Here
4786
    $issue =
4791
    $issue =
4787
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4792
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4788
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4793
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4789
    is( $accountline->amount+0, 6,
4794
    is(
4790
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4795
        $accountline->amount + 0,
4796
        6,
4797
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4791
    );
4798
    );
4792
    $accountline->delete();
4799
    $accountline->delete();
4793
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4800
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4794
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4801
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4795
    is( $accountline->amount+0, 5,
4802
    is(
4796
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4803
        $accountline->amount + 0,
4804
        5,
4805
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4797
    );
4806
    );
4798
    $accountline->delete();
4807
    $accountline->delete();
4799
    $issue->delete();
4808
    $issue->delete();
4800
4809
4801
    $itemtype->rentalcharge(2)->store;
4810
    $itemtype->rentalcharge(2)->store;
4802
    is( $itemtype->rentalcharge+0, 2,
4811
    is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' );
4803
        'Rental charge updated and retreived correctly' );
4804
    $issue =
4812
    $issue =
4805
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4813
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4806
    my $accountlines =
4814
    my $accountlines =
4807
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4815
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4808
    is( $accountlines->count, '2',
4816
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" );
4809
        "Fixed charge and accrued charge recorded distinctly" );
4810
    $accountlines->delete();
4817
    $accountlines->delete();
4811
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4818
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4812
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4819
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4813
    is( $accountlines->count, '2',
4820
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" );
4814
        "Fixed charge and accrued charge recorded distinctly, for renewal" );
4815
    $accountlines->delete();
4821
    $accountlines->delete();
4816
    $issue->delete();
4822
    $issue->delete();
4817
    $itemtype->rentalcharge(0)->store;
4823
    $itemtype->rentalcharge(0)->store;
4818
    is( $itemtype->rentalcharge+0, 0,
4824
    is( $itemtype->rentalcharge + 0, 0, 'Rental charge reset and retreived correctly' );
4819
        'Rental charge reset and retreived correctly' );
4820
4825
4821
    # Hourly
4826
    # Hourly
4822
    Koha::CirculationRules->set_rule(
4827
    Koha::CirculationRules->set_rule(
Lines 4830-4837 subtest 'Incremented fee tests' => sub { Link Here
4830
    );
4835
    );
4831
4836
4832
    $itemtype->rentalcharge_hourly('0.25')->store();
4837
    $itemtype->rentalcharge_hourly('0.25')->store();
4833
    is( $itemtype->rentalcharge_hourly,
4838
    is( $itemtype->rentalcharge_hourly, '0.25', 'Hourly rental charge stored and retreived correctly' );
4834
        '0.25', 'Hourly rental charge stored and retreived correctly' );
4835
4839
4836
    $dt_to       = $now->clone->add( hours => 168 );
4840
    $dt_to       = $now->clone->add( hours => 168 );
4837
    $dt_to_renew = $now->clone->add( hours => 312 );
4841
    $dt_to_renew = $now->clone->add( hours => 312 );
Lines 4840-4852 subtest 'Incremented fee tests' => sub { Link Here
4840
    $issue =
4844
    $issue =
4841
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4845
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4842
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4846
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4843
    is( $accountline->amount + 0, 42,
4847
    is(
4844
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" );
4848
        $accountline->amount + 0,
4849
        42,
4850
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)"
4851
    );
4845
    $accountline->delete();
4852
    $accountline->delete();
4846
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4853
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4847
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4854
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4848
    is( $accountline->amount + 0, 36,
4855
    is(
4849
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)" );
4856
        $accountline->amount + 0,
4857
        36,
4858
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)"
4859
    );
4850
    $accountline->delete();
4860
    $accountline->delete();
4851
    $issue->delete();
4861
    $issue->delete();
4852
4862
Lines 4854-4866 subtest 'Incremented fee tests' => sub { Link Here
4854
    $issue =
4864
    $issue =
4855
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4865
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4856
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4866
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4857
    is( $accountline->amount + 0, 36,
4867
    is(
4858
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" );
4868
        $accountline->amount + 0,
4869
        36,
4870
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)"
4871
    );
4859
    $accountline->delete();
4872
    $accountline->delete();
4860
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4873
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4861
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4874
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4862
    is( $accountline->amount + 0, 30,
4875
    is(
4863
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u" );
4876
        $accountline->amount + 0,
4877
        30,
4878
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u"
4879
    );
4864
    $accountline->delete();
4880
    $accountline->delete();
4865
    $issue->delete();
4881
    $issue->delete();
4866
4882
Lines 4868-4880 subtest 'Incremented fee tests' => sub { Link Here
4868
    $issue =
4884
    $issue =
4869
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4885
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4870
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4886
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4871
    is( $accountline->amount + 0, 42,
4887
    is(
4872
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" );
4888
        $accountline->amount + 0,
4889
        42,
4890
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u"
4891
    );
4873
    $accountline->delete();
4892
    $accountline->delete();
4874
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4893
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4875
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4894
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4876
    is( $accountline->amount + 0, 36,
4895
    is(
4877
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)" );
4896
        $accountline->amount + 0,
4897
        36,
4898
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)"
4899
    );
4878
    $accountline->delete();
4900
    $accountline->delete();
4879
    $issue->delete();
4901
    $issue->delete();
4880
    Time::Fake->reset;
4902
    Time::Fake->reset;
Lines 5521-5547 subtest 'AddIssue records staff who checked out item if appropriate' => sub { Link Here
5521
            value => { categorycode => $patron_category->{categorycode} }
5543
            value => { categorycode => $patron_category->{categorycode} }
5522
        }
5544
        }
5523
    );
5545
    );
5524
    my $item = $builder->build_sample_item(
5546
    my $item_1 = $builder->build_sample_item(
5525
        {
5547
        {
5526
            library  => $library->{branchcode}
5548
            library  => $library->{branchcode}
5527
        }
5549
        }
5528
    );
5550
    );
5529
5551
5530
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
5552
    my $item_2 = $builder->build_sample_item(
5553
        {
5554
            library  => $library->branchcode
5555
        }
5556
    );
5557
5558
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->borrowernumber } } );
5531
5559
5532
    my $dt_from = dt_from_string();
5560
    my $dt_from = dt_from_string();
5533
    my $dt_to   = dt_from_string()->add( days => 7 );
5561
    my $dt_to   = dt_from_string()->add( days => 7 );
5534
5562
5535
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5563
    my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from );
5536
5564
5537
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5565
    is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5538
5566
5539
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5567
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5540
5568
5541
    my $issue2 =
5569
    my $issue_2 =
5542
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5570
      AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from );
5543
5571
5544
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5572
    is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5545
};
5573
};
5546
5574
5547
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
5575
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
5548
- 

Return to bug 31676