|
Lines 37-150
Koha::CirculationRules - Koha CirculationRule Object set class
Link Here
|
| 37 |
|
37 |
|
| 38 |
=head3 rule_kinds |
38 |
=head3 rule_kinds |
| 39 |
|
39 |
|
| 40 |
This structure describes the possible rules that may be set, and what scopes they can be set at. |
40 |
This structure describes the possible rules that may be set, what scopes they can be set at and any |
|
|
41 |
default values. |
| 41 |
|
42 |
|
| 42 |
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. |
43 |
Any attempt to set a rule with a nonsensical scope (for instance, setting the C<patron_maxissueqty> |
|
|
44 |
for a branchcode and itemtype), is an error. |
| 45 |
|
| 46 |
These default values correspond to what would be stored in the database if nothing was changed on |
| 47 |
the old circulation rules editor; this is a combination of the default values in the template and |
| 48 |
the issuingrules table. |
| 43 |
|
49 |
|
| 44 |
=cut |
50 |
=cut |
| 45 |
|
51 |
|
| 46 |
our $RULE_KINDS = { |
52 |
our $RULE_KINDS = { |
| 47 |
refund => { |
53 |
refund => { |
| 48 |
scope => [ 'branchcode' ], |
54 |
scope => [ 'branchcode' ], |
|
|
55 |
default_value => 1, |
| 49 |
}, |
56 |
}, |
| 50 |
|
57 |
|
| 51 |
patron_maxissueqty => { |
58 |
patron_maxissueqty => { |
| 52 |
scope => [ 'branchcode', 'categorycode' ], |
59 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
60 |
default_value => "", |
| 53 |
}, |
61 |
}, |
| 54 |
patron_maxonsiteissueqty => { |
62 |
patron_maxonsiteissueqty => { |
| 55 |
scope => [ 'branchcode', 'categorycode' ], |
63 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
64 |
default_value => "", |
| 56 |
}, |
65 |
}, |
| 57 |
max_holds => { |
66 |
max_holds => { |
| 58 |
scope => [ 'branchcode', 'categorycode' ], |
67 |
scope => [ 'branchcode', 'categorycode' ], |
|
|
68 |
default_value => "", |
| 59 |
}, |
69 |
}, |
| 60 |
|
70 |
|
| 61 |
holdallowed => { |
71 |
holdallowed => { |
| 62 |
scope => [ 'branchcode', 'itemtype' ], |
72 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
73 |
default_value => 2, |
| 63 |
}, |
74 |
}, |
| 64 |
hold_fulfillment_policy => { |
75 |
hold_fulfillment_policy => { |
| 65 |
scope => [ 'branchcode', 'itemtype' ], |
76 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
77 |
default_value => 'any', |
| 66 |
}, |
78 |
}, |
| 67 |
returnbranch => { |
79 |
returnbranch => { |
| 68 |
scope => [ 'branchcode', 'itemtype' ], |
80 |
scope => [ 'branchcode', 'itemtype' ], |
|
|
81 |
default_value => 'homebranch', |
| 69 |
}, |
82 |
}, |
| 70 |
|
83 |
|
| 71 |
article_requests => { |
84 |
article_requests => { |
| 72 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
85 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
86 |
default_value => 'no', |
| 73 |
}, |
87 |
}, |
| 74 |
auto_renew => { |
88 |
auto_renew => { |
| 75 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
89 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
90 |
default_value => 0, |
| 76 |
}, |
91 |
}, |
| 77 |
cap_fine_to_replacement_price => { |
92 |
cap_fine_to_replacement_price => { |
| 78 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
93 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
94 |
default_value => 0, |
| 79 |
}, |
95 |
}, |
| 80 |
chargeperiod => { |
96 |
chargeperiod => { |
| 81 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
97 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
98 |
default_value => 0, |
| 82 |
}, |
99 |
}, |
| 83 |
chargeperiod_charge_at => { |
100 |
chargeperiod_charge_at => { |
| 84 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
101 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
102 |
default_value => 0, |
| 85 |
}, |
103 |
}, |
| 86 |
fine => { |
104 |
fine => { |
| 87 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
105 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
106 |
default_value => 0, |
| 88 |
}, |
107 |
}, |
| 89 |
finedays => { |
108 |
finedays => { |
| 90 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
109 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
110 |
default_value => 0, |
| 91 |
}, |
111 |
}, |
| 92 |
firstremind => { |
112 |
firstremind => { |
| 93 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
113 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
114 |
default_value => 0, |
| 94 |
}, |
115 |
}, |
| 95 |
hardduedate => { |
116 |
hardduedate => { |
| 96 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
117 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
118 |
default_value => "", |
| 97 |
}, |
119 |
}, |
| 98 |
hardduedatecompare => { |
120 |
hardduedatecompare => { |
| 99 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
121 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
122 |
default_value => -1, |
| 100 |
}, |
123 |
}, |
| 101 |
holds_per_record => { |
124 |
holds_per_record => { |
| 102 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
125 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
126 |
default_value => 1, |
| 103 |
}, |
127 |
}, |
| 104 |
issuelength => { |
128 |
issuelength => { |
| 105 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
129 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
130 |
default_value => 0, |
| 106 |
}, |
131 |
}, |
| 107 |
lengthunit => { |
132 |
lengthunit => { |
| 108 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
133 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
134 |
default_value => 'days', |
| 109 |
}, |
135 |
}, |
| 110 |
maxissueqty => { |
136 |
maxissueqty => { |
| 111 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
137 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
138 |
default_value => "", |
| 112 |
}, |
139 |
}, |
| 113 |
maxonsiteissueqty => { |
140 |
maxonsiteissueqty => { |
| 114 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
141 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
142 |
default_value => "", |
| 115 |
}, |
143 |
}, |
| 116 |
maxsuspensiondays => { |
144 |
maxsuspensiondays => { |
| 117 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
145 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
146 |
default_value => "", |
| 118 |
}, |
147 |
}, |
| 119 |
no_auto_renewal_after => { |
148 |
no_auto_renewal_after => { |
| 120 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
149 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
150 |
default_value => "", |
| 121 |
}, |
151 |
}, |
| 122 |
no_auto_renewal_after_hard_limit => { |
152 |
no_auto_renewal_after_hard_limit => { |
| 123 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
153 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
154 |
default_value => "", |
| 124 |
}, |
155 |
}, |
| 125 |
norenewalbefore => { |
156 |
norenewalbefore => { |
| 126 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
157 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
158 |
default_value => "", |
| 127 |
}, |
159 |
}, |
| 128 |
onshelfholds => { |
160 |
onshelfholds => { |
| 129 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
161 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
162 |
default_value => 0, |
| 130 |
}, |
163 |
}, |
| 131 |
opacitemholds => { |
164 |
opacitemholds => { |
| 132 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
165 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
166 |
default_value => "N", |
| 133 |
}, |
167 |
}, |
| 134 |
overduefinescap => { |
168 |
overduefinescap => { |
| 135 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
169 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
170 |
default_value => "", |
| 136 |
}, |
171 |
}, |
| 137 |
renewalperiod => { |
172 |
renewalperiod => { |
| 138 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
173 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
174 |
default_value => 0, |
| 139 |
}, |
175 |
}, |
| 140 |
renewalsallowed => { |
176 |
renewalsallowed => { |
| 141 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
177 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
178 |
default_value => 0, |
| 142 |
}, |
179 |
}, |
| 143 |
rentaldiscount => { |
180 |
rentaldiscount => { |
| 144 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
181 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
182 |
default_value => 0, |
| 145 |
}, |
183 |
}, |
| 146 |
reservesallowed => { |
184 |
reservesallowed => { |
| 147 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
185 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
|
|
186 |
default_value => 0, |
| 148 |
}, |
187 |
}, |
| 149 |
# Not included (deprecated?): |
188 |
# Not included (deprecated?): |
| 150 |
# * accountsent |
189 |
# * accountsent |
|
Lines 227-232
sub get_effective_rules {
Link Here
|
| 227 |
|
266 |
|
| 228 |
=head3 set_rule |
267 |
=head3 set_rule |
| 229 |
|
268 |
|
|
|
269 |
=over 4 |
| 270 |
Koha::CirculationRules->set_rule( { |
| 271 |
branchcode => $branchcode, |
| 272 |
[ categorycode => $categorycode, ] |
| 273 |
[ itemtype => $itemtype, ] |
| 274 |
rule_name => $rule_name, |
| 275 |
rule_value => $rule_value, |
| 276 |
[ allow_null_out_of_scope => 1, ] |
| 277 |
} ) |
| 278 |
=back |
| 279 |
|
| 280 |
Sets a single circulation rule. |
| 281 |
|
| 282 |
It is an error to specify a C<categorycode> or C<itemtype> unless the given C<rule_name> can be set |
| 283 |
at that scope; i.e., you cannot set a C<patron_maxissueqty> for an itemtype. |
| 284 |
|
| 285 |
If C<allow_null_out_of_scope> is passed, and any excess C<categorycode> or C<itemtype> is set to C<undef>, |
| 286 |
they are ignored. |
| 287 |
|
| 230 |
=cut |
288 |
=cut |
| 231 |
|
289 |
|
| 232 |
sub set_rule { |
290 |
sub set_rule { |
|
Lines 248-254
sub set_rule {
Link Here
|
| 248 |
unless exists $params->{$scope_level}; |
306 |
unless exists $params->{$scope_level}; |
| 249 |
} else { |
307 |
} else { |
| 250 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
308 |
croak "set_rule cannot set '$params->{rule_name}' for a '$scope_level'!" |
| 251 |
if exists $params->{$scope_level}; |
309 |
unless !exists $params->{$scope_level} || ( |
|
|
310 |
$params->{allow_null_out_of_scope} && |
| 311 |
!defined $params->{$scope_level} |
| 312 |
); |
| 252 |
} |
313 |
} |
| 253 |
} |
314 |
} |
| 254 |
|
315 |
|