|
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', 'onsite_checkout' ], |
| 55 |
}, |
55 |
}, |
| 56 |
patron_maxonsiteissueqty => { |
56 |
patron_maxonsiteissueqty => { |
| 57 |
scope => [ 'branchcode', 'categorycode' ], |
57 |
scope => [ 'branchcode', 'categorycode' ], |
|
Lines 77-107
our $RULE_KINDS = {
Link Here
|
| 77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 78 |
}, |
78 |
}, |
| 79 |
auto_renew => { |
79 |
auto_renew => { |
| 80 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
80 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 81 |
}, |
81 |
}, |
| 82 |
cap_fine_to_replacement_price => { |
82 |
cap_fine_to_replacement_price => { |
| 83 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
83 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 84 |
}, |
84 |
}, |
| 85 |
chargeperiod => { |
85 |
chargeperiod => { |
| 86 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
86 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 87 |
}, |
87 |
}, |
| 88 |
chargeperiod_charge_at => { |
88 |
chargeperiod_charge_at => { |
| 89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 90 |
}, |
90 |
}, |
| 91 |
fine => { |
91 |
fine => { |
| 92 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
92 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 93 |
}, |
93 |
}, |
| 94 |
finedays => { |
94 |
finedays => { |
| 95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 96 |
}, |
96 |
}, |
| 97 |
firstremind => { |
97 |
firstremind => { |
| 98 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
98 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 99 |
}, |
99 |
}, |
| 100 |
hardduedate => { |
100 |
hardduedate => { |
| 101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 102 |
}, |
102 |
}, |
| 103 |
hardduedatecompare => { |
103 |
hardduedatecompare => { |
| 104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
104 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 105 |
}, |
105 |
}, |
| 106 |
holds_per_day => { |
106 |
holds_per_day => { |
| 107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
Lines 110-140
our $RULE_KINDS = {
Link Here
|
| 110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 111 |
}, |
111 |
}, |
| 112 |
issuelength => { |
112 |
issuelength => { |
| 113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 114 |
}, |
114 |
}, |
| 115 |
daysmode => { |
115 |
daysmode => { |
| 116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 117 |
}, |
117 |
}, |
| 118 |
lengthunit => { |
118 |
lengthunit => { |
| 119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 120 |
}, |
120 |
}, |
| 121 |
maxissueqty => { |
121 |
maxissueqty => { |
| 122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 123 |
}, |
123 |
}, |
| 124 |
maxonsiteissueqty => { |
124 |
maxonsiteissueqty => { |
| 125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 126 |
}, |
126 |
}, |
| 127 |
maxsuspensiondays => { |
127 |
maxsuspensiondays => { |
| 128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 129 |
}, |
129 |
}, |
| 130 |
no_auto_renewal_after => { |
130 |
no_auto_renewal_after => { |
| 131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 132 |
}, |
132 |
}, |
| 133 |
no_auto_renewal_after_hard_limit => { |
133 |
no_auto_renewal_after_hard_limit => { |
| 134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 135 |
}, |
135 |
}, |
| 136 |
norenewalbefore => { |
136 |
norenewalbefore => { |
| 137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 138 |
}, |
138 |
}, |
| 139 |
onshelfholds => { |
139 |
onshelfholds => { |
| 140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
Lines 143-170
our $RULE_KINDS = {
Link Here
|
| 143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 144 |
}, |
144 |
}, |
| 145 |
overduefinescap => { |
145 |
overduefinescap => { |
| 146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 147 |
}, |
147 |
}, |
| 148 |
renewalperiod => { |
148 |
renewalperiod => { |
| 149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 150 |
}, |
150 |
}, |
| 151 |
renewalsallowed => { |
151 |
renewalsallowed => { |
| 152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 153 |
}, |
153 |
}, |
| 154 |
unseen_renewals_allowed => { |
154 |
unseen_renewals_allowed => { |
| 155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 156 |
}, |
156 |
}, |
| 157 |
rentaldiscount => { |
157 |
rentaldiscount => { |
| 158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 159 |
}, |
159 |
}, |
| 160 |
reservesallowed => { |
160 |
reservesallowed => { |
| 161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 162 |
}, |
162 |
}, |
| 163 |
suspension_chargeperiod => { |
163 |
suspension_chargeperiod => { |
| 164 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
164 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 165 |
}, |
165 |
}, |
| 166 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
166 |
note => { # This is not really a rule. Maybe we will want to separate this later. |
| 167 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
167 |
scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ], |
| 168 |
}, |
168 |
}, |
| 169 |
decreaseloanholds => { |
169 |
decreaseloanholds => { |
| 170 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
170 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
Lines 194-210
sub get_effective_rule {
Link Here
|
| 194 |
my $categorycode = $params->{categorycode}; |
194 |
my $categorycode = $params->{categorycode}; |
| 195 |
my $itemtype = $params->{itemtype}; |
195 |
my $itemtype = $params->{itemtype}; |
| 196 |
my $branchcode = $params->{branchcode}; |
196 |
my $branchcode = $params->{branchcode}; |
|
|
197 |
my $onsite_checkout = $params->{onsite_checkout}; |
| 197 |
|
198 |
|
| 198 |
Koha::Exceptions::MissingParameter->throw( |
199 |
Koha::Exceptions::MissingParameter->throw( |
| 199 |
"Required parameter 'rule_name' missing") |
200 |
"Required parameter 'rule_name' missing") |
| 200 |
unless $rule_name; |
201 |
unless $rule_name; |
| 201 |
|
202 |
|
| 202 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
203 |
for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) { |
| 203 |
$v = undef if $v and $v eq '*'; |
204 |
$v = undef if $v and $v eq '*'; |
| 204 |
} |
205 |
} |
| 205 |
|
206 |
|
| 206 |
my $order_by = $params->{order_by} |
207 |
my $order_by = $params->{order_by} |
| 207 |
// { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; |
208 |
// { -desc => [ 'branchcode', 'onsite_checkout', 'categorycode', 'itemtype', ] }; |
| 208 |
|
209 |
|
| 209 |
my $search_params; |
210 |
my $search_params; |
| 210 |
$search_params->{rule_name} = $rule_name; |
211 |
$search_params->{rule_name} = $rule_name; |
|
Lines 212-217
sub get_effective_rule {
Link Here
|
| 212 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
213 |
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; |
| 213 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
214 |
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; |
| 214 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
215 |
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; |
|
|
216 |
$search_params->{onsite_checkout} = defined $onsite_checkout ? [ $onsite_checkout, undef ] : undef; |
| 215 |
|
217 |
|
| 216 |
my $rule = $self->search( |
218 |
my $rule = $self->search( |
| 217 |
$search_params, |
219 |
$search_params, |
|
Lines 234-239
sub get_effective_rules {
Link Here
|
| 234 |
my $rules = $params->{rules}; |
236 |
my $rules = $params->{rules}; |
| 235 |
my $categorycode = $params->{categorycode}; |
237 |
my $categorycode = $params->{categorycode}; |
| 236 |
my $itemtype = $params->{itemtype}; |
238 |
my $itemtype = $params->{itemtype}; |
|
|
239 |
my $onsite_checkout = $params->{onsite_checkout}; |
| 237 |
my $branchcode = $params->{branchcode}; |
240 |
my $branchcode = $params->{branchcode}; |
| 238 |
|
241 |
|
| 239 |
my $r; |
242 |
my $r; |
|
Lines 244-249
sub get_effective_rules {
Link Here
|
| 244 |
categorycode => $categorycode, |
247 |
categorycode => $categorycode, |
| 245 |
itemtype => $itemtype, |
248 |
itemtype => $itemtype, |
| 246 |
branchcode => $branchcode, |
249 |
branchcode => $branchcode, |
|
|
250 |
onsite_checkout => $onsite_checkout, |
| 247 |
} |
251 |
} |
| 248 |
); |
252 |
); |
| 249 |
|
253 |
|
|
Lines 272-278
sub set_rule {
Link Here
|
| 272 |
unless defined $kind_info; |
276 |
unless defined $kind_info; |
| 273 |
|
277 |
|
| 274 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
278 |
# Enforce scope; a rule should be set for its defined scope, no more, no less. |
| 275 |
foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) { |
279 |
foreach my $scope_level ( qw( branchcode onsite_checkout categorycode itemtype ) ) { |
| 276 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
280 |
if ( grep /$scope_level/, @{ $kind_info->{scope} } ) { |
| 277 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
281 |
croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!" |
| 278 |
unless exists $params->{$scope_level}; |
282 |
unless exists $params->{$scope_level}; |
|
Lines 285-296
sub set_rule {
Link Here
|
| 285 |
my $branchcode = $params->{branchcode}; |
289 |
my $branchcode = $params->{branchcode}; |
| 286 |
my $categorycode = $params->{categorycode}; |
290 |
my $categorycode = $params->{categorycode}; |
| 287 |
my $itemtype = $params->{itemtype}; |
291 |
my $itemtype = $params->{itemtype}; |
|
|
292 |
my $onsite_checkout = $params->{onsite_checkout}; |
| 288 |
my $rule_name = $params->{rule_name}; |
293 |
my $rule_name = $params->{rule_name}; |
| 289 |
my $rule_value = $params->{rule_value}; |
294 |
my $rule_value = $params->{rule_value}; |
| 290 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
295 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
| 291 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
296 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
| 292 |
|
297 |
|
| 293 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
298 |
for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) { |
| 294 |
$v = undef if $v and $v eq '*'; |
299 |
$v = undef if $v and $v eq '*'; |
| 295 |
} |
300 |
} |
| 296 |
my $rule = $self->search( |
301 |
my $rule = $self->search( |
|
Lines 299-304
sub set_rule {
Link Here
|
| 299 |
branchcode => $branchcode, |
304 |
branchcode => $branchcode, |
| 300 |
categorycode => $categorycode, |
305 |
categorycode => $categorycode, |
| 301 |
itemtype => $itemtype, |
306 |
itemtype => $itemtype, |
|
|
307 |
onsite_checkout => $onsite_checkout, |
| 302 |
} |
308 |
} |
| 303 |
)->next(); |
309 |
)->next(); |
| 304 |
|
310 |
|
|
Lines 318-323
sub set_rule {
Link Here
|
| 318 |
branchcode => $branchcode, |
324 |
branchcode => $branchcode, |
| 319 |
categorycode => $categorycode, |
325 |
categorycode => $categorycode, |
| 320 |
itemtype => $itemtype, |
326 |
itemtype => $itemtype, |
|
|
327 |
onsite_checkout => $onsite_checkout, |
| 321 |
rule_name => $rule_name, |
328 |
rule_name => $rule_name, |
| 322 |
rule_value => $rule_value, |
329 |
rule_value => $rule_value, |
| 323 |
} |
330 |
} |
|
Lines 340-345
sub set_rules {
Link Here
|
| 340 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
347 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
| 341 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
348 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
| 342 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
349 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
|
|
350 |
$set_params{onsite_checkout} = $params->{onsite_checkout} if exists $params->{onsite_checkout}; |
| 351 |
|
| 343 |
my $rules = $params->{rules}; |
352 |
my $rules = $params->{rules}; |
| 344 |
|
353 |
|
| 345 |
my $rule_objects = []; |
354 |
my $rule_objects = []; |
|
Lines 558-569
sub get_effective_daysmode {
Link Here
|
| 558 |
my $categorycode = $params->{categorycode}; |
567 |
my $categorycode = $params->{categorycode}; |
| 559 |
my $itemtype = $params->{itemtype}; |
568 |
my $itemtype = $params->{itemtype}; |
| 560 |
my $branchcode = $params->{branchcode}; |
569 |
my $branchcode = $params->{branchcode}; |
|
|
570 |
my $onsite_checkout = $params->{onsite_checkout}; |
| 561 |
|
571 |
|
| 562 |
my $daysmode_rule = $class->get_effective_rule( |
572 |
my $daysmode_rule = $class->get_effective_rule( |
| 563 |
{ |
573 |
{ |
| 564 |
categorycode => $categorycode, |
574 |
categorycode => $categorycode, |
| 565 |
itemtype => $itemtype, |
575 |
itemtype => $itemtype, |
| 566 |
branchcode => $branchcode, |
576 |
branchcode => $branchcode, |
|
|
577 |
onsite_checkout => $onsite_checkout, |
| 567 |
rule_name => 'daysmode', |
578 |
rule_name => 'daysmode', |
| 568 |
} |
579 |
} |
| 569 |
); |
580 |
); |