Lines 45-162
Any attempt to set a rule with a nonsensical scope (for instance, setting the C<
Link Here
|
45 |
|
45 |
|
46 |
=cut |
46 |
=cut |
47 |
|
47 |
|
|
|
48 |
my $scope1 = [ 'branchcode', 'categorycode' ]; |
49 |
my $scope2 = [ 'branchcode', 'itemtype' ]; |
50 |
my $scope3 = [ 'branchcode', 'categorycode', 'itemtype' ]; |
51 |
|
48 |
our $RULE_KINDS = { |
52 |
our $RULE_KINDS = { |
49 |
refund => { |
53 |
refund => { scope => ['branchcode'] }, |
50 |
scope => [ 'branchcode' ], |
54 |
|
51 |
}, |
55 |
patron_maxissueqty => { scope => $scope1 }, |
52 |
|
56 |
patron_maxonsiteissueqty => { scope => $scope1 }, |
53 |
patron_maxissueqty => { |
57 |
max_holds => { scope => $scope1 }, |
54 |
scope => [ 'branchcode', 'categorycode' ], |
58 |
|
55 |
}, |
59 |
holdallowed => { scope => $scope2 }, |
56 |
patron_maxonsiteissueqty => { |
60 |
hold_fulfillment_policy => { scope => $scope2 }, |
57 |
scope => [ 'branchcode', 'categorycode' ], |
61 |
returnbranch => { scope => $scope2 }, |
58 |
}, |
62 |
|
59 |
max_holds => { |
63 |
article_requests => { scope => $scope3 }, |
60 |
scope => [ 'branchcode', 'categorycode' ], |
64 |
auto_renew => { scope => $scope3 }, |
61 |
}, |
65 |
cap_fine_to_replacement_price => { scope => $scope3 }, |
62 |
|
66 |
chargeperiod => { scope => $scope3 }, |
63 |
holdallowed => { |
67 |
chargeperiod_charge_at => { scope => $scope3 }, |
64 |
scope => [ 'branchcode', 'itemtype' ], |
68 |
fine => { scope => $scope3 }, |
65 |
}, |
69 |
finedays => { scope => $scope3 }, |
66 |
hold_fulfillment_policy => { |
70 |
firstremind => { scope => $scope3 }, |
67 |
scope => [ 'branchcode', 'itemtype' ], |
71 |
hardduedate => { scope => $scope3 }, |
68 |
}, |
72 |
hardduedatecompare => { scope => $scope3 }, |
69 |
returnbranch => { |
73 |
holds_per_day => { scope => $scope3 }, |
70 |
scope => [ 'branchcode', 'itemtype' ], |
74 |
holds_per_record => { scope => $scope3 }, |
71 |
}, |
75 |
issuelength => { scope => $scope3 }, |
72 |
|
76 |
lengthunit => { scope => $scope3 }, |
73 |
article_requests => { |
77 |
maxissueqty => { scope => $scope3 }, |
74 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
78 |
maxonsiteissueqty => { scope => $scope3 }, |
75 |
}, |
79 |
maxsuspensiondays => { scope => $scope3 }, |
76 |
auto_renew => { |
80 |
no_auto_renewal_after => { scope => $scope3 }, |
77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
81 |
no_auto_renewal_after_hard_limit => { scope => $scope3 }, |
78 |
}, |
82 |
norenewalbefore => { scope => $scope3 }, |
79 |
cap_fine_to_replacement_price => { |
83 |
onshelfholds => { scope => $scope3 }, |
80 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
84 |
opacitemholds => { scope => $scope3 }, |
81 |
}, |
85 |
overduefinescap => { scope => $scope3 }, |
82 |
chargeperiod => { |
86 |
renewalperiod => { scope => $scope3 }, |
83 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
87 |
renewalsallowed => { scope => $scope3 }, |
84 |
}, |
88 |
rentaldiscount => { scope => $scope3 }, |
85 |
chargeperiod_charge_at => { |
89 |
reservesallowed => { scope => $scope3 }, |
86 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
90 |
suspension_chargeperiod => { scope => $scope3 }, |
87 |
}, |
91 |
|
88 |
fine => { |
92 |
note => { scope => $scope3 }, |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
93 |
# This is not really a rule. Maybe we will want to separate this later. |
90 |
}, |
94 |
|
91 |
finedays => { |
|
|
92 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
93 |
}, |
94 |
firstremind => { |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
96 |
}, |
97 |
hardduedate => { |
98 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
99 |
}, |
100 |
hardduedatecompare => { |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
102 |
}, |
103 |
holds_per_day => { |
104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
105 |
}, |
106 |
holds_per_record => { |
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
108 |
}, |
109 |
issuelength => { |
110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
111 |
}, |
112 |
lengthunit => { |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
114 |
}, |
115 |
maxissueqty => { |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
117 |
}, |
118 |
maxonsiteissueqty => { |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
120 |
}, |
121 |
maxsuspensiondays => { |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
123 |
}, |
124 |
no_auto_renewal_after => { |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
126 |
}, |
127 |
no_auto_renewal_after_hard_limit => { |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
129 |
}, |
130 |
norenewalbefore => { |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
132 |
}, |
133 |
onshelfholds => { |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
135 |
}, |
136 |
opacitemholds => { |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
138 |
}, |
139 |
overduefinescap => { |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
141 |
}, |
142 |
renewalperiod => { |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
144 |
}, |
145 |
renewalsallowed => { |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
147 |
}, |
148 |
rentaldiscount => { |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
150 |
}, |
151 |
reservesallowed => { |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
153 |
}, |
154 |
suspension_chargeperiod => { |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
156 |
}, |
157 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
159 |
}, |
160 |
# Not included (deprecated?): |
95 |
# Not included (deprecated?): |
161 |
# * accountsent |
96 |
# * accountsent |
162 |
# * reservecharge |
97 |
# * reservecharge |
Lines 192-198
sub get_effective_rule {
Link Here
|
192 |
} |
127 |
} |
193 |
|
128 |
|
194 |
my $order_by = $params->{order_by} |
129 |
my $order_by = $params->{order_by} |
195 |
// { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; |
130 |
// { -desc => $scope3 }; |
196 |
|
131 |
|
197 |
my $search_params; |
132 |
my $search_params; |
198 |
$search_params->{rule_name} = $rule_name; |
133 |
$search_params->{rule_name} = $rule_name; |
Lines 260-266
sub set_rule {
Link Here
|
260 |
unless defined $kind_info; |
195 |
unless defined $kind_info; |
261 |
|
196 |
|
262 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
197 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
263 |
foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) { |
198 |
foreach my $scope_level ( @$scope3 ) { |
264 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
199 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
265 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
200 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
266 |
unless exists $params->{$scope_level}; |
201 |
unless exists $params->{$scope_level}; |
267 |
- |
|
|