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

(-)a/t/db_dependent/Circulation.t (-79 / +105 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 719-724 subtest "CanBookBeRenewed tests" => sub { Link Here
719
    my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago);
719
    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);
720
    is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due);
721
721
722
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow');
723
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
724
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
725
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
726
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');
727
728
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
729
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
730
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');
731
    is( $error, 'overdue', "Correct error returned");
732
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
733
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');
734
    is( $error, 'overdue', "Correct error returned");
735
736
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
737
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
738
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
739
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
740
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');
741
    is( $error, 'overdue', "Correct error returned");
742
722
    my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
743
    my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
723
    C4::Overdues::UpdateFine(
744
    C4::Overdues::UpdateFine(
724
        {
745
        {
Lines 733-738 subtest "CanBookBeRenewed tests" => sub { Link Here
733
    # Make sure fine calculation isn't skipped when adding renewal
754
    # Make sure fine calculation isn't skipped when adding renewal
734
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
755
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
735
756
757
    # Calculate new due-date based on the present date not to incur
758
    # multiple fees
759
    t::lib::Mocks::mock_preference('RenewalPeriodBase', 'now');
760
736
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
761
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
737
    t::lib::Mocks::mock_userenv({ patron => $staff });
762
    t::lib::Mocks::mock_userenv({ patron => $staff });
738
763
Lines 765-797 subtest "CanBookBeRenewed tests" => sub { Link Here
765
    is ($new_log_size, $old_log_size + 1, 'renew log successfully added');
790
    is ($new_log_size, $old_log_size + 1, 'renew log successfully added');
766
791
767
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
792
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
768
    is( $fines->count, 2, 'AddRenewal left both fines' );
793
    is( $fines->count, 1, 'AddRenewal left fine' );
769
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
794
    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();
795
    $fines->delete();
772
796
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 );
797
    my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );
796
    my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );
798
    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 );
799
    AddIssue( $renewing_borrower,$item_7->barcode,Koha::DateUtils::output_pref({str=>$datedue6->date_due, dateformat =>'iso'}),0,$date, 0, undef );
Lines 800-808 subtest "CanBookBeRenewed tests" => sub { Link Here
800
    $new_log_size = Koha::ActionLogs->count( \%params_issue );
802
    $new_log_size = Koha::ActionLogs->count( \%params_issue );
801
    is ($new_log_size, $old_issue_log_size, 'renew not logged as issue when renewed via issuing');
803
    is ($new_log_size, $old_issue_log_size, 'renew not logged as issue when renewed via issuing');
802
804
803
    $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
804
    $fines->delete();
805
806
    $hold = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next;
805
    $hold = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next;
807
    $hold->cancel;
806
    $hold->cancel;
808
807
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
4101
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
4103
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
4102
    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");
4103
    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);
4104
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef);
4106
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
4105
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
4107
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
4106
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
4108
};
4107
};
Lines 4697-4704 subtest 'Incremented fee tests' => sub { Link Here
4697
4696
4698
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4697
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4699
4698
4700
    my $library =
4699
    my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store;
4701
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4702
4700
4703
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4701
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4704
4702
Lines 4723-4737 subtest 'Incremented fee tests' => sub { Link Here
4723
4721
4724
    my $item = $builder->build_sample_item(
4722
    my $item = $builder->build_sample_item(
4725
        {
4723
        {
4726
            library  => $library->{branchcode},
4724
            library  => $library->id,
4727
            itype    => $itemtype->id,
4725
            itype    => $itemtype->id,
4728
        }
4726
        }
4729
    );
4727
    );
4730
4728
4731
    is( $itemtype->rentalcharge_daily+0,
4729
    is( $itemtype->rentalcharge_daily + 0,1, 'Daily rental charge stored and retreived correctly' );
4732
        1, 'Daily rental charge stored and retreived correctly' );
4730
    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
4731
4736
    my $now         = dt_from_string;
4732
    my $now         = dt_from_string;
4737
    my $dt_from     = $now->clone;
4733
    my $dt_from     = $now->clone;
Lines 4742-4755 subtest 'Incremented fee tests' => sub { Link Here
4742
    my $issue =
4738
    my $issue =
4743
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4739
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4744
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4740
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4745
    is( $accountline->amount+0, 7,
4741
    is(
4746
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4742
        $accountline->amount + 0,
4743
        7,
4744
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4747
    );
4745
    );
4748
    $accountline->delete();
4746
    $accountline->delete();
4749
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4747
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4750
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4748
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4751
    is( $accountline->amount+0, 6,
4749
    is(
4752
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4750
        $accountline->amount + 0,
4751
        6,
4752
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4753
    );
4753
    );
4754
    $accountline->delete();
4754
    $accountline->delete();
4755
    $issue->delete();
4755
    $issue->delete();
Lines 4759-4772 subtest 'Incremented fee tests' => sub { Link Here
4759
    $issue =
4759
    $issue =
4760
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4760
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4761
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4761
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4762
    is( $accountline->amount+0, 7,
4762
    is(
4763
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4763
        $accountline->amount + 0,
4764
        7,
4765
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4764
    );
4766
    );
4765
    $accountline->delete();
4767
    $accountline->delete();
4766
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4768
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4767
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4769
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4768
    is( $accountline->amount+0, 6,
4770
    is(
4769
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4771
        $accountline->amount + 0,
4772
        6,
4773
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4770
    );
4774
    );
4771
    $accountline->delete();
4775
    $accountline->delete();
4772
    $issue->delete();
4776
    $issue->delete();
Lines 4786-4822 subtest 'Incremented fee tests' => sub { Link Here
4786
    $issue =
4790
    $issue =
4787
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4791
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4788
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4792
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4789
    is( $accountline->amount+0, 6,
4793
    is(
4790
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4794
        $accountline->amount + 0,
4795
        6,
4796
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4791
    );
4797
    );
4792
    $accountline->delete();
4798
    $accountline->delete();
4793
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4799
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4794
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4800
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4795
    is( $accountline->amount+0, 5,
4801
    is(
4796
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4802
        $accountline->amount + 0,
4803
        5,
4804
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4797
    );
4805
    );
4798
    $accountline->delete();
4806
    $accountline->delete();
4799
    $issue->delete();
4807
    $issue->delete();
4800
4808
4801
    $itemtype->rentalcharge(2)->store;
4809
    $itemtype->rentalcharge(2)->store;
4802
    is( $itemtype->rentalcharge+0, 2,
4810
    is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' );
4803
        'Rental charge updated and retreived correctly' );
4804
    $issue =
4811
    $issue =
4805
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4812
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4806
    my $accountlines =
4813
    my $accountlines =
4807
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4814
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4808
    is( $accountlines->count, '2',
4815
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" );
4809
        "Fixed charge and accrued charge recorded distinctly" );
4810
    $accountlines->delete();
4816
    $accountlines->delete();
4811
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4817
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4812
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4818
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4813
    is( $accountlines->count, '2',
4819
    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();
4820
    $accountlines->delete();
4816
    $issue->delete();
4821
    $issue->delete();
4817
    $itemtype->rentalcharge(0)->store;
4822
    $itemtype->rentalcharge(0)->store;
4818
    is( $itemtype->rentalcharge+0, 0,
4823
    is( $itemtype->rentalcharge + 0, 0, 'Rental charge reset and retreived correctly' );
4819
        'Rental charge reset and retreived correctly' );
4820
4824
4821
    # Hourly
4825
    # Hourly
4822
    Koha::CirculationRules->set_rule(
4826
    Koha::CirculationRules->set_rule(
Lines 4830-4837 subtest 'Incremented fee tests' => sub { Link Here
4830
    );
4834
    );
4831
4835
4832
    $itemtype->rentalcharge_hourly('0.25')->store();
4836
    $itemtype->rentalcharge_hourly('0.25')->store();
4833
    is( $itemtype->rentalcharge_hourly,
4837
    is( $itemtype->rentalcharge_hourly, '0.25', 'Hourly rental charge stored and retreived correctly' );
4834
        '0.25', 'Hourly rental charge stored and retreived correctly' );
4835
4838
4836
    $dt_to       = $now->clone->add( hours => 168 );
4839
    $dt_to       = $now->clone->add( hours => 168 );
4837
    $dt_to_renew = $now->clone->add( hours => 312 );
4840
    $dt_to_renew = $now->clone->add( hours => 312 );
Lines 4840-4852 subtest 'Incremented fee tests' => sub { Link Here
4840
    $issue =
4843
    $issue =
4841
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4844
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4842
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4845
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4843
    is( $accountline->amount + 0, 42,
4846
    is(
4844
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" );
4847
        $accountline->amount + 0,
4848
        42,
4849
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)"
4850
    );
4845
    $accountline->delete();
4851
    $accountline->delete();
4846
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4852
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4847
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4853
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4848
    is( $accountline->amount + 0, 36,
4854
    is(
4849
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)" );
4855
        $accountline->amount + 0,
4856
        36,
4857
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)"
4858
    );
4850
    $accountline->delete();
4859
    $accountline->delete();
4851
    $issue->delete();
4860
    $issue->delete();
4852
4861
Lines 4854-4866 subtest 'Incremented fee tests' => sub { Link Here
4854
    $issue =
4863
    $issue =
4855
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4864
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4856
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4865
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4857
    is( $accountline->amount + 0, 36,
4866
    is(
4858
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" );
4867
        $accountline->amount + 0,
4868
        36,
4869
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)"
4870
    );
4859
    $accountline->delete();
4871
    $accountline->delete();
4860
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4872
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4861
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4873
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4862
    is( $accountline->amount + 0, 30,
4874
    is(
4863
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u" );
4875
        $accountline->amount + 0,
4876
        30,
4877
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u"
4878
    );
4864
    $accountline->delete();
4879
    $accountline->delete();
4865
    $issue->delete();
4880
    $issue->delete();
4866
4881
Lines 4868-4880 subtest 'Incremented fee tests' => sub { Link Here
4868
    $issue =
4883
    $issue =
4869
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4884
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4870
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4885
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4871
    is( $accountline->amount + 0, 42,
4886
    is(
4872
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" );
4887
        $accountline->amount + 0,
4888
        42,
4889
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u"
4890
    );
4873
    $accountline->delete();
4891
    $accountline->delete();
4874
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4892
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4875
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4893
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4876
    is( $accountline->amount + 0, 36,
4894
    is(
4877
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)" );
4895
        $accountline->amount + 0,
4896
        36,
4897
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)"
4898
    );
4878
    $accountline->delete();
4899
    $accountline->delete();
4879
    $issue->delete();
4900
    $issue->delete();
4880
    Time::Fake->reset;
4901
    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} }
5542
            value => { categorycode => $patron_category->{categorycode} }
5522
        }
5543
        }
5523
    );
5544
    );
5524
    my $item = $builder->build_sample_item(
5545
    my $item_1 = $builder->build_sample_item(
5525
        {
5546
        {
5526
            library  => $library->{branchcode}
5547
            library  => $library->{branchcode}
5527
        }
5548
        }
5528
    );
5549
    );
5529
5550
5530
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
5551
    my $item_2 = $builder->build_sample_item(
5552
        {
5553
            library  => $library->branchcode
5554
        }
5555
    );
5556
5557
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->borrowernumber } } );
5531
5558
5532
    my $dt_from = dt_from_string();
5559
    my $dt_from = dt_from_string();
5533
    my $dt_to   = dt_from_string()->add( days => 7 );
5560
    my $dt_to   = dt_from_string()->add( days => 7 );
5534
5561
5535
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5562
    my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from );
5536
5563
5537
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5564
    is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5538
5565
5539
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5566
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5540
5567
5541
    my $issue2 =
5568
    my $issue_2 =
5542
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5569
      AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from );
5543
5570
5544
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5571
    is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5545
};
5572
};
5546
5573
5547
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
5574
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