|
Lines 39-158
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 |
daysmode => { |
137 |
daysmode => { |
| 113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
138 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
| 114 |
}, |
139 |
}, |
| 115 |
lengthunit => { |
140 |
lengthunit => { |
| 116 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
141 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
142 |
default_value => 'days', |
| 117 |
}, |
143 |
}, |
| 118 |
maxissueqty => { |
144 |
maxissueqty => { |
| 119 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
145 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
146 |
default_value => "", |
| 120 |
}, |
147 |
}, |
| 121 |
maxonsiteissueqty => { |
148 |
maxonsiteissueqty => { |
| 122 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
150 |
default_value => "", |
| 123 |
}, |
151 |
}, |
| 124 |
maxsuspensiondays => { |
152 |
maxsuspensiondays => { |
| 125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
153 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
154 |
default_value => "", |
| 126 |
}, |
155 |
}, |
| 127 |
no_auto_renewal_after => { |
156 |
no_auto_renewal_after => { |
| 128 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
157 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
158 |
default_value => "", |
| 129 |
}, |
159 |
}, |
| 130 |
no_auto_renewal_after_hard_limit => { |
160 |
no_auto_renewal_after_hard_limit => { |
| 131 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
162 |
default_value => "", |
| 132 |
}, |
163 |
}, |
| 133 |
norenewalbefore => { |
164 |
norenewalbefore => { |
| 134 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
165 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
166 |
default_value => "", |
| 135 |
}, |
167 |
}, |
| 136 |
onshelfholds => { |
168 |
onshelfholds => { |
| 137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
169 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
170 |
default_value => 0, |
| 138 |
}, |
171 |
}, |
| 139 |
opacitemholds => { |
172 |
opacitemholds => { |
| 140 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
173 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
174 |
default_value => "N", |
| 141 |
}, |
175 |
}, |
| 142 |
overduefinescap => { |
176 |
overduefinescap => { |
| 143 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
177 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
178 |
default_value => "", |
| 144 |
}, |
179 |
}, |
| 145 |
renewalperiod => { |
180 |
renewalperiod => { |
| 146 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
181 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
182 |
default_value => 0, |
| 147 |
}, |
183 |
}, |
| 148 |
renewalsallowed => { |
184 |
renewalsallowed => { |
| 149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
185 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
186 |
default_value => 0, |
| 150 |
}, |
187 |
}, |
| 151 |
rentaldiscount => { |
188 |
rentaldiscount => { |
| 152 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
189 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
190 |
default_value => 0, |
| 153 |
}, |
191 |
}, |
| 154 |
reservesallowed => { |
192 |
reservesallowed => { |
| 155 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
193 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
194 |
default_value => 0, |
| 156 |
}, |
195 |
}, |
| 157 |
suspension_chargeperiod => { |
196 |
suspension_chargeperiod => { |
| 158 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
197 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
Lines 246-251
sub get_effective_rules {
Link Here
|
| 246 |
|
285 |
|
| 247 |
=head3 set_rule |
286 |
=head3 set_rule |
| 248 |
|
287 |
|
|
|
288 |
=over 4 |
| 289 |
Koha::CirculationRules->set_rule( { |
| 290 |
branchcode => $branchcode, |
| 291 |
[ categorycode => $categorycode, ] |
| 292 |
[ itemtype => $itemtype, ] |
| 293 |
rule_name => $rule_name, |
| 294 |
rule_value => $rule_value, |
| 295 |
[ allow_null_out_of_scope => 1, ] |
| 296 |
} ) |
| 297 |
=back |
| 298 |
|
| 299 |
Sets a single circulation rule. |
| 300 |
|
| 301 |
It is an error to specify a C<categorycode> or C<itemtype> unless the given C<rule_name> can be set |
| 302 |
at that scope; i.e., you cannot set a C<patron_maxissueqty> for an itemtype. |
| 303 |
|
| 304 |
If C<allow_null_out_of_scope> is passed, and any excess C<categorycode> or C<itemtype> is set to C<undef>, |
| 305 |
they are ignored. |
| 306 |
|
| 249 |
=cut |
307 |
=cut |
| 250 |
|
308 |
|
| 251 |
sub set_rule { |
309 |
sub set_rule { |
|
Lines 269-275
sub set_rule {
Link Here
|
| 269 |
unless exists $params->{$scope_level}; |
327 |
unless exists $params->{$scope_level}; |
| 270 |
} else { |
328 |
} else { |
| 271 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
329 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
| 272 |
if exists $params->{$scope_level}; |
330 |
unless !exists $params->{$scope_level} || ( |
|
|
331 |
$params->{allow_null_out_of_scope} && |
| 332 |
!defined $params->{$scope_level} |
| 333 |
); |
| 273 |
} |
334 |
} |
| 274 |
} |
335 |
} |
| 275 |
|
336 |
|