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

(-)a/Koha/CirculationRule.pm (+10 lines)
Lines 68-73 sub item_type { Link Here
68
    return Koha::ItemTypes->_new_from_dbic($rs);
68
    return Koha::ItemTypes->_new_from_dbic($rs);
69
}
69
}
70
70
71
=head3 priority
72
73
=cut
74
75
sub priority {
76
    my ($self) = @_;
77
78
    return $self->has_priority;
79
}
80
71
=head3 clone
81
=head3 clone
72
82
73
Clone a circulation rule to another branch
83
Clone a circulation rule to another branch
(-)a/Koha/CirculationRules.pm (-9 / +21 lines)
Lines 65-73 our $RULE_KINDS = { Link Here
65
    max_holds => {
65
    max_holds => {
66
        scope => [ 'branchcode', 'categorycode' ],
66
        scope => [ 'branchcode', 'categorycode' ],
67
    },
67
    },
68
    has_priority => {
69
	scope => [ 'branchcode', 'categorycode' ],
70
    },
71
    holdallowed => {
68
    holdallowed => {
72
        scope => [ 'branchcode', 'itemtype' ],
69
        scope => [ 'branchcode', 'itemtype' ],
73
        can_be_blank => 0,
70
        can_be_blank => 0,
Lines 261-275 sub get_effective_rule { Link Here
261
    }
258
    }
262
259
263
    my $order_by = $params->{order_by}
260
    my $order_by = $params->{order_by}
264
      // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] };
261
      // { -desc => [ 'has_priority', 'branchcode', 'categorycode', 'itemtype' ] };
265
262
266
    my $search_params;
263
    my $search_params;
267
    $search_params->{rule_name} = $rule_name;
264
    $search_params->{rule_name} = $rule_name;
268
269
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
265
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
270
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
266
    $search_params->{has_priority} = 1;
271
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
272
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
273
267
274
    my $rule = $self->search(
268
    my $rule = $self->search(
275
        $search_params,
269
        $search_params,
Lines 279-284 sub get_effective_rule { Link Here
279
        }
273
        }
280
    )->single;
274
    )->single;
281
275
276
    return $rule if defined $rule;
277
278
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype,     undef ] : undef;
279
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
280
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
281
282
    $rule = $self->search(
283
        $search_params,
284
        {
285
            order_by => $order_by,
286
            rows => 1,
287
        }
288
    )->single;
289
282
    return $rule;
290
    return $rule;
283
}
291
}
284
292
Lines 383-388 sub set_rule { Link Here
383
    my $branchcode   = $params->{branchcode};
391
    my $branchcode   = $params->{branchcode};
384
    my $categorycode = $params->{categorycode};
392
    my $categorycode = $params->{categorycode};
385
    my $itemtype     = $params->{itemtype};
393
    my $itemtype     = $params->{itemtype};
394
    my $has_priority = $params->{has_priority};
386
    my $rule_name    = $params->{rule_name};
395
    my $rule_name    = $params->{rule_name};
387
    my $rule_value   = $params->{rule_value};
396
    my $rule_value   = $params->{rule_value};
388
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
397
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
Lines 400-405 sub set_rule { Link Here
400
            branchcode   => $branchcode,
409
            branchcode   => $branchcode,
401
            categorycode => $categorycode,
410
            categorycode => $categorycode,
402
            itemtype     => $itemtype,
411
            itemtype     => $itemtype,
412
            has_priority => $has_priority,
403
        }
413
        }
404
    )->next();
414
    )->next();
405
415
Lines 419-424 sub set_rule { Link Here
419
                    branchcode   => $branchcode,
429
                    branchcode   => $branchcode,
420
                    categorycode => $categorycode,
430
                    categorycode => $categorycode,
421
                    itemtype     => $itemtype,
431
                    itemtype     => $itemtype,
432
                    has_priority => $has_priority,
422
                    rule_name    => $rule_name,
433
                    rule_name    => $rule_name,
423
                    rule_value   => $rule_value,
434
                    rule_value   => $rule_value,
424
                }
435
                }
