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

(-)a/Koha/CirculationRules.pm (+5 lines)
Lines 62-73 our $RULE_KINDS = { Link Here
62
62
63
    holdallowed => {
63
    holdallowed => {
64
        scope => [ 'branchcode', 'itemtype' ],
64
        scope => [ 'branchcode', 'itemtype' ],
65
        can_be_blank => 0,
65
    },
66
    },
66
    hold_fulfillment_policy => {
67
    hold_fulfillment_policy => {
67
        scope => [ 'branchcode', 'itemtype' ],
68
        scope => [ 'branchcode', 'itemtype' ],
69
        can_be_blank => 0,
68
    },
70
    },
69
    returnbranch => {
71
    returnbranch => {
70
        scope => [ 'branchcode', 'itemtype' ],
72
        scope => [ 'branchcode', 'itemtype' ],
73
        can_be_blank => 0,
71
    },
74
    },
72
75
73
    article_requests => {
76
    article_requests => {
Lines 278-283 sub set_rule { Link Here
278
    my $itemtype     = $params->{itemtype};
281
    my $itemtype     = $params->{itemtype};
279
    my $rule_name    = $params->{rule_name};
282
    my $rule_name    = $params->{rule_name};
280
    my $rule_value   = $params->{rule_value};
283
    my $rule_value   = $params->{rule_value};
284
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
285
    $rule_value = undef if $rule_value eq "" && !$can_be_blank;
281
286
282
    for my $v ( $branchcode, $categorycode, $itemtype ) {
287
    for my $v ( $branchcode, $categorycode, $itemtype ) {
283
        $v = undef if $v and $v eq '*';
288
        $v = undef if $v and $v eq '*';
(-)a/admin/smart-rules.pl (-2 lines)
Lines 341-348 elsif ($op eq "set-branch-defaults") { Link Here
341
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
341
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
342
    my $returnbranch  = $input->param('returnbranch');
342
    my $returnbranch  = $input->param('returnbranch');
343
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
343
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
344
    $holdallowed =~ s/\s//g;
345
    $holdallowed = undef if $holdallowed !~ /^\d+/;
346
344
347
    if ($branch eq "*") {
345
    if ($branch eq "*") {
348
        Koha::CirculationRules->set_rules(
346
        Koha::CirculationRules->set_rules(
(-)a/t/db_dependent/Koha/CirculationRules.t (-2 / +26 lines)
Lines 33-39 my $schema = Koha::Database->new->schema; Link Here
33
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
34
34
35
subtest 'set_rule + get_effective_rule' => sub {
35
subtest 'set_rule + get_effective_rule' => sub {
36
    plan tests => 8;
36
    plan tests => 9;
37
37
38
    $schema->storage->txn_begin;
38
    $schema->storage->txn_begin;
39
39
Lines 102-107 subtest 'set_rule + get_effective_rule' => sub { Link Here
102
    is( $rule->rule_value, 1,
102
    is( $rule->rule_value, 1,
103
        'Default rule is returned if there is no rule for this branchcode' );
103
        'Default rule is returned if there is no rule for this branchcode' );
104
104
105
    subtest 'test rules that cannot be blank' => sub {
106
        plan tests => 3;
107
        foreach my $no_blank_rule ( ('holdallowed','hold_fulfillment_policy','returnbranch') ){
108
            Koha::CirculationRules->set_rule(
109
                {
110
                    branchcode   => $branchcode,
111
                    itemtype     => '*',
112
                    rule_name    => $no_blank_rule,
113
                    rule_value   => '',
114
                }
115
            );
116
117
            $rule = Koha::CirculationRules->get_effective_rule(
118
                {
119
                    branchcode   => $branchcode,
120
                    categorycode => undef,
121
                    itemtype     => undef,
122
                    rule_name    => $no_blank_rule,
123
                }
124
            );
125
            is( $rule, undef, 'Rules that cannot be blank are not set when passed blank string' );
126
        }
127
    };
128
129
105
    subtest 'test rule matching with different combinations of rule scopes' => sub {
130
    subtest 'test rule matching with different combinations of rule scopes' => sub {
106
        my ( $tests, $order ) = prepare_tests_for_rule_scope_combinations(
131
        my ( $tests, $order ) = prepare_tests_for_rule_scope_combinations(
107
            {
132
            {
108
- 

Return to bug 26529