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 4623-4630 subtest 'Incremented fee tests' => sub { Link Here
4623
4622
4624
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4623
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
4625
4624
4626
    my $library =
4625
    my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store;
4627
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4628
4626
4629
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4627
    $module->mock( 'userenv', sub { { branch => $library->id } } );
4630
4628
Lines 4649-4663 subtest 'Incremented fee tests' => sub { Link Here
4649
4647
4650
    my $item = $builder->build_sample_item(
4648
    my $item = $builder->build_sample_item(
4651
        {
4649
        {
4652
            library  => $library->{branchcode},
4650
            library  => $library->id,
4653
            itype    => $itemtype->id,
4651
            itype    => $itemtype->id,
4654
        }
4652
        }
4655
    );
4653
    );
4656
4654
4657
    is( $itemtype->rentalcharge_daily+0,
4655
    is( $itemtype->rentalcharge_daily + 0,1, 'Daily rental charge stored and retreived correctly' );
4658
        1, 'Daily rental charge stored and retreived correctly' );
4656
    is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item" );
4659
    is( $item->effective_itemtype, $itemtype->id,
4660
        "Itemtype set correctly for item" );
4661
4657
4662
    my $now         = dt_from_string;
4658
    my $now         = dt_from_string;
4663
    my $dt_from     = $now->clone;
4659
    my $dt_from     = $now->clone;
Lines 4668-4681 subtest 'Incremented fee tests' => sub { Link Here
4668
    my $issue =
4664
    my $issue =
4669
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4665
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4670
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4666
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4671
    is( $accountline->amount+0, 7,
4667
    is(
4672
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4668
        $accountline->amount + 0,
4669
        7,
4670
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
4673
    );
4671
    );
4674
    $accountline->delete();
4672
    $accountline->delete();
4675
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4673
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4676
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4674
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4677
    is( $accountline->amount+0, 6,
4675
    is(
4678
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4676
        $accountline->amount + 0,
4677
        6,
4678
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
4679
    );
4679
    );
4680
    $accountline->delete();
4680
    $accountline->delete();
4681
    $issue->delete();
4681
    $issue->delete();
Lines 4685-4698 subtest 'Incremented fee tests' => sub { Link Here
4685
    $issue =
4685
    $issue =
4686
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4686
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4687
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4687
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4688
    is( $accountline->amount+0, 7,
4688
    is(
4689
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4689
        $accountline->amount + 0,
4690
        7,
4691
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
4690
    );
4692
    );
4691
    $accountline->delete();
4693
    $accountline->delete();
4692
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4694
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4693
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4695
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4694
    is( $accountline->amount+0, 6,
4696
    is(
4695
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4697
        $accountline->amount + 0,
4698
        6,
4699
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
4696
    );
4700
    );
4697
    $accountline->delete();
4701
    $accountline->delete();
4698
    $issue->delete();
4702
    $issue->delete();
Lines 4712-4748 subtest 'Incremented fee tests' => sub { Link Here
4712
    $issue =
4716
    $issue =
4713
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4717
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4714
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4718
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4715
    is( $accountline->amount+0, 6,
4719
    is(
4716
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4720
        $accountline->amount + 0,
4721
        6,
4722
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
4717
    );
4723
    );
4718
    $accountline->delete();
4724
    $accountline->delete();
4719
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4725
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4720
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4726
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4721
    is( $accountline->amount+0, 5,
4727
    is(
4722
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4728
        $accountline->amount + 0,
4729
        5,
4730
        "Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
4723
    );
4731
    );
4724
    $accountline->delete();
4732
    $accountline->delete();
4725
    $issue->delete();
4733
    $issue->delete();
4726
4734
4727
    $itemtype->rentalcharge(2)->store;
4735
    $itemtype->rentalcharge(2)->store;
4728
    is( $itemtype->rentalcharge+0, 2,
4736
    is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' );
4729
        'Rental charge updated and retreived correctly' );
4730
    $issue =
4737
    $issue =
4731
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4738
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4732
    my $accountlines =
4739
    my $accountlines =
4733
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4740
      Koha::Account::Lines->search( { itemnumber => $item->id } );
4734
    is( $accountlines->count, '2',
4741
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" );
4735
        "Fixed charge and accrued charge recorded distinctly" );
4736
    $accountlines->delete();
4742
    $accountlines->delete();
4737
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4743
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4738
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4744
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
4739
    is( $accountlines->count, '2',
4745
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal" );
4740
        "Fixed charge and accrued charge recorded distinctly, for renewal" );
4741
    $accountlines->delete();
4746
    $accountlines->delete();
4742
    $issue->delete();
4747
    $issue->delete();
4743
    $itemtype->rentalcharge(0)->store;
4748
    $itemtype->rentalcharge(0)->store;
4744
    is( $itemtype->rentalcharge+0, 0,
4749
    is( $itemtype->rentalcharge + 0, 0, 'Rental charge reset and retreived correctly' );
4745
        'Rental charge reset and retreived correctly' );
4746
4750
4747
    # Hourly
4751
    # Hourly
4748
    Koha::CirculationRules->set_rule(
4752
    Koha::CirculationRules->set_rule(
Lines 4756-4763 subtest 'Incremented fee tests' => sub { Link Here
4756
    );
4760
    );
4757
4761
4758
    $itemtype->rentalcharge_hourly('0.25')->store();
4762
    $itemtype->rentalcharge_hourly('0.25')->store();
4759
    is( $itemtype->rentalcharge_hourly,
4763
    is( $itemtype->rentalcharge_hourly, '0.25', 'Hourly rental charge stored and retreived correctly' );
4760
        '0.25', 'Hourly rental charge stored and retreived correctly' );
4761
4764
4762
    $dt_to       = $now->clone->add( hours => 168 );
4765
    $dt_to       = $now->clone->add( hours => 168 );
4763
    $dt_to_renew = $now->clone->add( hours => 312 );
4766
    $dt_to_renew = $now->clone->add( hours => 312 );
Lines 4766-4778 subtest 'Incremented fee tests' => sub { Link Here
4766
    $issue =
4769
    $issue =
4767
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4770
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4768
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4771
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4769
    is( $accountline->amount + 0, 42,
4772
    is(
4770
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" );
4773
        $accountline->amount + 0,
4774
        42,
4775
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)"
4776
    );
4771
    $accountline->delete();
4777
    $accountline->delete();
4772
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4778
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4773
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4779
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4774
    is( $accountline->amount + 0, 36,
4780
    is(
4775
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)" );
4781
        $accountline->amount + 0,
4782
        36,
4783
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)"
4784
    );
4776
    $accountline->delete();
4785
    $accountline->delete();
4777
    $issue->delete();
4786
    $issue->delete();
4778
4787
Lines 4780-4792 subtest 'Incremented fee tests' => sub { Link Here
4780
    $issue =
4789
    $issue =
4781
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4790
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4782
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4791
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4783
    is( $accountline->amount + 0, 36,
4792
    is(
4784
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" );
4793
        $accountline->amount + 0,
4794
        36,
4795
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)"
4796
    );
4785
    $accountline->delete();
4797
    $accountline->delete();
4786
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4798
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
4787
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4799
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4788
    is( $accountline->amount + 0, 30,
4800
    is(
4789
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u" );
4801
        $accountline->amount + 0,
4802
        30,
4803
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u"
4804
    );
4790
    $accountline->delete();
4805
    $accountline->delete();
4791
    $issue->delete();
4806
    $issue->delete();
4792
4807
Lines 4794-4806 subtest 'Incremented fee tests' => sub { Link Here
4794
    $issue =
4809
    $issue =
4795
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4810
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4796
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4811
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4797
    is( $accountline->amount + 0, 42,
4812
    is(
4798
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" );
4813
        $accountline->amount + 0,
4814
        42,
4815
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u"
4816
    );
4799
    $accountline->delete();
4817
    $accountline->delete();
4800
    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 );
4801
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4819
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
4802
    is( $accountline->amount + 0, 36,
4820
    is(
4803
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)" );
4821
        $accountline->amount + 0,
4822
        36,
4823
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)"
4824
    );
4804
    $accountline->delete();
4825
    $accountline->delete();
4805
    $issue->delete();
4826
    $issue->delete();
4806
    Time::Fake->reset;
4827
    Time::Fake->reset;
Lines 5447-5473 subtest 'AddIssue records staff who checked out item if appropriate' => sub { Link Here
5447
            value => { categorycode => $patron_category->{categorycode} }
5468
            value => { categorycode => $patron_category->{categorycode} }
5448
        }
5469
        }
5449
    );
5470
    );
5450
    my $item = $builder->build_sample_item(
5471
    my $item_1 = $builder->build_sample_item(
5451
        {
5472
        {
5452
            library  => $library->{branchcode}
5473
            library  => $library->{branchcode}
5453
        }
5474
        }
5454
    );
5475
    );
5455
5476
5456
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
5477
    my $item_2 = $builder->build_sample_item(
5478
        {
5479
            library  => $library->branchcode
5480
        }
5481
    );
5482
5483
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->borrowernumber } } );
5457
5484
5458
    my $dt_from = dt_from_string();
5485
    my $dt_from = dt_from_string();
5459
    my $dt_to   = dt_from_string()->add( days => 7 );
5486
    my $dt_to   = dt_from_string()->add( days => 7 );
5460
5487
5461
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5488
    my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from );
5462
5489
5463
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5490
    is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
5464
5491
5465
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5492
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
5466
5493
5467
    my $issue2 =
5494
    my $issue_2 =
5468
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
5495
      AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from );
5469
5496
5470
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5497
    is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
5471
};
5498
};
5472
5499
5473
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
5500
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
5474
- 

Return to bug 31676