Lines 39-155
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, |
51 |
}, |
58 |
}, |
52 |
|
59 |
|
53 |
patron_maxissueqty => { |
60 |
patron_maxissueqty => { |
54 |
scope => [ 'branchcode', 'categorycode' ], |
61 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
62 |
default_value => "", |
55 |
}, |
63 |
}, |
56 |
patron_maxonsiteissueqty => { |
64 |
patron_maxonsiteissueqty => { |
57 |
scope => [ 'branchcode', 'categorycode' ], |
65 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
66 |
default_value => "", |
58 |
}, |
67 |
}, |
59 |
max_holds => { |
68 |
max_holds => { |
60 |
scope => [ 'branchcode', 'categorycode' ], |
69 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
70 |
default_value => "", |
61 |
}, |
71 |
}, |
62 |
|
72 |
|
63 |
holdallowed => { |
73 |
holdallowed => { |
64 |
scope => [ 'branchcode', 'itemtype' ], |
74 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
75 |
default_value => 2, |
65 |
}, |
76 |
}, |
66 |
hold_fulfillment_policy => { |
77 |
hold_fulfillment_policy => { |
67 |
scope => [ 'branchcode', 'itemtype' ], |
78 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
79 |
default_value => 'any', |
68 |
}, |
80 |
}, |
69 |
returnbranch => { |
81 |
returnbranch => { |
70 |
scope => [ 'branchcode', 'itemtype' ], |
82 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
83 |
default_value => 'homebranch', |
71 |
}, |
84 |
}, |
72 |
|
85 |
|
73 |
article_requests => { |
86 |
article_requests => { |
74 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
87 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
88 |
default_value => 'no', |
75 |
}, |
89 |
}, |
76 |
auto_renew => { |
90 |
auto_renew => { |
77 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
91 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
92 |
default_value => 0, |
78 |
}, |
93 |
}, |
79 |
cap_fine_to_replacement_price => { |
94 |
cap_fine_to_replacement_price => { |
80 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
96 |
default_value => 0, |
81 |
}, |
97 |
}, |
82 |
chargeperiod => { |
98 |
chargeperiod => { |
83 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
99 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
100 |
default_value => 0, |
84 |
}, |
101 |
}, |
85 |
chargeperiod_charge_at => { |
102 |
chargeperiod_charge_at => { |
86 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
103 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
104 |
default_value => 0, |
87 |
}, |
105 |
}, |
88 |
fine => { |
106 |
fine => { |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
108 |
default_value => 0, |
90 |
}, |
109 |
}, |
91 |
finedays => { |
110 |
finedays => { |
92 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
111 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
112 |
default_value => 0, |
93 |
}, |
113 |
}, |
94 |
firstremind => { |
114 |
firstremind => { |
95 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
115 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
116 |
default_value => 0, |
96 |
}, |
117 |
}, |
97 |
hardduedate => { |
118 |
hardduedate => { |
98 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
120 |
default_value => "", |
99 |
}, |
121 |
}, |
100 |
hardduedatecompare => { |
122 |
hardduedatecompare => { |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
123 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
124 |
default_value => -1, |
102 |
}, |
125 |
}, |
103 |
holds_per_day => { |
126 |
holds_per_day => { |
104 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
127 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
105 |
}, |
128 |
}, |
106 |
holds_per_record => { |
129 |
holds_per_record => { |
107 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
130 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
131 |
default_value => 1, |
108 |
}, |
132 |
}, |
109 |
issuelength => { |
133 |
issuelength => { |
110 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
135 |
default_value => 0, |
111 |
}, |
136 |
}, |
112 |
lengthunit => { |
137 |
lengthunit => { |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
138 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
139 |
default_value => 'days', |
114 |
}, |
140 |
}, |
115 |
maxissueqty => { |
141 |
maxissueqty => { |
116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
142 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
143 |
default_value => "", |
117 |
}, |
144 |
}, |
118 |
maxonsiteissueqty => { |
145 |
maxonsiteissueqty => { |
119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
147 |
default_value => "", |
120 |
}, |
148 |
}, |
121 |
maxsuspensiondays => { |
149 |
maxsuspensiondays => { |
122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
150 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
151 |
default_value => "", |
123 |
}, |
152 |
}, |
124 |
no_auto_renewal_after => { |
153 |
no_auto_renewal_after => { |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
154 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
155 |
default_value => "", |
126 |
}, |
156 |
}, |
127 |
no_auto_renewal_after_hard_limit => { |
157 |
no_auto_renewal_after_hard_limit => { |
128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
159 |
default_value => "", |
129 |
}, |
160 |
}, |
130 |
norenewalbefore => { |
161 |
norenewalbefore => { |
131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
162 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
163 |
default_value => "", |
132 |
}, |
164 |
}, |
133 |
onshelfholds => { |
165 |
onshelfholds => { |
134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
166 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
167 |
default_value => 0, |
135 |
}, |
168 |
}, |
136 |
opacitemholds => { |
169 |
opacitemholds => { |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
170 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
171 |
default_value => "N", |
138 |
}, |
172 |
}, |
139 |
overduefinescap => { |
173 |
overduefinescap => { |
140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
174 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
175 |
default_value => "", |
141 |
}, |
176 |
}, |
142 |
renewalperiod => { |
177 |
renewalperiod => { |
143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
178 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
179 |
default_value => 0, |
144 |
}, |
180 |
}, |
145 |
renewalsallowed => { |
181 |
renewalsallowed => { |
146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
182 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
183 |
default_value => 0, |
147 |
}, |
184 |
}, |
148 |
rentaldiscount => { |
185 |
rentaldiscount => { |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
186 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
187 |
default_value => 0, |
150 |
}, |
188 |
}, |
151 |
reservesallowed => { |
189 |
reservesallowed => { |
152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
190 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
191 |
default_value => 0, |
153 |
}, |
192 |
}, |
154 |
suspension_chargeperiod => { |
193 |
suspension_chargeperiod => { |
155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
194 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
Lines 243-248
sub get_effective_rules {
Link Here
|
243 |
|
282 |
|
244 |
=head3 set_rule |
283 |
=head3 set_rule |
245 |
|
284 |
|
|
|
285 |
=over 4 |
286 |
Koha::CirculationRules->set_rule( { |
287 |
branchcode => $branchcode, |
288 |
[ categorycode => $categorycode, ] |
289 |
[ itemtype => $itemtype, ] |
290 |
rule_name => $rule_name, |
291 |
rule_value => $rule_value, |
292 |
[ allow_null_out_of_scope => 1, ] |
293 |
} ) |
294 |
=back |
295 |
|
296 |
Sets a single circulation rule. |
297 |
|
298 |
It is an error to specify a C<categorycode> or C<itemtype> unless the given C<rule_name> can be set |
299 |
at that scope; i.e., you cannot set a C<patron_maxissueqty> for an itemtype. |
300 |
|
301 |
If C<allow_null_out_of_scope> is passed, and any excess C<categorycode> or C<itemtype> is set to C<undef>, |
302 |
they are ignored. |
303 |
|
246 |
=cut |
304 |
=cut |
247 |
|
305 |
|
248 |
sub set_rule { |
306 |
sub set_rule { |
Lines 266-272
sub set_rule {
Link Here
|
266 |
unless exists $params->{$scope_level}; |
324 |
unless exists $params->{$scope_level}; |
267 |
} else { |
325 |
} else { |
268 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
326 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
269 |
if exists $params->{$scope_level}; |
327 |
unless !exists $params->{$scope_level} || ( |
|
|
328 |
$params->{allow_null_out_of_scope} && |
329 |
!defined $params->{$scope_level} |
330 |
); |
270 |
} |
331 |
} |
271 |
} |
332 |
} |
272 |
|
333 |
|