Lines 51-57
our $RULE_KINDS = {
Link Here
|
51 |
}, |
51 |
}, |
52 |
|
52 |
|
53 |
patron_maxissueqty => { |
53 |
patron_maxissueqty => { |
54 |
scope => [ 'branchcode', 'categorycode' ], |
54 |
scope => [ 'branchcode', 'categorycode', 'checkout_type' ], |
55 |
}, |
55 |
}, |
56 |
patron_maxonsiteissueqty => { |
56 |
patron_maxonsiteissueqty => { |
57 |
scope => [ 'branchcode', 'categorycode' ], |
57 |
scope => [ 'branchcode', 'categorycode' ], |
Lines 74-104
our $RULE_KINDS = {
Link Here
|
74 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
74 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
75 |
}, |
75 |
}, |
76 |
auto_renew => { |
76 |
auto_renew => { |
77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
77 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
78 |
}, |
78 |
}, |
79 |
cap_fine_to_replacement_price => { |
79 |
cap_fine_to_replacement_price => { |
80 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
80 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
81 |
}, |
81 |
}, |
82 |
chargeperiod => { |
82 |
chargeperiod => { |
83 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
83 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
84 |
}, |
84 |
}, |
85 |
chargeperiod_charge_at => { |
85 |
chargeperiod_charge_at => { |
86 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
86 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
87 |
}, |
87 |
}, |
88 |
fine => { |
88 |
fine => { |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
90 |
}, |
90 |
}, |
91 |
finedays => { |
91 |
finedays => { |
92 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
92 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
93 |
}, |
93 |
}, |
94 |
firstremind => { |
94 |
firstremind => { |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
96 |
}, |
96 |
}, |
97 |
hardduedate => { |
97 |
hardduedate => { |
98 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
98 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
99 |
}, |
99 |
}, |
100 |
hardduedatecompare => { |
100 |
hardduedatecompare => { |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
102 |
}, |
102 |
}, |
103 |
holds_per_day => { |
103 |
holds_per_day => { |
104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
Lines 107-134
our $RULE_KINDS = {
Link Here
|
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
108 |
}, |
108 |
}, |
109 |
issuelength => { |
109 |
issuelength => { |
110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
110 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
111 |
}, |
111 |
}, |
112 |
lengthunit => { |
112 |
lengthunit => { |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
114 |
}, |
114 |
}, |
115 |
maxissueqty => { |
115 |
maxissueqty => { |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
117 |
}, |
117 |
}, |
118 |
maxonsiteissueqty => { |
118 |
maxonsiteissueqty => { |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
120 |
}, |
120 |
}, |
121 |
maxsuspensiondays => { |
121 |
maxsuspensiondays => { |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
123 |
}, |
123 |
}, |
124 |
no_auto_renewal_after => { |
124 |
no_auto_renewal_after => { |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
126 |
}, |
126 |
}, |
127 |
no_auto_renewal_after_hard_limit => { |
127 |
no_auto_renewal_after_hard_limit => { |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
129 |
}, |
129 |
}, |
130 |
norenewalbefore => { |
130 |
norenewalbefore => { |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
132 |
}, |
132 |
}, |
133 |
onshelfholds => { |
133 |
onshelfholds => { |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
Lines 137-161
our $RULE_KINDS = {
Link Here
|
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
138 |
}, |
138 |
}, |
139 |
overduefinescap => { |
139 |
overduefinescap => { |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
141 |
}, |
141 |
}, |
142 |
renewalperiod => { |
142 |
renewalperiod => { |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
144 |
}, |
144 |
}, |
145 |
renewalsallowed => { |
145 |
renewalsallowed => { |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
147 |
}, |
147 |
}, |
148 |
rentaldiscount => { |
148 |
rentaldiscount => { |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
150 |
}, |
150 |
}, |
151 |
reservesallowed => { |
151 |
reservesallowed => { |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
153 |
}, |
153 |
}, |
154 |
suspension_chargeperiod => { |
154 |
suspension_chargeperiod => { |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
156 |
}, |
156 |
}, |
157 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
157 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
159 |
}, |
159 |
}, |
160 |
# Not included (deprecated?): |
160 |
# Not included (deprecated?): |
161 |
# * accountsent |
161 |
# * accountsent |
Lines 177-198
sub get_effective_rule {
Link Here
|
177 |
$params->{categorycode} //= undef; |
177 |
$params->{categorycode} //= undef; |
178 |
$params->{branchcode} //= undef; |
178 |
$params->{branchcode} //= undef; |
179 |
$params->{itemtype} //= undef; |
179 |
$params->{itemtype} //= undef; |
|
|
180 |
$params->{checkout_type} //= undef; |
180 |
|
181 |
|
181 |
my $rule_name = $params->{rule_name}; |
182 |
my $rule_name = $params->{rule_name}; |
182 |
my $categorycode = $params->{categorycode}; |
183 |
my $categorycode = $params->{categorycode}; |
183 |
my $itemtype = $params->{itemtype}; |
184 |
my $itemtype = $params->{itemtype}; |
184 |
my $branchcode = $params->{branchcode}; |
185 |
my $branchcode = $params->{branchcode}; |
|
|
186 |
my $checkout_type = $params->{checkout_type}; |
185 |
|
187 |
|
186 |
Koha::Exceptions::MissingParameter->throw( |
188 |
Koha::Exceptions::MissingParameter->throw( |
187 |
"Required parameter 'rule_name' missing") |
189 |
"Required parameter 'rule_name' missing") |
188 |
unless $rule_name; |
190 |
unless $rule_name; |
189 |
|
191 |
|
190 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
192 |
for my $v ( $branchcode, $categorycode, $itemtype, $checkout_type ) { |
191 |
$v = undef if $v and $v eq '*'; |
193 |
$v = undef if $v and $v eq '*'; |
192 |
} |
194 |
} |
193 |
|
195 |
|
194 |
my $order_by = $params->{order_by} |
196 |
my $order_by = $params->{order_by} |
195 |
// { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; |
197 |
// { -desc => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ] }; |
196 |
|
198 |
|
197 |
my $search_params; |
199 |
my $search_params; |
198 |
$search_params->{rule_name} = $rule_name; |
200 |
$search_params->{rule_name} = $rule_name; |
Lines 200-205
sub get_effective_rule {
Link Here
|
200 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
202 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
201 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
203 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
202 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
204 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
|
|
205 |
$search_params->{checkout_type} = defined $checkout_type ? [ $checkout_type, undef ] : undef; |
203 |
|
206 |
|
204 |
my $rule = $self->search( |
207 |
my $rule = $self->search( |
205 |
$search_params, |
208 |
$search_params, |
Lines 222-227
sub get_effective_rules {
Link Here
|
222 |
my $rules = $params->{rules}; |
225 |
my $rules = $params->{rules}; |
223 |
my $categorycode = $params->{categorycode}; |
226 |
my $categorycode = $params->{categorycode}; |
224 |
my $itemtype = $params->{itemtype}; |
227 |
my $itemtype = $params->{itemtype}; |
|
|
228 |
my $checkout_type = $params->{checkout_type}; |
225 |
my $branchcode = $params->{branchcode}; |
229 |
my $branchcode = $params->{branchcode}; |
226 |
|
230 |
|
227 |
my $r; |
231 |
my $r; |
Lines 231-236
sub get_effective_rules {
Link Here
|
231 |
rule_name => $rule, |
235 |
rule_name => $rule, |
232 |
categorycode => $categorycode, |
236 |
categorycode => $categorycode, |
233 |
itemtype => $itemtype, |
237 |
itemtype => $itemtype, |
|
|
238 |
checkout_type => $checkout_type, |
234 |
branchcode => $branchcode, |
239 |
branchcode => $branchcode, |
235 |
} |
240 |
} |
236 |
); |
241 |
); |
Lines 260-266
sub set_rule {
Link Here
|
260 |
unless defined $kind_info; |
265 |
unless defined $kind_info; |
261 |
|
266 |
|
262 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
267 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
263 |
foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) { |
268 |
foreach my $scope_level ( qw( branchcode categorycode itemtype checkout_type ) ) { |
264 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
269 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
265 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
270 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
266 |
unless exists $params->{$scope_level}; |
271 |
unless exists $params->{$scope_level}; |
Lines 273-282
sub set_rule {
Link Here
|
273 |
my $branchcode = $params->{branchcode}; |
278 |
my $branchcode = $params->{branchcode}; |
274 |
my $categorycode = $params->{categorycode}; |
279 |
my $categorycode = $params->{categorycode}; |
275 |
my $itemtype = $params->{itemtype}; |
280 |
my $itemtype = $params->{itemtype}; |
|
|
281 |
my $checkout_type = $params->{checkout_type}; |
276 |
my $rule_name = $params->{rule_name}; |
282 |
my $rule_name = $params->{rule_name}; |
277 |
my $rule_value = $params->{rule_value}; |
283 |
my $rule_value = $params->{rule_value}; |
278 |
|
284 |
|
279 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
285 |
for my $v ( $branchcode, $categorycode, $itemtype, $checkout_type ) { |
280 |
$v = undef if $v and $v eq '*'; |
286 |
$v = undef if $v and $v eq '*'; |
281 |
} |
287 |
} |
282 |
my $rule = $self->search( |
288 |
my $rule = $self->search( |
Lines 285-290
sub set_rule {
Link Here
|
285 |
branchcode => $branchcode, |
291 |
branchcode => $branchcode, |
286 |
categorycode => $categorycode, |
292 |
categorycode => $categorycode, |
287 |
itemtype => $itemtype, |
293 |
itemtype => $itemtype, |
|
|
294 |
checkout_type => $checkout_type, |
288 |
} |
295 |
} |
289 |
)->next(); |
296 |
)->next(); |
290 |
|
297 |
|
Lines 304-309
sub set_rule {
Link Here
|
304 |
branchcode => $branchcode, |
311 |
branchcode => $branchcode, |
305 |
categorycode => $categorycode, |
312 |
categorycode => $categorycode, |
306 |
itemtype => $itemtype, |
313 |
itemtype => $itemtype, |
|
|
314 |
checkout_type => $checkout_type, |
307 |
rule_name => $rule_name, |
315 |
rule_name => $rule_name, |
308 |
rule_value => $rule_value, |
316 |
rule_value => $rule_value, |
309 |
} |
317 |
} |