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

(-)a/C4/Circulation.pm (-6 / +15 lines)
Lines 410-416 sub TooMany { Link Here
410
    my $child_types = Koha::ItemTypes->search({ parent_type => $type });
410
    my $child_types = Koha::ItemTypes->search({ parent_type => $type });
411
    # Find any children if we are a parent_type;
411
    # Find any children if we are a parent_type;
412
412
413
    # given branch, patron category, and item type, determine
413
    # given branch, patron category, item type, and checkout type, determine
414
    # applicable issuing rule
414
    # applicable issuing rule
415
415
416
    $parent_maxissueqty_rule = Koha::CirculationRules->get_effective_rule(
416
    $parent_maxissueqty_rule = Koha::CirculationRules->get_effective_rule(
Lines 1452-1457 sub AddIssue { Link Here
1452
                    patron    => $patron,
1452
                    patron    => $patron,
1453
                    library   => $library,
1453
                    library   => $library,
1454
                    item      => $item_object,
1454
                    item      => $item_object,
1455
                    onsite_checkout => $onsite_checkout,
1455
                    to_date   => $datedue,
1456
                    to_date   => $datedue,
1456
                }
1457
                }
1457
            );
1458
            );
Lines 1493-1498 sub AddIssue { Link Here
1493
                        categorycode => $borrower->{categorycode},
1494
                        categorycode => $borrower->{categorycode},
1494
                        itemtype     => $item_object->effective_itemtype,
1495
                        itemtype     => $item_object->effective_itemtype,
1495
                        branchcode   => $branchcode,
1496
                        branchcode   => $branchcode,
1497
                        onsite_checkout => $onsite_checkout,
1496
                        rule_name    => 'auto_renew'
1498
                        rule_name    => 'auto_renew'
1497
                    }
1499
                    }
1498
                );
1500
                );
