]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_item_config.js
updated some logging, added script support to SIP for determining magnetic, etc....
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_item_config.js
1 load_lib('circ/circ_lib.js');
2 log_debug('loading circ_item_config.js ...');
3
4 /* ----------------------------------------------------------------------------- 
5         Configure the duration rules for the various item types and circ modifiers
6
7         MARC Fixed Field info:
8         http://www.oclc.org/bibformats/en/fixedfield/
9
10         ----------------------------------------------------------------------------- */
11
12 var MARC_ITEM_TYPE_MAP = {
13
14         a : { /* Language material [Books] */
15                 magneticMedia                   : 'f',
16                 durationRule                    : '14_days_2_renew',
17                 recurringFinesRule      : '10_cent_per_day',
18                 maxFine                                 : 'overdue_mid'
19         },
20
21         t : { /* Manuscript language material [Books] */
22                 magneticMedia                   : 'f',
23                 durationRule                    : '14_days_2_renew',
24                 recurringFinesRule      : '10_cent_per_day',
25                 maxFine                                 : 'overdue_mid'
26         },
27
28         g : { /* Projected medium [Videos, etc.] */
29                 magneticMedia                   : 'f',
30                 durationRule                    : '7_days_0_renew',
31                 recurringFinesRule      : '10_cent_per_day',
32                 maxFine                                 : 'overdue_mid'
33         },
34
35         k : { /* Two-dimensional nonprojectable graphic [Card, charts, etc.] */
36                 magneticMedia                   : 'f',
37                 durationRule                    : '3_month_0_renew',
38                 recurringFinesRule      : '10_cent_per_day',
39                 maxFine                                 : 'overdue_mid'
40         },
41
42         r : { /* Three-dimensional artifact or naturally occurring object [Models, games, etc.] */ 
43                 magneticMedia                   : 'f',
44                 durationRule                    : '14_days_2_renew',
45                 recurringFinesRule      : '10_cent_per_day',
46                 maxFine                                 : 'overdue_mid'
47         },
48
49         o : { /* Kit [Mixture of item types] */
50                 magneticMedia                   : 'f',
51                 durationRule                    : '14_days_2_renew',
52                 recurringFinesRule      : '10_cent_per_day',
53                 maxFine                                 : 'overdue_mid'
54         },
55
56         p : { /* Mixed materials [Mixture of item types] */
57                 magneticMedia                   : 'f',
58                 durationRule                    : '14_days_2_renew',
59                 recurringFinesRule      : '10_cent_per_day',
60                 maxFine                                 : 'overdue_mid'
61         },
62
63         e : { /* Cartographic material [Map] */
64                 magneticMedia                   : 'f',
65                 durationRule                    : '7_days_2_renew',
66                 recurringFinesRule      : '50_cent_per_day',
67                 maxFine                                 : 'overdue_mid'
68         },
69
70         f : { /* Manuscript cartographic material [Map] */
71                 magneticMedia                   : 'f',
72                 durationRule                    : '3_days_1_renew',
73                 recurringFinesRule      : '50_cent_per_day',
74                 maxFine                                 : 'overdue_mid'
75         },
76
77         c : { /* Notated music [Printed music] */
78                 magneticMedia                   : 'f',
79                 durationRule                    : '14_days_2_renew',
80                 recurringFinesRule      : '10_cent_per_day',
81                 maxFine                                 : 'overdue_mid'
82         },
83
84         d : { /* Manuscript notated music [Printed music] */
85                 magneticMedia                   : 'f',
86                 durationRule                    : '14_days_2_renew',
87                 recurringFinesRule      : '10_cent_per_day',
88                 maxFine                                 : 'overdue_mid'
89         },
90
91         i : { /* Nonmusical sound recording [Audiobooks, sound effects, etc.] */
92                 magneticMedia                   : 'f',
93                 durationRule                    : '14_days_2_renew',
94                 recurringFinesRule      : '10_cent_per_day',
95                 maxFine                                 : 'overdue_mid'
96         },
97
98         j : { /* Musical sound recording [Music] */
99                 magneticMedia                   : 'f',
100                 durationRule                    : '14_days_2_renew',
101                 recurringFinesRule      : '10_cent_per_day',
102                 maxFine                                 : 'overdue_mid'
103         },
104
105         m : { /* Computer file */
106                 magneticMedia                   : 'f',
107                 durationRule                    : '14_days_2_renew',
108                 recurringFinesRule      : '10_cent_per_day',
109                 maxFine                                 : 'overdue_mid'
110         }
111 }
112
113
114 var CIRC_MOD_MAP = {
115
116         'art'           : {
117                 magneticMedia                   : 'f',
118                 durationRule                    : '3_month_0_renew',
119                 recurringFinesRule      : '10_cent_per_day',
120                 maxFine                                 : 'overdue_mid'
121         },
122
123         'atlas'         : {
124                 magneticMedia                   : 'f',
125                 durationRule                    : '7_days_2_renew',
126                 recurringFinesRule      : '50_cent_per_day',
127                 maxFine                                 : 'overdue_mid'
128         },
129
130         'audiobook' : {
131                 magneticMedia                   : 'f',
132                 durationRule                    : '14_days_2_renew',
133                 recurringFinesRule      : '10_cent_per_day',
134                 maxFine                                 : 'overdue_mid'
135         },
136
137         'av' : {
138                 magneticMedia                   : 'f',
139                 durationRule                    : '7_days_2_renew',
140                 recurringFinesRule      : '50_cent_per_day',
141                 maxFine                                 : 'overdue_mid'
142         },
143
144         'bestseller'                            : {
145                 magneticMedia                   : 'f',
146                 durationRule                    : '7_days_2_renew',
147                 recurringFinesRule      : '50_cent_per_day',
148                 maxFine                                 : 'overdue_mid'
149         },
150
151         'bestsellernh'                          : {
152                 magneticMedia                   : 'f',
153                 durationRule                    : '7_days_2_renew',
154                 recurringFinesRule      : '50_cent_per_day',
155                 maxFine                                 : 'overdue_mid'
156         },
157
158         'book'                                          : {
159                 magneticMedia                   : 'f',
160                 durationRule                    : '14_days_2_renew',
161                 recurringFinesRule      : '10_cent_per_day',
162                 maxFine                                 : 'overdue_mid'
163         },
164
165         'cd'                            : {
166                 magneticMedia                   : 'f',
167                 durationRule                    : '14_days_2_renew',
168                 recurringFinesRule      : '10_cent_per_day',
169                 maxFine                                 : 'overdue_mid'
170         },
171
172         'dvd'                                                   : {
173                 magneticMedia                   : 'f',
174                 durationRule                    : '7_days_0_renew',
175                 recurringFinesRule      : '50_cent_per_day',
176                 maxFine                                 : 'overdue_mid'
177         },
178
179         'e-book' : {
180                 magneticMedia                   : 'f',
181                 durationRule                    : '3_days_1_renew',
182                 recurringFinesRule      : '50_cent_per_day',
183                 maxFine                                 : 'overdue_mid'
184         },
185
186         'equipment' : { 
187                 magneticMedia                   : 'f',
188                 durationRule                    : '3_days_1_renew',
189                 recurringFinesRule      : '50_cent_per_day',
190                 maxFine                                 : 'overdue_mid'
191         },
192
193         'filmstrip'                                     : {
194                 magneticMedia                   : 'f',
195                 durationRule                    : '14_days_2_renew',
196                 recurringFinesRule      : '10_cent_per_day',
197                 maxFine                                 : 'overdue_mid'
198         },
199
200         'kit' : {
201                 magneticMedia                   : 'f',
202                 durationRule                    : '14_days_2_renew',
203                 recurringFinesRule      : '10_cent_per_day',
204                 maxFine                                 : 'overdue_mid'
205         },
206
207         'magazine'      : {
208                 magneticMedia                   : 'f',
209                 durationRule                    : '14_days_2_renew',
210                 recurringFinesRule      : '10_cent_per_day',
211                 maxFine                                 : 'overdue_mid'
212         },
213
214         'map' : {
215                 magneticMedia                   : 'f',
216                 durationRule                    : '3_days_1_renew',
217                 recurringFinesRule      : '50_cent_per_day',
218                 maxFine                                 : 'overdue_mid'
219         },
220
221         'microform' : {
222                 magneticMedia                   : 'f',
223                 durationRule                    : '14_days_2_renew',
224                 recurringFinesRule      : '10_cent_per_day',
225                 maxFine                                 : 'overdue_mid'
226         },
227
228         'music' : {
229                 magneticMedia                   : 'f',
230                 durationRule                    : '14_days_2_renew',
231                 recurringFinesRule      : '10_cent_per_day',
232                 maxFine                                 : 'overdue_mid'
233         },
234
235         'record'                                                : {
236                 magneticMedia                   : 'f',
237                 durationRule                    : '14_days_2_renew',
238                 recurringFinesRule      : '10_cent_per_day',
239                 maxFine                                 : 'overdue_mid'
240         },
241
242         'software' : {
243                 magneticMedia                   : 'f',
244                 durationRule                    : '7_days_2_renew',
245                 recurringFinesRule      : '10_cent_per_day',
246                 maxFine                                 : 'overdue_mid'
247         },
248
249         'talking book'                          : {  
250                 magneticMedia                   : 'f',
251                 durationRule                    : 'unlimited',
252         },
253
254         'toy'                                                   : {
255                 magneticMedia                   : 'f',
256                 durationRule                    : '7_days_2_renew',
257                 recurringFinesRule      : '50_cent_per_day',
258                 maxFine                                 : 'overdue_mid'
259         },
260
261         'video' : {
262                 magneticMedia                   : 'f',
263                 durationRule                    : '7_days_0_renew',
264                 recurringFinesRule      : '50_cent_per_day',
265                 maxFine                                 : 'overdue_mid'
266         },
267 }
268
269
270 /* Set up rules for legacy types */
271 CIRC_MOD_MAP['DEPOSIT']         = CIRC_MOD_MAP['book'];
272 CIRC_MOD_MAP['E-AUDIO']         = CIRC_MOD_MAP['book'];
273 CIRC_MOD_MAP['EQUIP']           = CIRC_MOD_MAP['book'];
274 CIRC_MOD_MAP['FACBESTSLR'] = CIRC_MOD_MAP['book'];
275 CIRC_MOD_MAP['FACNEWBK']        = CIRC_MOD_MAP['book'];
276 CIRC_MOD_MAP['MAG-CIRC']        = CIRC_MOD_MAP['book'];
277 CIRC_MOD_MAP['MAG-NOCIRC'] = CIRC_MOD_MAP['book'];
278 CIRC_MOD_MAP['NEW-AV']          = CIRC_MOD_MAP['book'];
279 CIRC_MOD_MAP['NEW-BOOK']        = CIRC_MOD_MAP['book'];
280 CIRC_MOD_MAP['NEWSPAPER']       = CIRC_MOD_MAP['book'];
281 CIRC_MOD_MAP['NILS-ITEM']       = CIRC_MOD_MAP['book'];
282 CIRC_MOD_MAP['OUTREACH']        = CIRC_MOD_MAP['book'];
283 CIRC_MOD_MAP['PAMPHLET']        = CIRC_MOD_MAP['book'];
284 CIRC_MOD_MAP['PAPERBACK']       = CIRC_MOD_MAP['book'];
285 CIRC_MOD_MAP['REALIA']          = CIRC_MOD_MAP['book'];
286 CIRC_MOD_MAP['RESERVE']         = CIRC_MOD_MAP['book'];
287 CIRC_MOD_MAP['STATE-BOOK'] = {
288         magneticMedia                   : 'f',
289         durationRule                    : '35_days_1_renew',
290         recurringFinesRule      : "10_cent_per_day",
291         maxFine                                 : "overdue_mid"
292 };
293 CIRC_MOD_MAP['STATE-MFRM'] =  {
294         magneticMedia                   : 'f',
295         durationRule                    : '14_days_2_renew',
296         recurringFinesRule      : "10_cent_per_day",
297         maxFine                                 : "overdue_mid"
298 };
299
300 /* this will set defaults even if no one asked for them */
301 log_debug("Calling getItemConfig() to force defaults..");
302 getItemConfig();
303 log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
304
305
306 function getItemConfig() {
307
308         /* ----------------------------------------------------------------------------------- 
309                 If a circ_modifier is defined on the copy and we have config info for the
310                 provided circ_modifier, use that config.  Otherwise fall back on the MARC item type
311                 ----------------------------------------------------------------------------------- */
312         var marcType    = getMARCItemType();
313         var circMod             = copy.circ_modifier;
314         var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
315         
316         var config;
317         
318         if( circMod && CIRC_MOD_MAP[circMod.toLowerCase()] ) {
319                 /* if we have a config for the given circ_modifier, use it */
320                 log_debug("a circ_mod config exists for the copy: " + circMod);
321                 config = CIRC_MOD_MAP[circMod];
322         
323         } else {
324                 /* otherwise, fall back on the MARC item type */
325         
326                 if( circMod ) {
327                         log_debug("no circ_mod config found for "
328                                 +circMod+", falling back to MARC");
329                 }
330                 config = MARC_ITEM_TYPE_MAP[marcType];
331         }
332
333         /* if no config could be found, default to 'book' */
334         if(!config) {
335                 log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
336                 config = CIRC_MOD_MAP['book'];
337         }
338
339         /* go ahead and set some default result 
340                 data (which may be overidden) */
341         for( var i in config ) {
342                 log_debug("item_config setting result defaults: "+i+" = " +config[i]);
343                 result[i] = config[i];
344         }
345
346         return config;
347 }
348
349