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

(-)a/Koha/CirculationRule.pm (+10 lines)
Lines 71-76 sub item_type { Link Here
71
    return $self->{item_type};
71
    return $self->{item_type};
72
}
72
}
73
73
74
=head3 priority
75
76
=cut
77
78
sub priority {
79
    my ($self) = @_;
80
81
    return $self->has_priority;
82
}
83
74
=head3 clone
84
=head3 clone
75
85
76
Clone a circulation rule to another branch
86
Clone a circulation rule to another branch
(-)a/Koha/CirculationRules.pm (-9 / +21 lines)
Lines 63-71 our $RULE_KINDS = { Link Here
63
    max_holds => {
63
    max_holds => {
64
        scope => [ 'branchcode', 'categorycode' ],
64
        scope => [ 'branchcode', 'categorycode' ],
65
    },
65
    },
66
    has_priority => {
67
	scope => [ 'branchcode', 'categorycode' ],
68
    },
69
    holdallowed => {
66
    holdallowed => {
70
        scope => [ 'branchcode', 'itemtype' ],
67
        scope => [ 'branchcode', 'itemtype' ],
71
        can_be_blank => 0,
68
        can_be_blank => 0,
Lines 254-268 sub get_effective_rule { Link Here
254
    }
251
    }
255
252
256
    my $order_by = $params->{order_by}
253
    my $order_by = $params->{order_by}
257
      // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] };
254
      // { -desc => [ 'has_priority', 'branchcode', 'categorycode', 'itemtype' ] };
258
255
259
    my $search_params;
256
    my $search_params;
260
    $search_params->{rule_name} = $rule_name;
257
    $search_params->{rule_name} = $rule_name;
261
262
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
258
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
263
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
259
    $search_params->{has_priority} = 1;
264
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
265
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
266
260
267
    my $rule = $self->search(
261
    my $rule = $self->search(
268
        $search_params,
262
        $search_params,
Lines 272-277 sub get_effective_rule { Link Here
272
        }
266
        }
273
    )->single;
267
    )->single;
274
268
269
    return $rule if defined $rule;
270
271
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype,     undef ] : undef;
272
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
273
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
274
275
    $rule = $self->search(
276
        $search_params,
277
        {
278
            order_by => $order_by,
279
            rows => 1,
280
        }
281
    )->single;
282
275
    return $rule;
283
    return $rule;
276
}
284
}
277
285
Lines 376-381 sub set_rule { Link Here
376
    my $branchcode   = $params->{branchcode};
384
    my $branchcode   = $params->{branchcode};
377
    my $categorycode = $params->{categorycode};
385
    my $categorycode = $params->{categorycode};
378
    my $itemtype     = $params->{itemtype};
386
    my $itemtype     = $params->{itemtype};
387
    my $has_priority = $params->{has_priority};
379
    my $rule_name    = $params->{rule_name};
388
    my $rule_name    = $params->{rule_name};
380
    my $rule_value   = $params->{rule_value};
389
    my $rule_value   = $params->{rule_value};
381
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
390
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
Lines 390-395 sub set_rule { Link Here
390
            branchcode   => $branchcode,
399
            branchcode   => $branchcode,
391
            categorycode => $categorycode,
400
            categorycode => $categorycode,
392
            itemtype     => $itemtype,
401
            itemtype     => $itemtype,
402
            has_priority => $has_priority,
393
        }
403
        }
394
    )->next();
404
    )->next();
395
405
Lines 409-414 sub set_rule { Link Here
409
                    branchcode   => $branchcode,
419
                    branchcode   => $branchcode,
410
                    categorycode => $categorycode,
420
                    categorycode => $categorycode,
411
                    itemtype     => $itemtype,
421
                    itemtype     => $itemtype,
422
                    has_priority => $has_priority,
412
                    rule_name    => $rule_name,
423
                    rule_name    => $rule_name,
413
                    rule_value   => $rule_value,
424
                    rule_value   => $rule_value,
414
                }
425
                }