Lines 2139-2145 sub AddReturn { Link Here
2139
2141
2140
        if ( $issue and $issue->is_overdue($return_date) ) {
2142
        if ( $issue and $issue->is_overdue($return_date) ) {
2141
        # fix fine days
2143
        # fix fine days
2142
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date );
2144
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, $issue->onsite_checkout, dt_from_string($issue->date_due), $return_date );
2143
            if ($reminder){
2145
            if ($reminder){
2144
                $messages->{'PrevDebarred'} = $debardate;
2146
                $messages->{'PrevDebarred'} = $debardate;
2145
            } else {
2147
            } else {
Lines 2357-2368 sub MarkIssueReturned { Link Here
2357
2359
2358
=head2 _debar_user_on_return
2360
=head2 _debar_user_on_return
2359
2361
2360
    _debar_user_on_return($borrower, $item, $datedue, $returndate);
2362
    _debar_user_on_return($borrower, $item, $onsite_checkout, $datedue, $returndate);
2361
2363
2362
C<$borrower> borrower hashref
2364
C<$borrower> borrower hashref
2363
2365
2364
C<$item> item hashref
2366
C<$item> item hashref
2365
2367
2368
C<$onsite_checkout> undef, 0 or 1
2369
2366
C<$datedue> date due DateTime object
2370
C<$datedue> date due DateTime object
2367
2371
2368
C<$returndate> DateTime object representing the return time
2372
C<$returndate> DateTime object representing the return time
Lines 2378-2384 to ease testing. Link Here
2378
=cut
2382
=cut
2379
2383
2380
sub _calculate_new_debar_dt {
2384
sub _calculate_new_debar_dt {
2381
    my ( $borrower, $item, $dt_due, $return_date ) = @_;
2385
    my ( $borrower, $item, $onsite_checkout, $dt_due, $return_date ) = @_;
2382
2386
2383
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2387
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2384
    my $circcontrol = C4::Context->preference('CircControl');
2388
    my $circcontrol = C4::Context->preference('CircControl');
Lines 2386-2391 sub _calculate_new_debar_dt { Link Here
2386
        {   categorycode => $borrower->{categorycode},
2390
        {   categorycode => $borrower->{categorycode},
2387
            itemtype     => $item->{itype},
2391
            itemtype     => $item->{itype},
2388
            branchcode   => $branchcode,
2392
            branchcode   => $branchcode,
2393
            onsite_checkout => $onsite_checkout,
2389
            rules => [
2394
            rules => [
2390
                'finedays',
2395
                'finedays',
2391
                'lengthunit',
2396
                'lengthunit',
Lines 2459-2469 sub _calculate_new_debar_dt { Link Here
2459
}
2464
}
2460
2465
2461
sub _debar_user_on_return {
2466
sub _debar_user_on_return {
2462
    my ( $borrower, $item, $dt_due, $return_date ) = @_;
2467
    my ( $borrower, $item, $onsite_checkout, $dt_due, $return_date ) = @_;
2463
2468
2464
    $return_date //= dt_from_string();
2469
    $return_date //= dt_from_string();
2465
2470
2466
    my $new_debar_dt = _calculate_new_debar_dt ($borrower, $item, $dt_due, $return_date);
2471
    my $new_debar_dt = _calculate_new_debar_dt ($borrower, $item, $onsite_checkout, $dt_due, $return_date);
2467
2472
2468
    return unless $new_debar_dt;
2473
    return unless $new_debar_dt;
2469
2474
Lines 3032-3037 sub AddRenewal { Link Here
3032
                patron    => $patron,
3037
                patron    => $patron,
3033
                library   => $circ_library,
3038
                library   => $circ_library,
3034
                item      => $item_object,
3039
                item      => $item_object,
3040
                onsite_checkout => $issue->onsite_checkout,
3035
                from_date => dt_from_string( $issue->date_due, 'sql' ),
3041
                from_date => dt_from_string( $issue->date_due, 'sql' ),
3036
                to_date   => dt_from_string($datedue),
3042
                to_date   => dt_from_string($datedue),
3037
            }
3043
            }
Lines 3046-3051 sub AddRenewal { Link Here
3046
                {   categorycode => $patron->categorycode,
3052
                {   categorycode => $patron->categorycode,
3047
                    itemtype     => $item_object->effective_itemtype,
3053
                    itemtype     => $item_object->effective_itemtype,
3048
                    branchcode   => $circ_library->branchcode,
3054
                    branchcode   => $circ_library->branchcode,
3055
                    onsite_checkout => $issue->onsite_checkout,
3049
                    rule_name    => 'unseen_renewals_allowed'
3056
                    rule_name    => 'unseen_renewals_allowed'
3050
                }
3057
                }
3051
            );
3058
            );
Lines 3178-3189 sub GetRenewCount { Link Here
3178
    $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'};
3185
    $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'};
3179
    # $item and $borrower should be calculated
3186
    # $item and $borrower should be calculated
3180
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
3187
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
3188
    my $onsite_checkout = $data->{'onsite_checkout'};
3181
3189
3182
    my $rules = Koha::CirculationRules->get_effective_rules(
3190
    my $rules = Koha::CirculationRules->get_effective_rules(
3183
        {
3191
        {
3184
            categorycode => $patron->categorycode,
3192
            categorycode => $patron->categorycode,
3185
            itemtype     => $item->effective_itemtype,
3193
            itemtype     => $item->effective_itemtype,
3186
            branchcode   => $branchcode,
3194
            branchcode   => $branchcode,
3195
            onsite_checkout => $onsite_checkout,
3187
            rules        => [ 'renewalsallowed', 'unseen_renewals_allowed' ]
3196
            rules        => [ 'renewalsallowed', 'unseen_renewals_allowed' ]
3188
        }
3197
        }
3189
    );
3198
    );
(-)a/Koha/Charges/Fees.pm (+25 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp qw( carp confess );
22
use Carp qw( carp confess );
23
23
24
use Koha::Calendar;
24
use Koha::Calendar;
25
use Koha::Checkouts;
25
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Exceptions;
27
use Koha::Exceptions;
27
28
Lines 38-43 Koha::Charges::Fees->new( Link Here
38
        patron    => $patron,
39
        patron    => $patron,
39
        library   => $library,
40
        library   => $library,
40
        item      => $item,
41
        item      => $item,
42
        [ onsite_checkout => $onsite_checkout, ]
41
        to_date   => $to_dt,
43
        to_date   => $to_dt,
42
        [ from_date => $from_dt, ]
44
        [ from_date => $from_dt, ]
43
    }
45
    }
Lines 57-62 sub new { Link Here
57
    Koha::Exceptions::MissingParameter->throw("Missing mandatory parameter: to_date")
59
    Koha::Exceptions::MissingParameter->throw("Missing mandatory parameter: to_date")
58
        unless $params->{to_date};
60
        unless $params->{to_date};
59
61
62
    $params->{onsite_checkout} = $params->{onsite_checkout} ? 1 : 0;
63
60
    Carp::confess("Key 'patron' is not a Koha::Patron object!")
64
    Carp::confess("Key 'patron' is not a Koha::Patron object!")
61
      unless $params->{patron}->isa('Koha::Patron');
65
      unless $params->{patron}->isa('Koha::Patron');
62
    Carp::confess("Key 'library' is not a Koha::Library object!")
66
    Carp::confess("Key 'library' is not a Koha::Library object!")
Lines 95-100 sub accumulate_rentalcharge { Link Here
95
            categorycode => $self->patron->categorycode,
99
            categorycode => $self->patron->categorycode,
96
            itemtype     => $itemtype->id,
100
            itemtype     => $itemtype->id,
97
            branchcode   => $self->library->id,
101
            branchcode   => $self->library->id,
102
            onsite_checkout => $self->onsite_checkout,
98
            rule_name    => 'lengthunit',
103
            rule_name    => 'lengthunit',
99
        }
104
        }
100
    );
105
    );
Lines 188-193 sub item { Link Here
188
    return $self->{item};
193
    return $self->{item};
189
}
194
}
190
195
196
=head3 onsite_checkout
197
198
my $item = $fees->onsite_checkout( $onsite_checkout );
199
200
=cut
201
202
sub onsite_checkout {
203
    my ( $self, $onsite_checkout ) = @_;
204
205
    if ( $onsite_checkout ) {
206
        my @valid_types = (0, 1);
207
        Carp::carp("Given 'onsite_checkout' is not valid! Valid are: " . join(', ', @valid_types))
208
          unless grep { $_ eq $onsite_checkout } @valid_types;
209
210
        $self->{onsite_checkout} = $onsite_checkout if $onsite_checkout;
211
    }
212
213
    return $self->{onsite_checkout};
214
}
215
191
=head3 to_date
216
=head3 to_date
192
217
193
my $to_date = $fees->to_date( $to_date );
218
my $to_date = $fees->to_date( $to_date );
(-)a/Koha/REST/V1/Checkouts.pm (+1 lines)
Lines 222-227 sub allows_renewal { Link Here
222
                categorycode => $checkout->patron->categorycode,
222
                categorycode => $checkout->patron->categorycode,
223
                itemtype     => $checkout->item->effective_itemtype,
223
                itemtype     => $checkout->item->effective_itemtype,
224
                branchcode   => $checkout->branchcode,
224
                branchcode   => $checkout->branchcode,
225
                onsite_checkout => $checkout->onsite_checkout,
225
                rule_name    => 'renewalsallowed',
226
                rule_name    => 'renewalsallowed',
226
            }
227
            }
227
        );
228
        );
(-)a/Koha/Template/Plugin/CirculationRules.pm (-2 / +6 lines)
Lines 24-38 use base qw( Template::Plugin ); Link Here
24
use Koha::CirculationRules;
24
use Koha::CirculationRules;
25
25
26
sub Get {
26
sub Get {
27
    my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
27
    my ( $self, $branchcode, $onsite_checkout, $categorycode, $itemtype, $rule_name ) = @_;
28
28
29
    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
29
    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
30
    $onsite_checkout = undef if $onsite_checkout eq {} or $onsite_checkout eq q{*};
30
    $categorycode = undef if $categorycode eq q{} or $categorycode eq q{*};
31
    $categorycode = undef if $categorycode eq q{} or $categorycode eq q{*};
31
    $itemtype     = undef if $itemtype eq q{}     or $itemtype  eq q{*};
32
    $itemtype     = undef if $itemtype eq q{}     or $itemtype  eq q{*};
32
33
33
    my $rule = Koha::CirculationRules->get_effective_rule(
34
    my $rule = Koha::CirculationRules->get_effective_rule(
34
        {
35
        {
35
            branchcode   => $branchcode,
36
            branchcode   => $branchcode,
37
            onsite_checkout => $onsite_checkout,
36
            categorycode => $categorycode,
38
            categorycode => $categorycode,
37
            itemtype     => $itemtype,
39
            itemtype     => $itemtype,
38
            rule_name    => $rule_name,
40
            rule_name    => $rule_name,
Lines 43-57 sub Get { Link Here
43
}
45
}
44
46
45
sub Search {
47
sub Search {
46
    my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
48
    my ( $self, $branchcode, $onsite_checkout, $categorycode, $itemtype,  $rule_name ) = @_;
47
49
48
    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
50
    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
51
    $onsite_checkout = undef if $onsite_checkout eq q{} or $onsite_checkout eq q{*};
49
    $categorycode = undef if $categorycode eq q{} or $categorycode eq q{*};
52
    $categorycode = undef if $categorycode eq q{} or $categorycode eq q{*};
50
    $itemtype     = undef if $itemtype eq q{}     or $itemtype eq q{*};
53
    $itemtype     = undef if $itemtype eq q{}     or $itemtype eq q{*};
51
54
52
    my $rule = Koha::CirculationRules->search(
55
    my $rule = Koha::CirculationRules->search(
53
        {
56
        {
54
            branchcode   => $branchcode,
57
            branchcode   => $branchcode,
58
            onsite_checkout => $onsite_checkout,
55
            categorycode => $categorycode,
59
            categorycode => $categorycode,
56
            itemtype     => $itemtype,
60
            itemtype     => $itemtype,
57
            rule_name    => $rule_name,
61
            rule_name    => $rule_name,
(-)a/api/v1/swagger/definitions/circ-rule-kind.json (-1 / +1 lines)
Lines 6-12 Link Here
6
      "type": "array",
6
      "type": "array",
7
      "items": {
7
      "items": {
8
        "type": "string",
8
        "type": "string",
9
        "enum": [ "branchcode", "categorycode", "itemtype" ]
9
        "enum": [ "branchcode", "onsite_checkout", "categorycode", "itemtype" ]
10
      }
10
      }
11
    }
11
    }
12
  },
12
  },
(-)a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t (-2 / +2 lines)
Lines 130-136 subtest "suspension_chargeperiod" => sub { Link Here
130
130
131
    my $last_year = dt_from_string->clone->subtract( years => 1 );
131
    my $last_year = dt_from_string->clone->subtract( years => 1 );
132
    my $today = dt_from_string;
132
    my $today = dt_from_string;
133
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
133
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, undef, $last_year, $today );
134
    is( $new_debar_dt->truncate( to => 'day' ),
134
    is( $new_debar_dt->truncate( to => 'day' ),
135
        $today->clone->add( days => 365 / 15 * 7 )->truncate( to => 'day' ) );
135
        $today->clone->add( days => 365 / 15 * 7 )->truncate( to => 'day' ) );
136
136
Lines 157-163 subtest "maxsuspensiondays" => sub { Link Here
157
157
158
    my $last_year = dt_from_string->clone->subtract( years => 1 );
158
    my $last_year = dt_from_string->clone->subtract( years => 1 );
159
    my $today = dt_from_string;
159
    my $today = dt_from_string;
160
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
160
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, undef, $last_year, $today );
161
    is( $new_debar_dt->truncate( to => 'day' ),
161
    is( $new_debar_dt->truncate( to => 'day' ),
162
        $today->clone->add( days => 333 )->truncate( to => 'day' ) );
162
        $today->clone->add( days => 333 )->truncate( to => 'day' ) );
163
};
163
};
(-)a/t/db_dependent/Koha/Charges/Fees.t (+2 lines)
Lines 29-34 use t::lib::Dates; Link Here
29
29
30
use Time::Fake;
30
use Time::Fake;
31
use C4::Calendar;
31
use C4::Calendar;
32
use Koha::Checkouts;
32
use Koha::DateUtils qw(dt_from_string);
33
use Koha::DateUtils qw(dt_from_string);
33
34
34
BEGIN {
35
BEGIN {
Lines 406-411 subtest 'accumulate_rentalcharge tests' => sub { Link Here
406
            patron    => $patron,
407
            patron    => $patron,
407
            library   => $library,
408
            library   => $library,
408
            item      => $item,
409
            item      => $item,
410
            onsite_checkout => 0,
409
            to_date   => $dt_to,
411
            to_date   => $dt_to,
410
            from_date => $dt_from,
412
            from_date => $dt_from,
411
        }
413
        }
(-)a/t/db_dependent/Koha/IssuingRules.t (-8 / +40 lines)
Lines 25-30 use Test::Exception; Link Here
25
25
26
use Benchmark;
26
use Benchmark;
27
27
28
use Koha::Checkouts;
28
use Koha::CirculationRules;
29
use Koha::CirculationRules;
29
30
30
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
Lines 41-46 subtest 'get_effective_issuing_rule' => sub { Link Here
41
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
42
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
42
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
43
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
43
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
44
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
45
    my $onsite_checkout = 0;
44
46
45
    subtest 'Call with undefined values' => sub {
47
    subtest 'Call with undefined values' => sub {
46
        plan tests => 5;
48
        plan tests => 5;
Lines 54-59 subtest 'get_effective_issuing_rule' => sub { Link Here
54
            branchcode   => undef,
56
            branchcode   => undef,
55
            categorycode => undef,
57
            categorycode => undef,
56
            itemtype     => undef,
58
            itemtype     => undef,
59
            onsite_checkout => undef,
57
            rule_name    => 'fine',
60
            rule_name    => 'fine',
58
            rule_value   => 1,
61
            rule_value   => 1,
59
        });
62
        });
Lines 67-72 subtest 'get_effective_issuing_rule' => sub { Link Here
67
                    branchcode   => undef,
70
                    branchcode   => undef,
68
                    categorycode => undef,
71
                    categorycode => undef,
69
                    itemtype     => undef,
72
                    itemtype     => undef,
73
                    onsite_checkout => undef,
70
                    rule_name    => 'fine',
74
                    rule_name    => 'fine',
71
                    rule_value   => 2,
75
                    rule_value   => 2,
72
                }
76
                }
Lines 77-82 subtest 'get_effective_issuing_rule' => sub { Link Here
77
            branchcode   => undef,
81
            branchcode   => undef,
78
            categorycode => undef,
82
            categorycode => undef,
79
            itemtype     => undef,
83
            itemtype     => undef,
84
            onsite_checkout => undef,
80
            rule_name    => 'fine',
85
            rule_name    => 'fine',
81
        });
86
        });
82
        _is_row_match(
87
        _is_row_match(
Lines 85-90 subtest 'get_effective_issuing_rule' => sub { Link Here
85
                branchcode   => undef,
90
                branchcode   => undef,
86
                categorycode => undef,
91
                categorycode => undef,
87
                itemtype     => undef,
92
                itemtype     => undef,
93
                onsite_checkout => undef,
88
                rule_name    => 'fine',
94
                rule_name    => 'fine',
89
                rule_value   => 2,
95
                rule_value   => 2,
90
            },
96
            },
Lines 95-125 subtest 'get_effective_issuing_rule' => sub { Link Here
95
    };
101
    };
96
102
97
    subtest 'Performance' => sub {
103
    subtest 'Performance' => sub {
98
        plan tests => 4;
104
        plan tests => 5;
99
105
100
        my $worst_case = timethis(500,
106
        my $worst_case = timethis(500,
101
                    sub { Koha::CirculationRules->get_effective_rule({
107
                    sub { Koha::CirculationRules->get_effective_rule({
102
                            branchcode   => 'nonexistent',
108
                            branchcode   => 'nonexistent',
103
                            categorycode => 'nonexistent',
109
                            categorycode => 'nonexistent',
104
                            itemtype     => 'nonexistent',
110
                            itemtype     => 'nonexistent',
111
                            onsite_checkout => 'nonexistent',
105
                            rule_name    => 'nonexistent',
112
                            rule_name    => 'nonexistent',
106
                        });
113
                        });
107
                    }
114
                    }
108
                );
115
                );
109
        my $mid_case = timethis(500,
116
        my $mid_case1 = timethis(500,
110
                    sub { Koha::CirculationRules->get_effective_rule({
117
                    sub { Koha::CirculationRules->get_effective_rule({
111
                            branchcode   => $branchcode,
118
                            branchcode   => $branchcode,
112
                            categorycode => 'nonexistent',
119
                            categorycode => 'nonexistent',
113
                            itemtype     => 'nonexistent',
120
                            itemtype     => 'nonexistent',
121
                            onsite_checkout => 'nonexistent',
114
                            rule_name    => 'nonexistent',
122
                            rule_name    => 'nonexistent',
115
                        });
123
                        });
116
                    }
124
                    }
117
                );
125
                );
118
        my $sec_best_case = timethis(500,
126
        my $mid_case2 = timethis(500,
119
                    sub { Koha::CirculationRules->get_effective_rule({
127
                    sub { Koha::CirculationRules->get_effective_rule({
120
                            branchcode   => $branchcode,
128
                            branchcode   => $branchcode,
121
                            categorycode => $categorycode,
129
                            categorycode => $categorycode,
122
                            itemtype     => 'nonexistent',
130
                            itemtype     => 'nonexistent',
131
                            onsite_checkout => 'nonexistent',
132
                            rule_name    => 'nonexistent',
133
                        });
134
                    }
135
                );
136
        my $mid_case3 = timethis(500,
137
                    sub { Koha::CirculationRules->get_effective_rule({
138
                            branchcode   => $branchcode,
139
                            categorycode => $categorycode,
140
                            itemtype     => $itemtype,
141
                            onsite_checkout => 'nonexistent',
123
                            rule_name    => 'nonexistent',
142
                            rule_name    => 'nonexistent',
124
                        });
143
                        });
125
                    }
144
                    }
Lines 129-134 subtest 'get_effective_issuing_rule' => sub { Link Here
129
                            branchcode   => $branchcode,
148
                            branchcode   => $branchcode,
130
                            categorycode => $categorycode,
149
                            categorycode => $categorycode,
131
                            itemtype     => $itemtype,
150
                            itemtype     => $itemtype,
151
                            onsite_checkout => $onsite_checkout,
132
                            rule_name    => 'nonexistent',
152
                            rule_name    => 'nonexistent',
133
                        });
153
                        });
134
                    }
154
                    }
Lines 136-146 subtest 'get_effective_issuing_rule' => sub { Link Here
136
        ok($worst_case, 'In worst case, get_effective_issuing_rule finds matching'
156
        ok($worst_case, 'In worst case, get_effective_issuing_rule finds matching'
137
           .' rule '.sprintf('%.2f', $worst_case->iters/$worst_case->cpu_a)
157
           .' rule '.sprintf('%.2f', $worst_case->iters/$worst_case->cpu_a)
138
           .' times per second.');
158
           .' times per second.');
139
        ok($mid_case, 'In mid case, get_effective_issuing_rule finds matching'
159
        ok($mid_case1, 'In mid case 1, get_effective_issuing_rule finds matching'
140
           .' rule '.sprintf('%.2f', $mid_case->iters/$mid_case->cpu_a)
160
           .' rule '.sprintf('%.2f', $mid_case1->iters/$mid_case1->cpu_a)
161
           .' times per second.');
162
        ok($mid_case2, 'In mid case 2, get_effective_issuing_rule finds matching'
163
           .' rule '.sprintf('%.2f', $mid_case2->iters/$mid_case2->cpu_a)
141
           .' times per second.');
164
           .' times per second.');
142
        ok($sec_best_case, 'In second best case, get_effective_issuing_rule finds matching'
165
        ok($mid_case3, 'In mid case 3, get_effective_issuing_rule finds matching'
143
           .' rule '.sprintf('%.2f', $sec_best_case->iters/$sec_best_case->cpu_a)
166
           .' rule '.sprintf('%.2f', $mid_case3->iters/$mid_case3->cpu_a)
144
           .' times per second.');
167
           .' times per second.');
145
        ok($best_case, 'In best case, get_effective_issuing_rule finds matching'
168
        ok($best_case, 'In best case, get_effective_issuing_rule finds matching'
146
           .' rule '.sprintf('%.2f', $best_case->iters/$best_case->cpu_a)
169
           .' rule '.sprintf('%.2f', $best_case->iters/$best_case->cpu_a)
Lines 304-309 subtest 'clone' => sub { Link Here
304
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
327
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
305
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
328
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
306
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
329
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
330
    my $onsite_checkout = 0;
307
331
308
    subtest 'Clone multiple rules' => sub {
332
    subtest 'Clone multiple rules' => sub {
309
        plan tests => 4;
333
        plan tests => 4;
Lines 314-319 subtest 'clone' => sub { Link Here
314
            branchcode   => undef,
338
            branchcode   => undef,
315
            categorycode => $categorycode,
339
            categorycode => $categorycode,
316
            itemtype     => $itemtype,
340
            itemtype     => $itemtype,
341
            onsite_checkout => $onsite_checkout,
317
            rule_name    => 'fine',
342
            rule_name    => 'fine',
318
            rule_value   => 5,
343
            rule_value   => 5,
319
        })->store;
344
        })->store;
Lines 322-327 subtest 'clone' => sub { Link Here
322
            branchcode   => undef,
347
            branchcode   => undef,
323
            categorycode => $categorycode,
348
            categorycode => $categorycode,
324
            itemtype     => $itemtype,
349
            itemtype     => $itemtype,
350
            onsite_checkout => $onsite_checkout,
325
            rule_name    => 'lengthunit',
351
            rule_name    => 'lengthunit',
326
            rule_value   => 'days',
352
            rule_value   => 'days',
327
        })->store;
353
        })->store;
Lines 332-343 subtest 'clone' => sub { Link Here
332
            branchcode   => $branchcode,
358
            branchcode   => $branchcode,
333
            categorycode => $categorycode,
359
            categorycode => $categorycode,
334
            itemtype     => $itemtype,
360
            itemtype     => $itemtype,
361
            onsite_checkout => $onsite_checkout,
335
            rule_name    => 'fine',
362
            rule_name    => 'fine',
336
        });
363
        });
337
        my $rule_lengthunit = Koha::CirculationRules->get_effective_rule({
364
        my $rule_lengthunit = Koha::CirculationRules->get_effective_rule({
338
            branchcode   => $branchcode,
365
            branchcode   => $branchcode,
339
            categorycode => $categorycode,
366
            categorycode => $categorycode,
340
            itemtype     => $itemtype,
367
            itemtype     => $itemtype,
368
            onsite_checkout => $onsite_checkout,
341
            rule_name    => 'lengthunit',
369
            rule_name    => 'lengthunit',
342
        });
370
        });
343
371
Lines 347-352 subtest 'clone' => sub { Link Here
347
                branchcode   => $branchcode,
375
                branchcode   => $branchcode,
348
                categorycode => $categorycode,
376
                categorycode => $categorycode,
349
                itemtype     => $itemtype,
377
                itemtype     => $itemtype,
378
                onsite_checkout => $onsite_checkout,
350
                rule_name    => 'fine',
379
                rule_name    => 'fine',
351
                rule_value   => 5,
380
                rule_value   => 5,
352
            },
381
            },
Lines 359-364 subtest 'clone' => sub { Link Here
359
                branchcode   => $branchcode,
388
                branchcode   => $branchcode,
360
                categorycode => $categorycode,
389
                categorycode => $categorycode,
361
                itemtype     => $itemtype,
390
                itemtype     => $itemtype,
391
                onsite_checkout => $onsite_checkout,
362
                rule_name    => 'lengthunit',
392
                rule_name    => 'lengthunit',
363
                rule_value   => 'days',
393
                rule_value   => 'days',
364
            },
394
            },
Lines 377-382 subtest 'clone' => sub { Link Here
377
            branchcode   => undef,
407
            branchcode   => undef,
378
            categorycode => $categorycode,
408
            categorycode => $categorycode,
379
            itemtype     => $itemtype,
409
            itemtype     => $itemtype,
410
            onsite_checkout => $onsite_checkout,
380
            rule_name    => 'fine',
411
            rule_name    => 'fine',
381
            rule_value   => 5,
412
            rule_value   => 5,
382
        })->store;
413
        })->store;
Lines 388-393 subtest 'clone' => sub { Link Here
388
            branchcode   => $branchcode,
419
            branchcode   => $branchcode,
389
            categorycode => $categorycode,
420
            categorycode => $categorycode,
390
            itemtype     => $itemtype,
421
            itemtype     => $itemtype,
422
            onsite_checkout => $onsite_checkout,
391
            rule_name    => 'fine',
423
            rule_name    => 'fine',
392
        });
424
        });
393
425
Lines 397-402 subtest 'clone' => sub { Link Here
397
                branchcode   => $branchcode,
429
                branchcode   => $branchcode,
398
                categorycode => $categorycode,
430
                categorycode => $categorycode,
399
                itemtype     => $itemtype,
431
                itemtype     => $itemtype,
432
                onsite_checkout => $onsite_checkout,
400
                rule_name    => 'fine',
433
                rule_name    => 'fine',
401
                rule_value   => '5',
434
                rule_value   => '5',
402
            },
435
            },
403
- 

Return to bug 26814