Lines 446-452 sub set_rules { Link Here
446
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
457
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
447
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
458
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
448
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
459
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
449
    my $rules        = $params->{rules};
460
    $set_params{has_priority} = $params->{has_priority} if exists $params->{has_priority};
461
    my $rules = $params->{rules};
450
462
451
    my $rule_objects = [];
463
    my $rule_objects = [];
452
    while ( my ( $rule_name, $rule_value ) = each %$rules ) {
464
    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 302-308 elsif ($op eq 'add') { Link Here
302
        maxissueqty                   => $maxissueqty,
310
        maxissueqty                   => $maxissueqty,
303
        maxonsiteissueqty             => $maxonsiteissueqty,
311
        maxonsiteissueqty             => $maxonsiteissueqty,
304
        rentaldiscount                => $rentaldiscount,
312
        rentaldiscount                => $rentaldiscount,
305
        has_priority                  => $has_priority,
306
        fine                          => $fine,
313
        fine                          => $fine,
307
        finedays                      => $finedays,
314
        finedays                      => $finedays,
308
        maxsuspensiondays             => $maxsuspensiondays,
315
        maxsuspensiondays             => $maxsuspensiondays,
Lines 345-351 elsif ($op eq 'add') { Link Here
345
            categorycode => $bor eq '*' ? undef : $bor,
352
            categorycode => $bor eq '*' ? undef : $bor,
346
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
353
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
347
            branchcode   => $br eq '*' ? undef : $br,
354
            branchcode   => $br eq '*' ? undef : $br,
348
	    has_priority => $has_priority,
355
            has_priority => $has_priority,
349
            rules        => $rules,
356
            rules        => $rules,
350
        }
357
        }
351
    );
358
    );