Lines 436-442 sub set_rules { Link Here
436
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
447
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
437
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
448
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
438
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
449
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
439
    my $rules        = $params->{rules};
450
    $set_params{has_priority} = $params->{has_priority} if exists $params->{has_priority};
451
    my $rules = $params->{rules};
440
452
441
    my $rule_objects = [];
453
    my $rule_objects = [];
442
    while ( my ( $rule_name, $rule_value ) = each %$rules ) {
454
    while ( my ( $rule_name, $rule_value ) = each %$rules ) {
(-)a/Koha/Schema/Result/CirculationRule.pm (-2 / +9 lines)
Lines 50-55 __PACKAGE__->table("circulation_rules"); Link Here
50
  is_nullable: 1
50
  is_nullable: 1
51
  size: 10
51
  size: 10
52
52
53
=head2 has_priority
54
55
  data_type: 'integer'
56
  is_nullable: 1
57
53
=head2 rule_name
58
=head2 rule_name
54
59
55
  data_type: 'varchar'
60
  data_type: 'varchar'
Lines 73-78 __PACKAGE__->add_columns( Link Here
73
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
78
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
74
  "itemtype",
79
  "itemtype",
75
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
80
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
81
  "has_priority",
82
  { data_type => "integer", is_nullable => 1, is_boolean => 1 },
76
  "rule_name",
83
  "rule_name",
77
  { data_type => "varchar", is_nullable => 0, size => 32 },
84
  { data_type => "varchar", is_nullable => 0, size => 32 },
78
  "rule_value",
85
  "rule_value",
Lines 177-184 __PACKAGE__->belongs_to( Link Here
177
);
184
);
178
185
179
186
180
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
187
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-07-22 13:19:28
181
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QHMqvrtX0ohJe70PHUYZ0Q
188
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1mg3weVQdfPTJ+jX6X5K+Q
182
189
183
sub koha_objects_class {
190
sub koha_objects_class {
184
    'Koha::CirculationRules';
191
    'Koha::CirculationRules';
(-)a/admin/smart-rules.pl (-7 / +22 lines)
Lines 70-81 $cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY ); Link Here
70
if ($op eq 'delete') {
70
if ($op eq 'delete') {
71
    my $itemtype     = $input->param('itemtype');
71
    my $itemtype     = $input->param('itemtype');
72
    my $categorycode = $input->param('categorycode');
72
    my $categorycode = $input->param('categorycode');
73
    my $has_priority = $input->param('has_priority') ? 1 : undef;
74
    $debug and warn "deleting $1 $2 $branch";
73
75
74
    Koha::CirculationRules->set_rules(
76
    Koha::CirculationRules->set_rules(
75
        {
77
        {
76
            categorycode => $categorycode eq '*' ? undef : $categorycode,
78
            categorycode => $categorycode eq '*' ? undef : $categorycode,
77
            branchcode   => $branch eq '*' ? undef : $branch,
79
            branchcode   => $branch eq '*' ? undef : $branch,
78
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
80
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
81
            has_priority => $has_priority,
79
            rules        => {
82
            rules        => {
80
                maxissueqty                      => undef,
83
                maxissueqty                      => undef,
81
                maxonsiteissueqty                => undef,
84
                maxonsiteissueqty                => undef,
Lines 121-132 if ($op eq 'delete') { Link Here
121
}
124
}
122
elsif ($op eq 'delete-branch-cat') {
125
elsif ($op eq 'delete-branch-cat') {
123
    my $categorycode  = $input->param('categorycode');
126
    my $categorycode  = $input->param('categorycode');
127
    my $has_priority  = $input->param('has_priority') ? 1 : undef;
124
    if ($branch eq "*") {
128
    if ($branch eq "*") {
125
        if ($categorycode eq "*") {
129
        if ($categorycode eq "*") {
126
            Koha::CirculationRules->set_rules(
130
            Koha::CirculationRules->set_rules(
127
                {
131
                {
128
                    branchcode   => undef,
132
                    branchcode   => undef,
129
                    categorycode => undef,
133
                    categorycode => undef,
134
                    has_priority => $has_priority,
130
                    rules        => {
135
                    rules        => {
131
                        max_holds                      => undef,
136
                        max_holds                      => undef,
132
                        patron_maxissueqty             => undef,
137
                        patron_maxissueqty             => undef,
Lines 150-155 elsif ($op eq 'delete-branch-cat') { Link Here
150
                {
155
                {
151
                    categorycode => $categorycode,
156
                    categorycode => $categorycode,
152
                    branchcode   => undef,
157
                    branchcode   => undef,
158
                    has_priority => $has_priority,
153
                    rules        => {
159
                    rules        => {
154
                        max_holds                => undef,
160
                        max_holds                => undef,
155
                        patron_maxissueqty       => undef,
161
                        patron_maxissueqty       => undef,
Lines 163-168 elsif ($op eq 'delete-branch-cat') { Link Here
163
            {
169
            {
164
                branchcode   => $branch,
170
                branchcode   => $branch,
165
                categorycode => undef,
171
                categorycode => undef,
172
                has_priority => $has_priority,
166
                rules        => {
173
                rules        => {
167
                    max_holds                => undef,
174
                    max_holds                => undef,
168
                    patron_maxissueqty       => undef,
175
                    patron_maxissueqty       => undef,
Lines 186-191 elsif ($op eq 'delete-branch-cat') { Link Here
186
            {
193
            {
187
                categorycode => $categorycode,
194
                categorycode => $categorycode,
188
                branchcode   => $branch,
195
                branchcode   => $branch,
196
                has_priority => $has_priority,
189
                rules        => {
197
                rules        => {
190
                    max_holds         => undef,
198
                    max_holds         => undef,
191
                    patron_maxissueqty       => undef,
199
                    patron_maxissueqty       => undef,
Lines 254-260 elsif ($op eq 'add') { Link Here
254
    my $br = $branch; # branch
262
    my $br = $branch; # branch
255
    my $bor  = $input->param('categorycode'); # borrower category
263
    my $bor  = $input->param('categorycode'); # borrower category
256
    my $itemtype  = $input->param('itemtype');     # item type
264
    my $itemtype  = $input->param('itemtype');     # item type
257
    my $has_priority = $input->param('has_priority') ? 1 : 0;
265
    my $has_priority = $input->param('has_priority') ? 1 : undef;
258
    my $fine = $input->param('fine');
266
    my $fine = $input->param('fine');
259
    my $finedays     = $input->param('finedays');
267
    my $finedays     = $input->param('finedays');
260
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || q{};
268
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || q{};
Lines 301-307 elsif ($op eq 'add') { Link Here
301
        maxissueqty                   => $maxissueqty,
309
        maxissueqty                   => $maxissueqty,
302
        maxonsiteissueqty             => $maxonsiteissueqty,
310
        maxonsiteissueqty             => $maxonsiteissueqty,
303
        rentaldiscount                => $rentaldiscount,
311
        rentaldiscount                => $rentaldiscount,
304
        has_priority                  => $has_priority,
305
        fine                          => $fine,
312
        fine                          => $fine,
306
        finedays                      => $finedays,
313
        finedays                      => $finedays,
307
        maxsuspensiondays             => $maxsuspensiondays,
314
        maxsuspensiondays             => $maxsuspensiondays,
Lines 344-350 elsif ($op eq 'add') { Link Here
344
            categorycode => $bor eq '*' ? undef : $bor,
351
            categorycode => $bor eq '*' ? undef : $bor,
345
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
352
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
346
            branchcode   => $br eq '*' ? undef : $br,
353
            branchcode   => $br eq '*' ? undef : $br,
347
	    has_priority => $has_priority,
354
            has_priority => $has_priority,
348
            rules        => $rules,
355
            rules        => $rules,
349
        }
356
        }
350
    );
357
    );
Lines 359-370 elsif ($op eq "set-branch-defaults") { Link Here
359
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
366
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
360
    my $returnbranch  = $input->param('returnbranch');
367
    my $returnbranch  = $input->param('returnbranch');
361
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
368
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
369
    my $has_priority = $input->param('has_priority') ? 1 : undef;
362
370
363
    if ($branch eq "*") {
371
    if ($branch eq "*") {
364
        Koha::CirculationRules->set_rules(
372
        Koha::CirculationRules->set_rules(
365
            {
373
            {
366
                itemtype     => undef,
374
                itemtype     => undef,
367
                branchcode   => undef,
375
                branchcode   => undef,
376
                has_priority => $has_priority,
368
                rules        => {
377
                rules        => {
369
                    holdallowed             => $holdallowed,
378
                    holdallowed             => $holdallowed,
370
                    hold_fulfillment_policy => $hold_fulfillment_policy,
379
                    hold_fulfillment_policy => $hold_fulfillment_policy,
Lines 376-384 elsif ($op eq "set-branch-defaults") { Link Here
376
            {
385
            {
377
                categorycode => undef,
386
                categorycode => undef,
378
                branchcode   => undef,
387
                branchcode   => undef,
388
                has_priority => $has_priority,
379
                rules        => {
389
                rules        => {
380
                    patron_maxissueqty             => $patron_maxissueqty,
390
                    patron_maxissueqty             => $patron_maxissueqty,
381
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
391
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
392
                    patron_has_priority      => $has_priority,
382
                }
393
                }
383
            }
394
            }
384
        );
395
        );
Lines 387-392 elsif ($op eq "set-branch-defaults") { Link Here
387
            {
398
            {
388
                itemtype     => undef,
399
                itemtype     => undef,
389
                branchcode   => $branch,
400
                branchcode   => $branch,
401
                has_priority => $has_priority,
390
                rules        => {
402
                rules        => {
391
                    holdallowed             => $holdallowed,
403
                    holdallowed             => $holdallowed,
392
                    hold_fulfillment_policy => $hold_fulfillment_policy,
404
                    hold_fulfillment_policy => $hold_fulfillment_policy,
Lines 398-403 elsif ($op eq "set-branch-defaults") { Link Here
398
            {
410
            {
399
                categorycode => undef,
411
                categorycode => undef,
400
                branchcode   => $branch,
412
                branchcode   => $branch,
413
                has_priority => $has_priority,
401
                rules        => {
414
                rules        => {
402
                    patron_maxissueqty             => $patron_maxissueqty,
415
                    patron_maxissueqty             => $patron_maxissueqty,
403
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
416
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
Lines 430-435 elsif ($op eq "add-branch-cat") { Link Here
430
                {
443
                {
431
                    categorycode => undef,
444
                    categorycode => undef,
432
                    branchcode   => undef,
445
                    branchcode   => undef,
446
                    has_priority => $has_priority,
433
                    rules        => {
447
                    rules        => {
434
                        max_holds         => $max_holds,
448
                        max_holds         => $max_holds,
435
                        patron_maxissueqty       => $patron_maxissueqty,
449
                        patron_maxissueqty       => $patron_maxissueqty,
Lines 443-453 elsif ($op eq "add-branch-cat") { Link Here
443
                {
457
                {
444
                    categorycode => $categorycode,
458
                    categorycode => $categorycode,
445
                    branchcode   => undef,
459
                    branchcode   => undef,
460
                    has_priority => $has_priority,
446
                    rules        => {
461
                    rules        => {
447
                        max_holds         => $max_holds,
462
                        max_holds         => $max_holds,
448
                        patron_maxissueqty       => $patron_maxissueqty,
463
                        patron_maxissueqty       => $patron_maxissueqty,
449
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
464
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
450
                        has_priority      => $has_priority,
451
                    }
465
                    }
452
                }
466
                }
453
            );
467
            );
Lines 457-467 elsif ($op eq "add-branch-cat") { Link Here
457
            {
471
            {
458
                categorycode => undef,
472
                categorycode => undef,
459
                branchcode   => $branch,
473
                branchcode   => $branch,
474
                has_priority => $has_priority,
460
                rules        => {
475
                rules        => {
461
                    max_holds         => $max_holds,
476
                    max_holds         => $max_holds,
462
                    patron_maxissueqty       => $patron_maxissueqty,
477
                    patron_maxissueqty       => $patron_maxissueqty,
463
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
478
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
464
                    has_priority      => $has_priority,
465
                }
479
                }
466
            }
480
            }
467
        );
481
        );
Lines 470-480 elsif ($op eq "add-branch-cat") { Link Here
470
            {
484
            {
471
                categorycode => $categorycode,
485
                categorycode => $categorycode,
472
                branchcode   => $branch,
486
                branchcode   => $branch,
487
                has_priority => $has_priority,
473
                rules        => {
488
                rules        => {
474
                    max_holds         => $max_holds,
489
                    max_holds         => $max_holds,
475
                    patron_maxissueqty       => $patron_maxissueqty,
490
                    patron_maxissueqty       => $patron_maxissueqty,
476
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
491
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
477
                    has_priority      => $has_priority,
478
                }
492
                }
479
            }
493
            }
480
        );
494
        );
Lines 747-753 my $definedbranch = $all_rules->count ? 1 : 0; Link Here
747
my $rules = {};
761
my $rules = {};
748
while ( my $r = $all_rules->next ) {
762
while ( my $r = $all_rules->next ) {
749
    $r = $r->unblessed;
763
    $r = $r->unblessed;
750
    $rules->{ $r->{categorycode} // q{} }->{ $r->{itemtype} // q{} }->{ $r->{rule_name} } = $r->{rule_value};
764
    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value};
765
    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ 'has_priority' } = $r->{has_priority};
751
}
766
}
752
767
753
$template->param(show_branch_cat_rule_form => 1);
768
$template->param(show_branch_cat_rule_form => 1);
(-)a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql (-5 / +2 lines)
Lines 1-5 Link Here
1
ALTER TABLE default_borrower_circ_rules ADD has_priority INT(1) DEFAULT 0;
1
ALTER TABLE circulation_rules ADD has_priority INT(1) DEFAULT NULL AFTER itemtype;
2
ALTER TABLE default_borrower_circ_rules DROP foreign key borrower_borrower_circ_rules_ibfk_1;
2
ALTER TABLE circulation_rules ADD KEY (branchcode , categorycode, itemtype, has_priority);
3
ALTER TABLE default_borrower_circ_rules DROP primary key;
4
ALTER TABLE default_borrower_circ_rules ADD primary key(categorycode, has_priority);
5
ALTER TABLE default_borrower_circ_rules ADD CONSTRAINT borrower_borrower_circ_rules_ibfk_1 FOREIGN KEY (categorycode) REFERENCES categories (categorycode) ON DELETE CASCADE ON UPDATE CASCADE;
(-)a/installer/data/mysql/kohastructure.sql (-5 / +6 lines)
Lines 1729-1739 DROP TABLE IF EXISTS `circulation_rules`; Link Here
1729
/*!40101 SET character_set_client = utf8 */;
1729
/*!40101 SET character_set_client = utf8 */;
1730
CREATE TABLE `circulation_rules` (
1730
CREATE TABLE `circulation_rules` (
1731
  `id` int(11) NOT NULL AUTO_INCREMENT,
1731
  `id` int(11) NOT NULL AUTO_INCREMENT,
1732
  `branchcode` varchar(10) DEFAULT NULL,
1732
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1733
  `categorycode` varchar(10) DEFAULT NULL,
1733
  `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1734
  `itemtype` varchar(10) DEFAULT NULL,
1734
  `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1735
  `rule_name` varchar(32) NOT NULL,
1735
  `has_priority` tinyint(1) NULL default NULL,
1736
  `rule_value` varchar(32) NOT NULL,
1736
  `rule_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
1737
  `rule_value` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
1737
  PRIMARY KEY (`id`),
1738
  PRIMARY KEY (`id`),
1738
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1739
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1739
  KEY `circ_rules_ibfk_2` (`categorycode`),
1740
  KEY `circ_rules_ibfk_2` (`categorycode`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-150 / +138 lines)
Lines 119-212 Link Here
119
                            <th>Note</th>
119
                            <th>Note</th>
120
                            [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
120
                            [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
121
                <th>Current checkouts allowed</th>
121
                <th>Current checkouts allowed</th>
122
                            <th>Current on-site checkouts allowed</th>
122
                <th>Current on-site checkouts allowed</th>
123
                            <th>Loan period</th>
123
                <th>Loan period</th>
124
                            <th>Days mode</th>
124
                <th>Days mode</th>
125
                            <th>Unit</th>
125
                <th>Unit</th>
126
                            <th>Hard due date</th>
126
                <th>Hard due date</th>
127
                            <th>Decreased loan period for high holds (day)</th>
127
                <th>Decreased loan period for high holds (day)</th>
128
                            <th>Fine amount</th>
128
                <th>Fine amount</th>
129
                            <th>Fine charging interval</th>
129
                <th>Fine charging interval</th>
130
                            <th>When to charge</th>
130
                <th>When to charge</th>
131
                            <th>Fine/suspension grace period</th>
131
                <th>Fine grace period</th>
132
                            <th>Overdue fines cap (amount)</th>
132
                <th>Overdue fines cap (amount)</th>
133
                            <th>Cap fine at replacement price</th>
133
                <th>Cap fine at replacement price</th>
134
                            <th>Suspension in days (day)</th>
134
                <th>Suspension in days (day)</th>
135
                            <th>Max. suspension duration (day)</th>
135
                <th>Max. suspension duration (day)</th>
136
                            <th>Suspension charging interval</th>
136
                <th>Suspension charging interval</th>
137
                            <th>Renewals allowed (count)</th>
137
                <th>Renewals allowed (count)</th>
138
                            [% IF Koha.Preference('UnseenRenewals') %]
138
                [% IF Koha.Preference('UnseenRenewals') %]
139
                            <th>Unseen renewals allowed (count)</th>
139
                <th>Unseen renewals allowed (count)</th>
140
                            [% END %]
140
                [% END %]
141
                            <th>Renewal period</th>
141
                <th>Renewal period</th>
142
                            <th>No renewal before</th>
142
                <th>No renewal before</th>
143
                            <th>Automatic renewal</th>
143
                <th>Automatic renewal</th>
144
                            <th>No automatic renewal after</th>
144
                <th>No automatic renewal after</th>
145
                            <th>No automatic renewal after (hard limit)</th>
145
                <th>No automatic renewal after (hard limit)</th>
146
                            <th>Holds allowed (total)</th>
146
                <th>Holds allowed (total)</th>
147
                            <th>Holds allowed (daily)</th>
147
                <th>Holds allowed (daily)</th>
148
                            <th>Holds per record (count)</th>
148
                <th>Holds per record (count)</th>
149
                            <th>On shelf holds allowed</th>
149
                <th>On shelf holds allowed</th>
150
                            <th>OPAC item level holds</th>
150
                <th>OPAC item level holds</th>
151
                            [% IF Koha.Preference('ArticleRequests') %]
151
                <th>Article requests</th>
152
                            <th>Article requests</th>
152
                <th>Rental discount (%)</th>
153
                            [% END %]
153
                <th class="noExport">Actions</th>
154
                            <th>Rental discount (%)</th>
154
            </tr>
155
                            [% IF Koha.Preference('UseRecalls') %]
155
            </thead>
156
                                <th>Recalls allowed (total)</th>
156
            <tbody>
157
                                <th>Recalls per record (count)</th>
157
                [% SET row_count = 0 %]
158
                                <th>On shelf recalls allowed</th>
158
                [% FOREACH c IN categorycodes %]
159
                                <th>Recall due date interval (day)</th>
159
                    [% SET c = '' UNLESS c.defined %]
160
                                <th>Recall overdue fine amount</th>
160
                    [% FOREACH i IN itemtypes %]
161
                                <th>Recall pickup period (day)</th>
161
                        [% SET i = '' UNLESS i.defined %]
162
                            [% END %]
162
                        [% SET note = all_rules.$c.$i.note %]
163
                            <th class="noExport">Actions</th>
163
                        [% SET has_priority = all_rules.$c.$i.has_priority %]
164
                        </tr>
164
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
165
                        </thead>
165
                        [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
166
                        <tbody>
166
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
167
                            [% SET row_count = 0 %]
167
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
168
                            [% FOREACH c IN categorycodes %]
168
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
169
                                [% SET c = '' UNLESS c.defined %]
169
                        [% SET hardduedate = all_rules.$c.$i.hardduedate %]
170
                                [% FOREACH i IN itemtypes %]
170
                        [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
171
                                    [% SET i = '' UNLESS i.defined %]
171
                        [% SET fine = all_rules.$c.$i.fine %]
172
                                    [% SET note = all_rules.$c.$i.note %]
172
                        [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
173
                                    [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
173
                        [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
174
                                    [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
174
                        [% SET firstremind = all_rules.$c.$i.firstremind %]
175
                                    [% SET issuelength = all_rules.$c.$i.issuelength %]
175
                        [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
176
                                    [% SET daysmode = all_rules.$c.$i.daysmode %]
176
                        [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
177
                                    [% SET lengthunit = all_rules.$c.$i.lengthunit %]
177
                        [% SET finedays = all_rules.$c.$i.finedays %]
178
                                    [% SET hardduedate = all_rules.$c.$i.hardduedate %]
178
                        [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
179
                                    [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
179
                        [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
180
                                    [% SET fine = all_rules.$c.$i.fine %]
180
                        [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
181
                                    [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
181
                        [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %]
182
                                    [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
182
                        [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
183
                                    [% SET firstremind = all_rules.$c.$i.firstremind %]
183
                        [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
184
                                    [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
184
                        [% SET auto_renew = all_rules.$c.$i.auto_renew %]
185
                                    [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
185
                        [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
186
                                    [% SET finedays = all_rules.$c.$i.finedays %]
186
                        [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
187
                                    [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
187
                        [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
188
                                    [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
188
                        [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
189
                                    [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
189
                        [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
190
                                    [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %]
190
                        [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
191
                                    [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
191
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
192
                                    [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
192
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
193
                                    [% SET auto_renew = all_rules.$c.$i.auto_renew %]
193
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
194
                                    [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
194
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
195
                                    [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
196
                                    [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
197
                                    [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
198
                                    [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
199
                                    [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
200
                                    [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
201
                                    [% SET article_requests = all_rules.$c.$i.article_requests %]
202
                                    [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
203
                                    [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
204
                                    [% SET recalls_allowed = all_rules.$c.$i.recalls_allowed %]
205
                                    [% SET recalls_per_record = all_rules.$c.$i.recalls_per_record %]
206
                                    [% SET on_shelf_recalls = all_rules.$c.$i.on_shelf_recalls %]
207
                                    [% SET recall_due_date_interval = all_rules.$c.$i.recall_due_date_interval %]
208
                                    [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %]
209
                                    [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %]
210
195
211
                                    [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time %]
196
                                    [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time %]
212
                                    [% IF show_rule %]
197
                                    [% IF show_rule %]
Lines 247-253 Link Here
247
                                                </td>
232
                                                </td>
248
                                                [% UNLESS humanbranch %]
233
                                                [% UNLESS humanbranch %]
249
                                    <td>
234
                                    <td>
250
                                        [% IF rule.has_priority %]
235
                                        [% IF has_priority.defined && has_priority %]
251
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
236
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
252
                                        [% ELSE %]
237
                                        [% ELSE %]
253
                                            <input type="checkbox" disabled="disabled"/>
238
                                            <input type="checkbox" disabled="disabled"/>
Lines 768-833 Link Here
768
                                            Not set
753
                                            Not set
769
                                        </option>
754
                                        </option>
770
755
771
                                        [% IF returnbranch.rule_value == 'homebranch' %]
756
                            [% IF returnbranch == 'homebranch' %]
772
                                        <option value="homebranch" selected="selected">
757
                            <option value="homebranch" selected="selected">
773
                                        [% ELSE %]
758
                            [% ELSE %]
774
                                        <option value="homebranch">
759
                            <option value="homebranch">
775
                                        [% END %]
760
                            [% END %]
776
                                            Item returns home
761
                                Item returns home
777
                                        </option>
762
                            </option>
778
                                        [% IF returnbranch.rule_value == 'holdingbranch' %]
763
                            [% IF returnbranch == 'holdingbranch' %]
779
                                        <option value="holdingbranch" selected="selected">
764
                            <option value="holdingbranch" selected="selected">
780
                                        [% ELSE %]
765
                            [% ELSE %]
781
                                        <option value="holdingbranch">
766
                            <option value="holdingbranch">
782
                                        [% END %]
767
                            [% END %]
783
                                            Item returns to issuing library
768
                                Item returns to issuing library
784
                                        </option>
769
                            </option>
785
                                        [% IF returnbranch.rule_value == 'noreturn' %]
770
                            [% IF returnbranch == 'noreturn' %]
786
                                        <option value="noreturn" selected="selected">
771
                            <option value="noreturn" selected="selected">
787
                                        [% ELSE %]
772
                            [% ELSE %]
788
                                        <option value="noreturn">
773
                            <option value="noreturn">
789
                                        [% END %]
774
                            [% END %]
790
                                            Item floats
775
                                Item floats
791
                                        </option>
776
                            </option>
792
                                    </select>
777
                        </select>
793
                                </td>
778
                    </td>
794
                                <td class="actions">
779
                    <td class="actions">
795
                                    <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
780
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
796
                                    [% IF ( default_checkout_hold_and_return_policy ) %]
781
                        <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
797
                                        <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
782
                    </td>
798
                                    [% END %]
783
                </tr>
799
                                </td>
784
            </table>
800
                            </tr>
785
        </form>
801
                        </table>
786
    </div>
802
                    </form>
787
    [% IF ( show_branch_cat_rule_form ) %]
803
                </div>
788
    <div id="holds-policy-by-patron-category" class="container">
804
789
    <h3>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h3>
805
                [% IF ( show_branch_cat_rule_form ) %]
790
        <p>For this library, you can specify the maximum number of loans that
806
                <div id="holds-policy-by-patron-category" class="page-section">
791
            a patron of a given category can make, regardless of the item type.
807
                    <h2>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h2>
792
        </p>
808
                    <p>For this library, you can specify the maximum number of loans that
793
        <p>If the total amount loanable for a given patron category is left blank,
809
                        a patron of a given category can make, regardless of the item type.
794
           no limit applies, except possibly for a limit you define for a specific item type.
810
                    </p>
795
        </p>
811
                    <p>If the total amount loanable for a given patron category is left blank,
796
        <p>
812
                       no limit applies, except possibly for a limit you define for a specific item type.
797
            <b>Has priority: </b>If checked, the rule will override those for all branches. Else
813
                    </p>
798
            it behaves like a default one: used if no rule exists for the coresponding branch.
814
                    <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
799
        </p>
815
                        <input type="hidden" name="op" value="add-branch-cat" />
800
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
816
                        <input type="hidden" name="branch" value="[% current_branch | html %]"/>
801
            <input type="hidden" name="op" value="add-branch-cat" />
817
                        <table>
802
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
818
                            <tr>
803
            <table>
819
                                <th>Patron category</th>
804
                <tr>
820
                                <th>Total current checkouts allowed</th>
805
                    <th>Patron category</th>
821
                                <th>Total current on-site checkouts allowed</th>
806
                    <th>Total current checkouts allowed</th>
822
                                <th>Total holds allowed</th>
807
                    <th>Total current on-site checkouts allowed</th>
823
                                <th>&nbsp;</th>
808
                    <th>Total holds allowed</th>
824
                            </tr>
809
                    [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
825
                            [% FOREACH c IN categorycodes %]
810
                    <th>&nbsp;</th>
826
                                [% NEXT UNLESS c %]
811
                </tr>
827
                                [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
812
                [% SET i = '' %]
828
                                [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
813
                [% FOREACH c IN categorycodes %]
829
                                [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
814
                    [% NEXT UNLESS c %]
830
815
                    [% SET patron_maxissueqty = all_rules.$c.$i.patron_maxissueqty %]
816
                    [% SET patron_maxonsiteissueqty = all_rules.$c.$i.patron_maxonsiteissueqty %]
817
                    [% SET max_holds = all_rules.$c.$i.max_holds %]
818
                    [% SET has_priority = all_rules.$c.$i.has_priority %]
831
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
819
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
832
                    <tr>
820
                    <tr>
833
                        <td>
821
                        <td>
Lines 860-866 Link Here
860
                        </td>
848
                        </td>
861
                        [% UNLESS humanbranch %]
849
                        [% UNLESS humanbranch %]
862
                            <td>
850
                            <td>
863
                                [% IF branch_cat_rule_loo.has_priority %]
851
                                [% IF has_priority.defined && has_priority %]
864
                                    <input type="checkbox" checked="checked" disabled/>
852
                                    <input type="checkbox" checked="checked" disabled/>
865
                                [% ELSE %]
853
                                [% ELSE %]
866
                                    <input type="checkbox" disabled/>
854
                                    <input type="checkbox" disabled/>
(-)a/t/db_dependent/Circulation/Branch.t (-14 / +36 lines)
Lines 155-161 Koha::CirculationRules->set_rules( Link Here
155
            patron_maxissueqty       => 5,
155
            patron_maxissueqty       => 5,
156
            patron_maxonsiteissueqty => 6,
156
            patron_maxonsiteissueqty => 6,
157
        }
157
        }
158
    }
158
   }
159
);
159
);
160
160
161
161
Lines 232-243 Koha::CirculationRules->set_rules( Link Here
232
    }
232
    }
233
);
233
);
234
234
235
$query = q|
235
Koha::CirculationRules->set_rules(
236
    INSERT INTO default_borrower_circ_rules
236
    {
237
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
237
        branchcode   => undef,
238
    VALUES( ?, ?, ?, ? )
238
        categorycode => $samplecat->{categorycode},
239
|;
239
        rules        => {
240
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 0);
240
            patron_maxonsiteissueqty  => 3,
241
            patron_maxissueqty        => 3,
242
        }
243
    }
244
);
241
245
242
#Test GetBranchBorrowerCircRule
246
#Test GetBranchBorrowerCircRule
243
#
247
#
Lines 265-286 is_deeply( Link Here
265
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
269
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
266
);
270
);
267
271
268
$query = q|
272
269
    INSERT INTO default_borrower_circ_rules
273
Koha::CirculationRules->set_rules(
270
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
274
    {
271
    VALUES( ?, ?, ?, ? )
275
        branchcode   => undef,
272
|;
276
        categorycode => $samplecat->{categorycode},
273
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 1);
277
        has_priority => 1,
278
        rules        => {
279
            patron_maxonsiteissueqty  => 3,
280
            patron_maxissueqty        => 3,
281
        }
282
    }
283
);
274
284
275
is_deeply(
285
is_deeply(
276
    GetBranchBorrowerCircRule(
286
    GetBranchBorrowerCircRule(
277
        $samplebranch1->{branchcode},
287
        $samplebranch1->{branchcode},
278
        $samplecat->{categorycode}
288
        $samplecat->{categorycode}
279
    ),
289
    ),
280
    { maxissueqty => 3, maxonsiteissueqty => 3, has_priority => 1 },
290
    { patron_maxissueqty => 3, patron_maxonsiteissueqty => 3 },
281
    "GetBranchBorrower returns the rule having priority"
291
    "GetBranchBorrower returns the rule having priority"
282
);
292
);
283
293
294
Koha::CirculationRules->set_rules(
295
    {
296
        branchcode   => undef,
297
        categorycode => $samplecat->{categorycode},
298
        has_priority => 0,
299
        rules        => {
300
            patron_maxonsiteissueqty  => 3,
301
            patron_maxissueqty        => 3,
302
        }
303
    }
304
);
305
284
#Test GetBranchItemRule
306
#Test GetBranchItemRule
285
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
307
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
286
is_deeply(
308
is_deeply(
(-)a/t/db_dependent/Koha/IssuingRules.t (-8 / +15 lines)
Lines 35-40 $schema->storage->txn_begin; Link Here
35
35
36
my $builder      = t::lib::TestBuilder->new;
36
my $builder      = t::lib::TestBuilder->new;
37
37
38
38
subtest 'get_effective_issuing_rule' => sub {
39
subtest 'get_effective_issuing_rule' => sub {
39
    plan tests => 3;
40
    plan tests => 3;
40
41
Lines 43-72 subtest 'get_effective_issuing_rule' => sub { Link Here
43
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
44
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
44
45
45
    subtest 'Priority rule' => sub {
46
    subtest 'Priority rule' => sub {
46
        plan tests => 3;
47
        plan tests => 4;
47
48
48
        Koha::IssuingRules->delete;
49
        Koha::CirculationRules->delete;
50
        is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.');
49
51
50
        ok(Koha::IssuingRule->new({
52
        ok(Koha::CirculationRule->new({
51
            branchcode => $branchcode,
53
            branchcode => $branchcode,
52
            categorycode => $categorycode,
54
            categorycode => $categorycode,
53
            itemtype => $itemtype,
55
            itemtype => $itemtype,
56
            rule_name => 'fine',
57
            rule_value => 0,
54
        })->store, "Given I added an issuing rule branchcode => $branchcode,'
58
        })->store, "Given I added an issuing rule branchcode => $branchcode,'
55
           .' categorycode => $categorycode, itemtype => $itemtype,");
59
           .' categorycode => $categorycode, itemtype => $itemtype,");
56
60
57
        ok(Koha::IssuingRule->new({
61
        ok(Koha::CirculationRule->new({
58
            branchcode => '*',
62
            branchcode => undef,
59
            categorycode => $categorycode,
63
            categorycode => $categorycode,
60
            itemtype => $itemtype,
64
            itemtype => $itemtype,
61
            has_priority => 1,
65
            has_priority => 1,
66
            rule_name => 'fine',
67
            rule_value => 1,
62
        })->store, "Add a priority rule.");
68
        })->store, "Add a priority rule.");
63
69
64
        my $rule = Koha::IssuingRules->get_effective_issuing_rule({
70
        my $rule = Koha::CirculationRules->get_effective_rule({
65
            branchcode   => $branchcode,
71
            branchcode   => $branchcode,
66
            categorycode => $categorycode,
72
            categorycode => $categorycode,
67
            itemtype     => $itemtype,
73
            itemtype     => $itemtype,
74
            has_priority => 1,
75
            rule_name    => 'fine',
68
        });
76
        });
69
        is($rule->has_priority, 1, 'Priority rule should be returned');
77
        is($rule->priority, 1, 'Priority rule should be returned');
70
    };
78
    };
71
79
72
    subtest 'Call with undefined values' => sub {
80
    subtest 'Call with undefined values' => sub {
73
- 

Return to bug 8137