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-137
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 |
daysmode => { |
112 |
daysmode => { |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
114 |
}, |
114 |
}, |
115 |
lengthunit => { |
115 |
lengthunit => { |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
117 |
}, |
117 |
}, |
118 |
maxissueqty => { |
118 |
maxissueqty => { |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
120 |
}, |
120 |
}, |
121 |
maxonsiteissueqty => { |
121 |
maxonsiteissueqty => { |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
123 |
}, |
123 |
}, |
124 |
maxsuspensiondays => { |
124 |
maxsuspensiondays => { |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
126 |
}, |
126 |
}, |
127 |
no_auto_renewal_after => { |
127 |
no_auto_renewal_after => { |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
129 |
}, |
129 |
}, |
130 |
no_auto_renewal_after_hard_limit => { |
130 |
no_auto_renewal_after_hard_limit => { |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
132 |
}, |
132 |
}, |
133 |
norenewalbefore => { |
133 |
norenewalbefore => { |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
135 |
}, |
135 |
}, |
136 |
onshelfholds => { |
136 |
onshelfholds => { |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
Lines 140-164
our $RULE_KINDS = {
Link Here
|
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
141 |
}, |
141 |
}, |
142 |
overduefinescap => { |
142 |
overduefinescap => { |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
144 |
}, |
144 |
}, |
145 |
renewalperiod => { |
145 |
renewalperiod => { |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
147 |
}, |
147 |
}, |
148 |
renewalsallowed => { |
148 |
renewalsallowed => { |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
150 |
}, |
150 |
}, |
151 |
rentaldiscount => { |
151 |
rentaldiscount => { |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
153 |
}, |
153 |
}, |
154 |
reservesallowed => { |
154 |
reservesallowed => { |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
156 |
}, |
156 |
}, |
157 |
suspension_chargeperiod => { |
157 |
suspension_chargeperiod => { |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
159 |
}, |
159 |
}, |
160 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
160 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ], |
162 |
}, |
162 |
}, |
163 |
# Not included (deprecated?): |
163 |
# Not included (deprecated?): |
164 |
# * accountsent |
164 |
# * accountsent |
Lines 180-201
sub get_effective_rule {
Link Here
|
180 |
$params->{categorycode} //= undef; |
180 |
$params->{categorycode} //= undef; |
181 |
$params->{branchcode} //= undef; |
181 |
$params->{branchcode} //= undef; |
182 |
$params->{itemtype} //= undef; |
182 |
$params->{itemtype} //= undef; |
|
|
183 |
$params->{checkout_type} //= undef; |
183 |
|
184 |
|
184 |
my $rule_name = $params->{rule_name}; |
185 |
my $rule_name = $params->{rule_name}; |
185 |
my $categorycode = $params->{categorycode}; |
186 |
my $categorycode = $params->{categorycode}; |
186 |
my $itemtype = $params->{itemtype}; |
187 |
my $itemtype = $params->{itemtype}; |
187 |
my $branchcode = $params->{branchcode}; |
188 |
my $branchcode = $params->{branchcode}; |
|
|
189 |
my $checkout_type = $params->{checkout_type}; |
188 |
|
190 |
|
189 |
Koha::Exceptions::MissingParameter->throw( |
191 |
Koha::Exceptions::MissingParameter->throw( |
190 |
"Required parameter 'rule_name' missing") |
192 |
"Required parameter 'rule_name' missing") |
191 |
unless $rule_name; |
193 |
unless $rule_name; |
192 |
|
194 |
|
193 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
195 |
for my $v ( $branchcode, $categorycode, $itemtype, $checkout_type ) { |
194 |
$v = undef if $v and $v eq '*'; |
196 |
$v = undef if $v and $v eq '*'; |
195 |
} |
197 |
} |
196 |
|
198 |
|
197 |
my $order_by = $params->{order_by} |
199 |
my $order_by = $params->{order_by} |
198 |
// { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; |
200 |
// { -desc => [ 'branchcode', 'checkout_type', 'categorycode', 'itemtype', ] }; |
199 |
|
201 |
|
200 |
my $search_params; |
202 |
my $search_params; |
201 |
$search_params->{rule_name} = $rule_name; |
203 |
$search_params->{rule_name} = $rule_name; |
Lines 203-208
sub get_effective_rule {
Link Here
|
203 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
205 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
204 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
206 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
205 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
207 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
|
|
208 |
$search_params->{checkout_type} = defined $checkout_type ? [ $checkout_type, undef ] : undef; |
206 |
|
209 |
|
207 |
my $rule = $self->search( |
210 |
my $rule = $self->search( |
208 |
$search_params, |
211 |
$search_params, |
Lines 225-230
sub get_effective_rules {
Link Here
|
225 |
my $rules = $params->{rules}; |
228 |
my $rules = $params->{rules}; |
226 |
my $categorycode = $params->{categorycode}; |
229 |
my $categorycode = $params->{categorycode}; |
227 |
my $itemtype = $params->{itemtype}; |
230 |
my $itemtype = $params->{itemtype}; |
|
|
231 |
my $checkout_type = $params->{checkout_type}; |
228 |
my $branchcode = $params->{branchcode}; |
232 |
my $branchcode = $params->{branchcode}; |
229 |
|
233 |
|
230 |
my $r; |
234 |
my $r; |
Lines 234-239
sub get_effective_rules {
Link Here
|
234 |
rule_name => $rule, |
238 |
rule_name => $rule, |
235 |
categorycode => $categorycode, |
239 |
categorycode => $categorycode, |
236 |
itemtype => $itemtype, |
240 |
itemtype => $itemtype, |
|
|
241 |
checkout_type => $checkout_type, |
237 |
branchcode => $branchcode, |
242 |
branchcode => $branchcode, |
238 |
} |
243 |
} |
239 |
); |
244 |
); |
Lines 263-269
sub set_rule {
Link Here
|
263 |
unless defined $kind_info; |
268 |
unless defined $kind_info; |
264 |
|
269 |
|
265 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
270 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
266 |
foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) { |
271 |
foreach my $scope_level ( qw( branchcode categorycode itemtype checkout_type ) ) { |
267 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
272 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
268 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
273 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
269 |
unless exists $params->{$scope_level}; |
274 |
unless exists $params->{$scope_level}; |
Lines 276-285
sub set_rule {
Link Here
|
276 |
my $branchcode = $params->{branchcode}; |
281 |
my $branchcode = $params->{branchcode}; |
277 |
my $categorycode = $params->{categorycode}; |
282 |
my $categorycode = $params->{categorycode}; |
278 |
my $itemtype = $params->{itemtype}; |
283 |
my $itemtype = $params->{itemtype}; |
|
|
284 |
my $checkout_type = $params->{checkout_type}; |
279 |
my $rule_name = $params->{rule_name}; |
285 |
my $rule_name = $params->{rule_name}; |
280 |
my $rule_value = $params->{rule_value}; |
286 |
my $rule_value = $params->{rule_value}; |
281 |
|
287 |
|
282 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
288 |
for my $v ( $branchcode, $categorycode, $itemtype, $checkout_type ) { |
283 |
$v = undef if $v and $v eq '*'; |
289 |
$v = undef if $v and $v eq '*'; |
284 |
} |
290 |
} |
285 |
my $rule = $self->search( |
291 |
my $rule = $self->search( |
Lines 288-293
sub set_rule {
Link Here
|
288 |
branchcode => $branchcode, |
294 |
branchcode => $branchcode, |
289 |
categorycode => $categorycode, |
295 |
categorycode => $categorycode, |
290 |
itemtype => $itemtype, |
296 |
itemtype => $itemtype, |
|
|
297 |
checkout_type => $checkout_type, |
291 |
} |
298 |
} |
292 |
)->next(); |
299 |
)->next(); |
293 |
|
300 |
|
Lines 307-312
sub set_rule {
Link Here
|
307 |
branchcode => $branchcode, |
314 |
branchcode => $branchcode, |
308 |
categorycode => $categorycode, |
315 |
categorycode => $categorycode, |
309 |
itemtype => $itemtype, |
316 |
itemtype => $itemtype, |
|
|
317 |
checkout_type => $checkout_type, |
310 |
rule_name => $rule_name, |
318 |
rule_name => $rule_name, |
311 |
rule_value => $rule_value, |
319 |
rule_value => $rule_value, |
312 |
} |
320 |
} |