|
Lines 39-161
Koha::CirculationRules - Koha CirculationRule Object set class
Link Here
|
| 39 |
|
39 |
|
| 40 |
=head3 rule_kinds |
40 |
=head3 rule_kinds |
| 41 |
|
41 |
|
| 42 |
This structure describes the possible rules that may be set, and what scopes they can be set at. |
42 |
This structure describes the possible rules that may be set, what scopes they can be set at and any |
|
|
43 |
default values. |
| 43 |
|
44 |
|
| 44 |
Any attempt to set a rule with a nonsensical scope (for instance, setting the C<patron_maxissueqty> for a branchcode and itemtype), is an error. |
45 |
Any attempt to set a rule with a nonsensical scope (for instance, setting the C<patron_maxissueqty> |
|
|
46 |
for a branchcode and itemtype), is an error. |
| 47 |
|
| 48 |
These default values correspond to what would be stored in the database if nothing was changed on |
| 49 |
the old circulation rules editor; this is a combination of the default values in the template and |
| 50 |
the issuingrules table. |
| 45 |
|
51 |
|
| 46 |
=cut |
52 |
=cut |
| 47 |
|
53 |
|
| 48 |
our $RULE_KINDS = { |
54 |
our $RULE_KINDS = { |
| 49 |
refund => { |
55 |
refund => { |
| 50 |
scope => [ 'branchcode' ], |
56 |
scope => [ 'branchcode' ], |
|
|
57 |
default_value => 1, |
| 58 |
group => 'fines', |
| 59 |
description => "Refund lost item fee", |
| 60 |
choices => [ |
| 61 |
[ 0, "No" ], |
| 62 |
[ 1, "Yes" ], |
| 63 |
], |
| 51 |
}, |
64 |
}, |
| 52 |
|
65 |
|
| 53 |
patron_maxissueqty => { |
66 |
patron_maxissueqty => { |
| 54 |
scope => [ 'branchcode', 'categorycode' ], |
67 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
68 |
default_value => "", |
| 69 |
group => 'circulation', |
| 70 |
description => "Total current checkouts allowed", |
| 55 |
}, |
71 |
}, |
| 56 |
patron_maxonsiteissueqty => { |
72 |
patron_maxonsiteissueqty => { |
| 57 |
scope => [ 'branchcode', 'categorycode' ], |
73 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
74 |
default_value => "", |
| 75 |
group => 'circulation', |
| 76 |
description => "Total current on-site checkouts allowed", |
| 58 |
}, |
77 |
}, |
| 59 |
max_holds => { |
78 |
max_holds => { |
| 60 |
scope => [ 'branchcode', 'categorycode' ], |
79 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
80 |
default_value => "", |
| 81 |
group => 'holds', |
| 82 |
description => "Maximum total holds allowed", |
| 61 |
}, |
83 |
}, |
| 62 |
|
84 |
|
| 63 |
holdallowed => { |
85 |
holdallowed => { |
| 64 |
scope => [ 'branchcode', 'itemtype' ], |
86 |
scope => [ 'branchcode', 'itemtype' ], |
| 65 |
can_be_blank => 0, |
87 |
can_be_blank => 0, |
|
|
88 |
default_value => 2, |
| 89 |
group => 'holds', |
| 90 |
description => "Hold policy", |
| 91 |
choices => [ |
| 92 |
[ 2, "From any library" ], |
| 93 |
[ 1, "From home library" ], |
| 94 |
[ 0, "No holds allowed" ], |
| 95 |
], |
| 66 |
}, |
96 |
}, |
| 67 |
hold_fulfillment_policy => { |
97 |
hold_fulfillment_policy => { |
| 68 |
scope => [ 'branchcode', 'itemtype' ], |
98 |
scope => [ 'branchcode', 'itemtype' ], |
| 69 |
can_be_blank => 0, |
99 |
can_be_blank => 0, |
|
|
100 |
default_value => 'any', |
| 101 |
group => 'holds', |
| 102 |
description => "Hold pickup library match", |
| 103 |
choices => [ |
| 104 |
[ "any", "any library" ], |
| 105 |
[ "homebranch", "item's home library" ], |
| 106 |
[ "holdingbranch", "item's holding library" ], |
| 107 |
], |
| 70 |
}, |
108 |
}, |
| 71 |
returnbranch => { |
109 |
returnbranch => { |
| 72 |
scope => [ 'branchcode', 'itemtype' ], |
110 |
scope => [ 'branchcode', 'itemtype' ], |
| 73 |
can_be_blank => 0, |
111 |
can_be_blank => 0, |
|
|
112 |
default_value => 'homebranch', |
| 113 |
group => 'circulation', |
| 114 |
description => "Return policy", |
| 115 |
choices => [ |
| 116 |
[ "homebranch", "Item returns home" ], |
| 117 |
[ "holdingbranch", "Item returns to issuing library" ], |
| 118 |
[ "noreturn", "Item floats" ], |
| 119 |
], |
| 74 |
}, |
120 |
}, |
| 75 |
|
121 |
|
| 76 |
article_requests => { |
122 |
article_requests => { |
| 77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
123 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
124 |
default_value => 'no', |
| 125 |
group => 'circulation', |
| 126 |
description => "Article requests", |
| 127 |
choices => [ |
| 128 |
[ "no", "No" ], |
| 129 |
[ "yes", "Yes" ], |
| 130 |
[ "bib_only", "Record only" ], |
| 131 |
[ "item_only", "Item only" ], |
| 132 |
], |
| 78 |
}, |
133 |
}, |
| 79 |
auto_renew => { |
134 |
auto_renew => { |
| 80 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
135 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
136 |
default_value => 0, |
| 137 |
group => 'circulation', |
| 138 |
description => "Automatic renewal", |
| 139 |
choices => [ |
| 140 |
[ 0, "No" ], |
| 141 |
[ 1, "Yes" ], |
| 142 |
], |
| 81 |
}, |
143 |
}, |
| 82 |
cap_fine_to_replacement_price => { |
144 |
cap_fine_to_replacement_price => { |
| 83 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
145 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
146 |
default_value => 0, |
| 147 |
group => 'fines', |
| 148 |
description => "Cap fine at replacement price", |
| 149 |
choices => [ |
| 150 |
[ 0, "No" ], |
| 151 |
[ 1, "Yes" ], |
| 152 |
], |
| 84 |
}, |
153 |
}, |
| 85 |
chargeperiod => { |
154 |
chargeperiod => { |
| 86 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
156 |
default_value => 0, |
| 157 |
group => 'fines', |
| 158 |
description => "Fine charging interval", |
| 87 |
}, |
159 |
}, |
| 88 |
chargeperiod_charge_at => { |
160 |
chargeperiod_charge_at => { |
| 89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
162 |
default_value => 0, |
| 163 |
group => 'circulation', |
| 164 |
description => "When to charge", |
| 165 |
choices => [ |
| 166 |
[ 0, "End of interval" ], |
| 167 |
[ 1, "Start of interval" ], |
| 168 |
], |
| 90 |
}, |
169 |
}, |
| 91 |
fine => { |
170 |
fine => { |
| 92 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
171 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
172 |
default_value => 0, |
| 173 |
group => 'fines', |
| 174 |
description => "Fine amount", |
| 93 |
}, |
175 |
}, |
| 94 |
finedays => { |
176 |
finedays => { |
| 95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
177 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
178 |
default_value => 0, |
| 179 |
group => 'fines', |
| 180 |
description => "Suspension in days", |
| 96 |
}, |
181 |
}, |
| 97 |
firstremind => { |
182 |
firstremind => { |
| 98 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
183 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
184 |
default_value => 0, |
| 185 |
group => 'fines', |
| 186 |
description => "Fine grace period", |
| 99 |
}, |
187 |
}, |
| 100 |
hardduedate => { |
188 |
hardduedate => { |
| 101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
189 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
190 |
default_value => "", |
| 191 |
group => 'circulation', |
| 192 |
description => "Hard due date", |
| 193 |
type => "date", |
| 102 |
}, |
194 |
}, |
| 103 |
hardduedatecompare => { |
195 |
hardduedatecompare => { |
| 104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
196 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
197 |
default_value => -1, |
| 198 |
group => 'circulation', |
| 199 |
description => "Hard due date type", |
| 200 |
choices => [ |
| 201 |
[ -1, "Before" ], |
| 202 |
[ 0, "Exactly on" ], |
| 203 |
[ 1, "After" ], |
| 204 |
], |
| 105 |
}, |
205 |
}, |
| 106 |
holds_per_day => { |
206 |
holds_per_day => { |
| 107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
207 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
208 |
group => 'holds', |
| 108 |
}, |
209 |
}, |
| 109 |
holds_per_record => { |
210 |
holds_per_record => { |
| 110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
211 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
212 |
default_value => 1, |
| 213 |
group => 'holds', |
| 214 |
description => "Holds per record (count)", |
| 111 |
}, |
215 |
}, |
| 112 |
issuelength => { |
216 |
issuelength => { |
| 113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
217 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
218 |
default_value => 0, |
| 219 |
group => 'circulation', |
| 220 |
description => "Loan period", |
| 114 |
}, |
221 |
}, |
| 115 |
daysmode => { |
222 |
daysmode => { |
| 116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
223 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 117 |
}, |
224 |
}, |
| 118 |
lengthunit => { |
225 |
lengthunit => { |
| 119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
226 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
227 |
default_value => 'days', |
| 228 |
group => 'circulation', |
| 229 |
description => "Loan period unit", |
| 120 |
}, |
230 |
}, |
| 121 |
maxissueqty => { |
231 |
patron_maxissueqty => { |
| 122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
232 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
233 |
default_value => "", |
| 234 |
group => 'circulation', |
| 235 |
description => "Current checkouts allowed", |
| 123 |
}, |
236 |
}, |
| 124 |
maxonsiteissueqty => { |
237 |
patron_maxonsiteissueqty => { |
| 125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
238 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
239 |
default_value => "", |
| 240 |
group => 'circulation', |
| 241 |
description => "Current on-site checkouts allowed", |
| 126 |
}, |
242 |
}, |
| 127 |
maxsuspensiondays => { |
243 |
maxsuspensiondays => { |
| 128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
244 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
245 |
default_value => "", |
| 246 |
group => 'fines', |
| 247 |
description => "Max. suspension duration (days)", |
| 129 |
}, |
248 |
}, |
| 130 |
no_auto_renewal_after => { |
249 |
no_auto_renewal_after => { |
| 131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
250 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
251 |
default_value => "", |
| 252 |
group => 'circulation', |
| 253 |
description => "No automatic renewal after", |
| 132 |
}, |
254 |
}, |
| 133 |
no_auto_renewal_after_hard_limit => { |
255 |
no_auto_renewal_after_hard_limit => { |
| 134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
256 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
257 |
default_value => "", |
| 258 |
group => 'circulation', |
| 259 |
description => "No automatic renewal after (hard limit)", |
| 260 |
type => "date", |
| 135 |
}, |
261 |
}, |
| 136 |
norenewalbefore => { |
262 |
norenewalbefore => { |
| 137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
263 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
264 |
default_value => "", |
| 265 |
group => 'circulation', |
| 266 |
description => "No renewal before", |
| 138 |
}, |
267 |
}, |
| 139 |
onshelfholds => { |
268 |
onshelfholds => { |
| 140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
269 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
270 |
default_value => 0, |
| 271 |
group => 'holds', |
| 272 |
description => "On shelf holds allowed", |
| 273 |
choices => [ |
| 274 |
[ 1, "Yes" ], |
| 275 |
[ 0, "If any unavailable" ], |
| 276 |
[ 2, "If all unavailable" ], |
| 277 |
], |
| 141 |
}, |
278 |
}, |
| 142 |
opacitemholds => { |
279 |
opacitemholds => { |
| 143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
280 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
281 |
default_value => "N", |
| 282 |
group => 'holds', |
| 283 |
description => "Item-level holds", |
| 284 |
choices => [ |
| 285 |
[ "N", "Don't allow" ], |
| 286 |
[ "Y", "Allow" ], |
| 287 |
[ "F", "Force" ], |
| 288 |
], |
| 144 |
}, |
289 |
}, |
| 145 |
overduefinescap => { |
290 |
overduefinescap => { |
| 146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
291 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
292 |
default_value => "", |
| 293 |
group => 'fines', |
| 294 |
description => "Overdue fines cap (amount)", |
| 147 |
}, |
295 |
}, |
| 148 |
renewalperiod => { |
296 |
renewalperiod => { |
| 149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
297 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
298 |
default_value => 0, |
| 299 |
group => 'circulation', |
| 300 |
description => "Renewal period", |
| 150 |
}, |
301 |
}, |
| 151 |
renewalsallowed => { |
302 |
renewalsallowed => { |
| 152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
303 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
304 |
default_value => 0, |
| 305 |
group => 'circulation', |
| 306 |
description => "Renewals allowed (count)", |
| 153 |
}, |
307 |
}, |
| 154 |
rentaldiscount => { |
308 |
rentaldiscount => { |
| 155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
309 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
310 |
default_value => 0, |
| 311 |
group => 'circulation', |
| 312 |
description => "Rental discount (%)", |
| 156 |
}, |
313 |
}, |
| 157 |
reservesallowed => { |
314 |
reservesallowed => { |
| 158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
315 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
316 |
default_value => 0, |
| 317 |
group => 'holds', |
| 318 |
description => "Holds allowed (count)", |
| 159 |
}, |
319 |
}, |
| 160 |
suspension_chargeperiod => { |
320 |
suspension_chargeperiod => { |
| 161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
321 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
Lines 249-254
sub get_effective_rules {
Link Here
|
| 249 |
|
409 |
|
| 250 |
=head3 set_rule |
410 |
=head3 set_rule |
| 251 |
|
411 |
|
|
|
412 |
=over 4 |
| 413 |
Koha::CirculationRules->set_rule( { |
| 414 |
branchcode => $branchcode, |
| 415 |
[ categorycode => $categorycode, ] |
| 416 |
[ itemtype => $itemtype, ] |
| 417 |
rule_name => $rule_name, |
| 418 |
rule_value => $rule_value, |
| 419 |
[ allow_null_out_of_scope => 1, ] |
| 420 |
} ) |
| 421 |
=back |
| 422 |
|
| 423 |
Sets a single circulation rule. |
| 424 |
|
| 425 |
It is an error to specify a C<categorycode> or C<itemtype> unless the given C<rule_name> can be set |
| 426 |
at that scope; i.e., you cannot set a C<patron_maxissueqty> for an itemtype. |
| 427 |
|
| 428 |
If C<allow_null_out_of_scope> is passed, and any excess C<categorycode> or C<itemtype> is set to C<undef>, |
| 429 |
they are ignored. |
| 430 |
|
| 252 |
=cut |
431 |
=cut |
| 253 |
|
432 |
|
| 254 |
sub set_rule { |
433 |
sub set_rule { |
|
Lines 272-278
sub set_rule {
Link Here
|
| 272 |
unless exists $params->{$scope_level}; |
451 |
unless exists $params->{$scope_level}; |
| 273 |
} else { |
452 |
} else { |
| 274 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
453 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
| 275 |
if exists $params->{$scope_level}; |
454 |
unless !exists $params->{$scope_level} || ( |
|
|
455 |
$params->{allow_null_out_of_scope} && |
| 456 |
!defined $params->{$scope_level} |
| 457 |
); |
| 276 |
} |
458 |
} |
| 277 |
} |
459 |
} |
| 278 |
|
460 |
|