Lines 360-371 elsif ($op eq "set-branch-defaults") { Link Here
360
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
367
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
361
    my $returnbranch  = $input->param('returnbranch');
368
    my $returnbranch  = $input->param('returnbranch');
362
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
369
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
370
    my $has_priority = $input->param('has_priority') ? 1 : undef;
363
371
364
    if ($branch eq "*") {
372
    if ($branch eq "*") {
365
        Koha::CirculationRules->set_rules(
373
        Koha::CirculationRules->set_rules(
366
            {
374
            {
367
                itemtype     => undef,
375
                itemtype     => undef,
368
                branchcode   => undef,
376
                branchcode   => undef,
377
                has_priority => $has_priority,
369
                rules        => {
378
                rules        => {
370
                    holdallowed             => $holdallowed,
379
                    holdallowed             => $holdallowed,
371
                    hold_fulfillment_policy => $hold_fulfillment_policy,
380
                    hold_fulfillment_policy => $hold_fulfillment_policy,
Lines 377-385 elsif ($op eq "set-branch-defaults") { Link Here
377
            {
386
            {
378
                categorycode => undef,
387
                categorycode => undef,
379
                branchcode   => undef,
388
                branchcode   => undef,
389
                has_priority => $has_priority,
380
                rules        => {
390
                rules        => {
381
                    patron_maxissueqty             => $patron_maxissueqty,
391
                    patron_maxissueqty             => $patron_maxissueqty,
382
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
392
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
393
                    patron_has_priority      => $has_priority,
383
                }
394
                }
384
            }
395
            }
385
        );
396
        );
Lines 388-393 elsif ($op eq "set-branch-defaults") { Link Here
388
            {
399
            {
389
                itemtype     => undef,
400
                itemtype     => undef,
390
                branchcode   => $branch,
401
                branchcode   => $branch,
402
                has_priority => $has_priority,
391
                rules        => {
403
                rules        => {
392
                    holdallowed             => $holdallowed,
404
                    holdallowed             => $holdallowed,
393
                    hold_fulfillment_policy => $hold_fulfillment_policy,
405
                    hold_fulfillment_policy => $hold_fulfillment_policy,
Lines 399-404 elsif ($op eq "set-branch-defaults") { Link Here
399
            {
411
            {
400
                categorycode => undef,
412
                categorycode => undef,
401
                branchcode   => $branch,
413
                branchcode   => $branch,
414
                has_priority => $has_priority,
402
                rules        => {
415
                rules        => {
403
                    patron_maxissueqty             => $patron_maxissueqty,
416
                    patron_maxissueqty             => $patron_maxissueqty,
404
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
417
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
Lines 431-436 elsif ($op eq "add-branch-cat") { Link Here
431
                {
444
                {
432
                    categorycode => undef,
445
                    categorycode => undef,
433
                    branchcode   => undef,
446
                    branchcode   => undef,
447
                    has_priority => $has_priority,
434
                    rules        => {
448
                    rules        => {
435
                        max_holds         => $max_holds,
449
                        max_holds         => $max_holds,
436
                        patron_maxissueqty       => $patron_maxissueqty,
450
                        patron_maxissueqty       => $patron_maxissueqty,
Lines 444-454 elsif ($op eq "add-branch-cat") { Link Here
444
                {
458
                {
445
                    categorycode => $categorycode,
459
                    categorycode => $categorycode,
446
                    branchcode   => undef,
460
                    branchcode   => undef,
461
                    has_priority => $has_priority,
447
                    rules        => {
462
                    rules        => {
448
                        max_holds         => $max_holds,
463
                        max_holds         => $max_holds,
449
                        patron_maxissueqty       => $patron_maxissueqty,
464
                        patron_maxissueqty       => $patron_maxissueqty,
450
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
465
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
451
                        has_priority      => $has_priority,
452
                    }
466
                    }
453
                }
467
                }
454
            );
468
            );
Lines 458-468 elsif ($op eq "add-branch-cat") { Link Here
458
            {
472
            {
459
                categorycode => undef,
473
                categorycode => undef,
460
                branchcode   => $branch,
474
                branchcode   => $branch,
475
                has_priority => $has_priority,
461
                rules        => {
476
                rules        => {
462
                    max_holds         => $max_holds,
477
                    max_holds         => $max_holds,
463
                    patron_maxissueqty       => $patron_maxissueqty,
478
                    patron_maxissueqty       => $patron_maxissueqty,
464
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
479
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
465
                    has_priority      => $has_priority,
466
                }
480
                }
467
            }
481
            }
468
        );
482
        );
Lines 471-481 elsif ($op eq "add-branch-cat") { Link Here
471
            {
485
            {
472
                categorycode => $categorycode,
486
                categorycode => $categorycode,
473
                branchcode   => $branch,
487
                branchcode   => $branch,
488
                has_priority => $has_priority,
474
                rules        => {
489
                rules        => {
475
                    max_holds         => $max_holds,
490
                    max_holds         => $max_holds,
476
                    patron_maxissueqty       => $patron_maxissueqty,
491
                    patron_maxissueqty       => $patron_maxissueqty,
477
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
492
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
478
                    has_priority      => $has_priority,
479
                }
493
                }
480
            }
494
            }
481
        );
495
        );
Lines 748-754 my $definedbranch = $all_rules->count ? 1 : 0; Link Here
748
my $rules = {};
762
my $rules = {};
749
while ( my $r = $all_rules->next ) {
763
while ( my $r = $all_rules->next ) {
750
    $r = $r->unblessed;
764
    $r = $r->unblessed;
751
    $rules->{ $r->{categorycode} // q{} }->{ $r->{itemtype} // q{} }->{ $r->{rule_name} } = $r->{rule_value};
765
    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value};
766
    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ 'has_priority' } = $r->{has_priority};
752
}
767
}
753
768
754
$template->param(show_branch_cat_rule_form => 1);
769
$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 1801-1811 DROP TABLE IF EXISTS `circulation_rules`; Link Here
1801
/*!40101 SET character_set_client = utf8 */;
1801
/*!40101 SET character_set_client = utf8 */;
1802
CREATE TABLE `circulation_rules` (
1802
CREATE TABLE `circulation_rules` (
1803
  `id` int(11) NOT NULL AUTO_INCREMENT,
1803
  `id` int(11) NOT NULL AUTO_INCREMENT,
1804
  `branchcode` varchar(10) DEFAULT NULL,
1804
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1805
  `categorycode` varchar(10) DEFAULT NULL,
1805
  `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1806
  `itemtype` varchar(10) DEFAULT NULL,
1806
  `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1807
  `rule_name` varchar(32) NOT NULL,
1807
  `has_priority` tinyint(1) NULL default NULL,
1808
  `rule_value` varchar(32) NOT NULL,
1808
  `rule_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
1809
  `rule_value` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
1809
  PRIMARY KEY (`id`),
1810
  PRIMARY KEY (`id`),
1810
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1811
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1811
  KEY `circ_rules_ibfk_2` (`categorycode`),
1812
  KEY `circ_rules_ibfk_2` (`categorycode`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-150 / +138 lines)
Lines 117-210 Link Here
117
                            <th>Note</th>
117
                            <th>Note</th>
118
                            [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
118
                            [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
119
                <th>Current checkouts allowed</th>
119
                <th>Current checkouts allowed</th>
120
                            <th>Current on-site checkouts allowed</th>
120
                <th>Current on-site checkouts allowed</th>
121
                            <th>Loan period</th>
121
                <th>Loan period</th>
122
                            <th>Days mode</th>
122
                <th>Days mode</th>
123
                            <th>Unit</th>
123
                <th>Unit</th>
124
                            <th>Hard due date</th>
124
                <th>Hard due date</th>
125
                            <th>Decreased loan period for high holds (day)</th>
125
                <th>Decreased loan period for high holds (day)</th>
126
                            <th>Fine amount</th>
126
                <th>Fine amount</th>
127
                            <th>Fine charging interval</th>
127
                <th>Fine charging interval</th>
128
                            <th>When to charge</th>
128
                <th>When to charge</th>
129
                            <th>Fine/suspension grace period</th>
129
                <th>Fine grace period</th>
130
                            <th>Overdue fines cap (amount)</th>
130
                <th>Overdue fines cap (amount)</th>
131
                            <th>Cap fine at replacement price</th>
131
                <th>Cap fine at replacement price</th>
132
                            <th>Suspension in days (day)</th>
132
                <th>Suspension in days (day)</th>
133
                            <th>Max. suspension duration (day)</th>
133
                <th>Max. suspension duration (day)</th>
134
                            <th>Suspension charging interval</th>
134
                <th>Suspension charging interval</th>
135
                            <th>Renewals allowed (count)</th>
135
                <th>Renewals allowed (count)</th>
136
                            [% IF Koha.Preference('UnseenRenewals') %]
136
                [% IF Koha.Preference('UnseenRenewals') %]
137
                            <th>Unseen renewals allowed (count)</th>
137
                <th>Unseen renewals allowed (count)</th>
138
                            [% END %]
138
                [% END %]
139
                            <th>Renewal period</th>
139
                <th>Renewal period</th>
140
                            <th>No renewal before</th>
140
                <th>No renewal before</th>
141
                            <th>Automatic renewal</th>
141
                <th>Automatic renewal</th>
142
                            <th>No automatic renewal after</th>
142
                <th>No automatic renewal after</th>
143
                            <th>No automatic renewal after (hard limit)</th>
143
                <th>No automatic renewal after (hard limit)</th>
144
                            <th>Holds allowed (total)</th>
144
                <th>Holds allowed (total)</th>
145
                            <th>Holds allowed (daily)</th>
145
                <th>Holds allowed (daily)</th>
146
                            <th>Holds per record (count)</th>
146
                <th>Holds per record (count)</th>
147
                            <th>On shelf holds allowed</th>
147
                <th>On shelf holds allowed</th>
148
                            <th>OPAC item level holds</th>
148
                <th>OPAC item level holds</th>
149
                            [% IF Koha.Preference('ArticleRequests') %]
149
                <th>Article requests</th>
150
                            <th>Article requests</th>
150
                <th>Rental discount (%)</th>
151
                            [% END %]
151
                <th class="noExport">Actions</th>
152
                            <th>Rental discount (%)</th>
152
            </tr>
153
                            [% IF Koha.Preference('UseRecalls') %]
153
            </thead>
154
                                <th>Recalls allowed (total)</th>
154
            <tbody>
155
                                <th>Recalls per record (count)</th>
155
                [% SET row_count = 0 %]
156
                                <th>On shelf recalls allowed</th>
156
                [% FOREACH c IN categorycodes %]
157
                                <th>Recall due date interval (day)</th>
157
                    [% SET c = '' UNLESS c.defined %]
158
                                <th>Recall overdue fine amount</th>
158
                    [% FOREACH i IN itemtypes %]
159
                                <th>Recall pickup period (day)</th>
159
                        [% SET i = '' UNLESS i.defined %]
160
                            [% END %]
160
                        [% SET note = all_rules.$c.$i.note %]
161
                            <th class="noExport">Actions</th>
161
                        [% SET has_priority = all_rules.$c.$i.has_priority %]
162
                        </tr>
162
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
163
                        </thead>
163
                        [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
164
                        <tbody>
164
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
165
                            [% SET row_count = 0 %]
165
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
166
                            [% FOREACH c IN categorycodes %]
166
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
167
                                [% SET c = '' UNLESS c.defined %]
167
                        [% SET hardduedate = all_rules.$c.$i.hardduedate %]
168
                                [% FOREACH i IN itemtypes %]
168
                        [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
169
                                    [% SET i = '' UNLESS i.defined %]
169
                        [% SET fine = all_rules.$c.$i.fine %]
170
                                    [% SET note = all_rules.$c.$i.note %]
170
                        [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
171
                                    [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
171
                        [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
172
                                    [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
172
                        [% SET firstremind = all_rules.$c.$i.firstremind %]
173
                                    [% SET issuelength = all_rules.$c.$i.issuelength %]
173
                        [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
174
                                    [% SET daysmode = all_rules.$c.$i.daysmode %]
174
                        [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
175
                                    [% SET lengthunit = all_rules.$c.$i.lengthunit %]
175
                        [% SET finedays = all_rules.$c.$i.finedays %]
176
                                    [% SET hardduedate = all_rules.$c.$i.hardduedate %]
176
                        [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
177
                                    [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
177
                        [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
178
                                    [% SET fine = all_rules.$c.$i.fine %]
178
                        [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
179
                                    [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
179
                        [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %]
180
                                    [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
180
                        [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
181
                                    [% SET firstremind = all_rules.$c.$i.firstremind %]
181
                        [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
182
                                    [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
182
                        [% SET auto_renew = all_rules.$c.$i.auto_renew %]
183
                                    [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
183
                        [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
184
                                    [% SET finedays = all_rules.$c.$i.finedays %]
184
                        [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
185
                                    [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
185
                        [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
186
                                    [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
186
                        [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
187
                                    [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
187
                        [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
188
                                    [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %]
188
                        [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
189
                                    [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
189
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
190
                                    [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
190
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
191
                                    [% SET auto_renew = all_rules.$c.$i.auto_renew %]
191
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
192
                                    [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
192
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
193
                                    [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
194
                                    [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
195
                                    [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
196
                                    [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
197
                                    [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
198
                                    [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
199
                                    [% SET article_requests = all_rules.$c.$i.article_requests %]
200
                                    [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
201
                                    [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
202
                                    [% SET recalls_allowed = all_rules.$c.$i.recalls_allowed %]
203
                                    [% SET recalls_per_record = all_rules.$c.$i.recalls_per_record %]
204
                                    [% SET on_shelf_recalls = all_rules.$c.$i.on_shelf_recalls %]
205
                                    [% SET recall_due_date_interval = all_rules.$c.$i.recall_due_date_interval %]
206
                                    [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %]
207
                                    [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %]
208
193
209
                                    [% 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 %]
194
                                    [% 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 %]
210
                                    [% IF show_rule %]
195
                                    [% IF show_rule %]
Lines 245-251 Link Here
245
                                                </td>
230
                                                </td>
246
                                                [% UNLESS humanbranch %]
231
                                                [% UNLESS humanbranch %]
247
                                    <td>
232
                                    <td>
248
                                        [% IF rule.has_priority %]
233
                                        [% IF has_priority.defined && has_priority %]
249
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
234
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
250
                                        [% ELSE %]
235
                                        [% ELSE %]
251
                                            <input type="checkbox" disabled="disabled"/>
236
                                            <input type="checkbox" disabled="disabled"/>
Lines 766-831 Link Here
766
                                            Not set
751
                                            Not set
767
                                        </option>
752
                                        </option>
768
753
769
                                        [% IF returnbranch.rule_value == 'homebranch' %]
754
                            [% IF returnbranch == 'homebranch' %]
770
                                        <option value="homebranch" selected="selected">
755
                            <option value="homebranch" selected="selected">
771
                                        [% ELSE %]
756
                            [% ELSE %]
772
                                        <option value="homebranch">
757
                            <option value="homebranch">
773
                                        [% END %]
758
                            [% END %]
774
                                            Item returns home
759
                                Item returns home
775
                                        </option>
760
                            </option>
776
                                        [% IF returnbranch.rule_value == 'holdingbranch' %]
761
                            [% IF returnbranch == 'holdingbranch' %]
777
                                        <option value="holdingbranch" selected="selected">
762
                            <option value="holdingbranch" selected="selected">
778
                                        [% ELSE %]
763
                            [% ELSE %]
779
                                        <option value="holdingbranch">
764
                            <option value="holdingbranch">
780
                                        [% END %]
765
                            [% END %]
781
                                            Item returns to issuing library
766
                                Item returns to issuing library
782
                                        </option>
767
                            </option>
783
                                        [% IF returnbranch.rule_value == 'noreturn' %]
768
                            [% IF returnbranch == 'noreturn' %]
784
                                        <option value="noreturn" selected="selected">
769
                            <option value="noreturn" selected="selected">
785
                                        [% ELSE %]
770
                            [% ELSE %]
786
                                        <option value="noreturn">
771
                            <option value="noreturn">
787
                                        [% END %]
772
                            [% END %]
788
                                            Item floats
773
                                Item floats
789
                                        </option>
774
                            </option>
790
                                    </select>
775
                        </select>
791
                                </td>
776
                    </td>
792
                                <td class="actions">
777
                    <td class="actions">
793
                                    <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
778
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
794
                                    [% IF ( default_checkout_hold_and_return_policy ) %]
779
                        <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>
795
                                        <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>
780
                    </td>
796
                                    [% END %]
781
                </tr>
797
                                </td>
782
            </table>
798
                            </tr>
783
        </form>
799
                        </table>
784
    </div>
800
                    </form>
785
    [% IF ( show_branch_cat_rule_form ) %]
801
                </div>
786
    <div id="holds-policy-by-patron-category" class="container">
802
787
    <h3>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h3>
803
                [% IF ( show_branch_cat_rule_form ) %]
788
        <p>For this library, you can specify the maximum number of loans that
804
                <div id="holds-policy-by-patron-category" class="page-section">
789
            a patron of a given category can make, regardless of the item type.
805
                    <h2>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h2>
790
        </p>
806
                    <p>For this library, you can specify the maximum number of loans that
791
        <p>If the total amount loanable for a given patron category is left blank,
807
                        a patron of a given category can make, regardless of the item type.
792
           no limit applies, except possibly for a limit you define for a specific item type.
808
                    </p>
793
        </p>
809
                    <p>If the total amount loanable for a given patron category is left blank,
794
        <p>
810
                       no limit applies, except possibly for a limit you define for a specific item type.
795
            <b>Has priority: </b>If checked, the rule will override those for all branches. Else
811
                    </p>
796
            it behaves like a default one: used if no rule exists for the coresponding branch.
812
                    <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
797
        </p>
813
                        <input type="hidden" name="op" value="add-branch-cat" />
798
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
814
                        <input type="hidden" name="branch" value="[% current_branch | html %]"/>
799
            <input type="hidden" name="op" value="add-branch-cat" />
815
                        <table>
800
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
816
                            <tr>
801
            <table>
817
                                <th>Patron category</th>
802
                <tr>
818
                                <th>Total current checkouts allowed</th>
803
                    <th>Patron category</th>
819
                                <th>Total current on-site checkouts allowed</th>
804
                    <th>Total current checkouts allowed</th>
820
                                <th>Total holds allowed</th>
805
                    <th>Total current on-site checkouts allowed</th>
821
                                <th>&nbsp;</th>
806
                    <th>Total holds allowed</th>
822
                            </tr>
807
                    [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
823
                            [% FOREACH c IN categorycodes %]
808
                    <th>&nbsp;</th>
824
                                [% NEXT UNLESS c %]
809
                </tr>
825
                                [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
810
                [% SET i = '' %]
826
                                [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
811
                [% FOREACH c IN categorycodes %]
827
                                [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
812
                    [% NEXT UNLESS c %]
828
813
                    [% SET patron_maxissueqty = all_rules.$c.$i.patron_maxissueqty %]
814
                    [% SET patron_maxonsiteissueqty = all_rules.$c.$i.patron_maxonsiteissueqty %]
815
                    [% SET max_holds = all_rules.$c.$i.max_holds %]
816
                    [% SET has_priority = all_rules.$c.$i.has_priority %]
829
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
817
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
830
                    <tr>
818
                    <tr>
831
                        <td>
819
                        <td>
Lines 858-864 Link Here
858
                        </td>
846
                        </td>
859
                        [% UNLESS humanbranch %]
847
                        [% UNLESS humanbranch %]
860
                            <td>
848
                            <td>
861
                                [% IF branch_cat_rule_loo.has_priority %]
849
                                [% IF has_priority.defined && has_priority %]
862
                                    <input type="checkbox" checked="checked" disabled/>
850
                                    <input type="checkbox" checked="checked" disabled/>
863
                                [% ELSE %]
851
                                [% ELSE %]
864
                                    <input type="checkbox" disabled/>
852
                                    <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