]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_item_config.js
removed a bogus special case for STATELIB circ durations
[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 /* SIP media types
6 000 Other
7 001 Book
8 002 Magazine
9 003 Bound journal
10 004 Audio tape
11 005 Video tape
12 006 CD/CDROM
13 007 Diskette
14 008 Book with diskette
15 009 Book with CD
16 010 Book with audio tape
17 */
18
19 /* ----------------------------------------------------------------------------- 
20         Configure the duration rules for the various item types and circ modifiers
21
22         MARC Fixed Field info:
23         http://www.oclc.org/bibformats/en/fixedfield/
24
25         ----------------------------------------------------------------------------- */
26
27 var MARC_ITEM_TYPE_MAP = {
28
29         a : { /* Language material [Books] */
30                 SIPMediaType                    : '001',
31                 magneticMedia                   : 'f',
32                 durationRule                    : '14_days_2_renew',
33                 recurringFinesRule      : '10_cent_per_day',
34                 maxFine                                 : 'overdue_mid'
35         },
36
37         t : { /* Manuscript language material [Books] */
38                 SIPMediaType                    : '001',
39                 magneticMedia                   : 'f',
40                 durationRule                    : '14_days_2_renew',
41                 recurringFinesRule      : '10_cent_per_day',
42                 maxFine                                 : 'overdue_mid'
43         },
44
45         g : { /* Projected medium [Videos, etc.] */
46                 SIPMediaType                    : '005',
47                 magneticMedia                   : 'f',
48                 durationRule                    : '7_days_0_renew',
49                 recurringFinesRule      : '10_cent_per_day',
50                 maxFine                                 : 'overdue_mid'
51         },
52
53         k : { /* Two-dimensional nonprojectable graphic [Card, charts, etc.] */
54                 SIPMediaType                    : '001',
55                 magneticMedia                   : 'f',
56                 durationRule                    : '3_month_0_renew',
57                 recurringFinesRule      : '10_cent_per_day',
58                 maxFine                                 : 'overdue_mid'
59         },
60
61         r : { /* Three-dimensional artifact or naturally occurring object [Models, games, etc.] */ 
62                 SIPMediaType                    : '001',
63                 magneticMedia                   : 'f',
64                 durationRule                    : '14_days_2_renew',
65                 recurringFinesRule      : '10_cent_per_day',
66                 maxFine                                 : 'overdue_mid'
67         },
68
69         o : { /* Kit [Mixture of item types] */
70                 SIPMediaType                    : '001',
71                 magneticMedia                   : 'f',
72                 durationRule                    : '14_days_2_renew',
73                 recurringFinesRule      : '10_cent_per_day',
74                 maxFine                                 : 'overdue_mid'
75         },
76
77         p : { /* Mixed materials [Mixture of item types] */
78                 SIPMediaType                    : '001',
79                 magneticMedia                   : 'f',
80                 durationRule                    : '14_days_2_renew',
81                 recurringFinesRule      : '10_cent_per_day',
82                 maxFine                                 : 'overdue_mid'
83         },
84
85         e : { /* Cartographic material [Map] */
86                 SIPMediaType                    : '001',
87                 magneticMedia                   : 'f',
88                 durationRule                    : '7_days_2_renew',
89                 recurringFinesRule      : '50_cent_per_day',
90                 maxFine                                 : 'overdue_mid'
91         },
92
93         f : { /* Manuscript cartographic material [Map] */
94                 SIPMediaType                    : '001',
95                 magneticMedia                   : 'f',
96                 durationRule                    : '3_days_1_renew',
97                 recurringFinesRule      : '50_cent_per_day',
98                 maxFine                                 : 'overdue_mid'
99         },
100
101         c : { /* Notated music [Printed music] */
102                 SIPMediaType                    : '001',
103                 magneticMedia                   : 'f',
104                 durationRule                    : '14_days_2_renew',
105                 recurringFinesRule      : '10_cent_per_day',
106                 maxFine                                 : 'overdue_mid'
107         },
108
109         d : { /* Manuscript notated music [Printed music] */
110                 SIPMediaType                    : '001',
111                 magneticMedia                   : 'f',
112                 durationRule                    : '14_days_2_renew',
113                 recurringFinesRule      : '10_cent_per_day',
114                 maxFine                                 : 'overdue_mid'
115         },
116
117         i : { /* Nonmusical sound recording [Audiobooks, sound effects, etc.] */
118                 SIPMediaType                    : '001',
119                 magneticMedia                   : 'f',
120                 durationRule                    : '14_days_2_renew',
121                 recurringFinesRule      : '10_cent_per_day',
122                 maxFine                                 : 'overdue_mid'
123         },
124
125         j : { /* Musical sound recording [Music] */
126                 SIPMediaType                    : '001',
127                 magneticMedia                   : 'f',
128                 durationRule                    : '14_days_2_renew',
129                 recurringFinesRule      : '10_cent_per_day',
130                 maxFine                                 : 'overdue_mid'
131         },
132
133         m : { /* Computer file */
134                 SIPMediaType                    : '001',
135                 magneticMedia                   : 'f',
136                 durationRule                    : '14_days_2_renew',
137                 recurringFinesRule      : '10_cent_per_day',
138                 maxFine                                 : 'overdue_mid'
139         }
140 }
141
142
143 var CIRC_MOD_MAP = {
144
145         'art'           : {
146                 SIPMediaType                    : '000',
147                 magneticMedia                   : 'f',
148                 durationRule                    : '3_month_0_renew',
149                 recurringFinesRule      : '10_cent_per_day',
150                 maxFine                                 : 'overdue_mid'
151         },
152
153         'atlas'         : {
154                 SIPMediaType                    : '000',
155                 magneticMedia                   : 'f',
156                 durationRule                    : '7_days_2_renew',
157                 recurringFinesRule      : '50_cent_per_day',
158                 maxFine                                 : 'overdue_mid'
159         },
160
161         'audiobook' : {
162                 SIPMediaType                    : '004',
163                 magneticMedia                   : 'f',
164                 durationRule                    : '14_days_2_renew',
165                 recurringFinesRule      : '10_cent_per_day',
166                 maxFine                                 : 'overdue_mid'
167         },
168
169         'av' : {
170                 SIPMediaType                    : '005',
171                 magneticMedia                   : 'f',
172                 durationRule                    : '7_days_2_renew',
173                 recurringFinesRule      : '50_cent_per_day',
174                 maxFine                                 : 'overdue_mid'
175         },
176
177         'new-av' : { 
178                 SIPMediaType                    : '005',
179                 magneticMedia                   : 'f',
180                 durationRule                    : '3_days_1_renew',
181                 recurringFinesRule      : '50_cent_per_day',
182                 maxFine                                 : 'overdue_mid'
183         },
184
185         'bestseller'                            : {
186                 SIPMediaType                    : '001',
187                 magneticMedia                   : 'f',
188                 durationRule                    : '7_days_2_renew',
189                 recurringFinesRule      : '50_cent_per_day',
190                 maxFine                                 : 'overdue_mid'
191         },
192
193         'bestsellernh'                          : {
194                 SIPMediaType                    : '001',
195                 magneticMedia                   : 'f',
196                 durationRule                    : '7_days_2_renew',
197                 recurringFinesRule      : '50_cent_per_day',
198                 maxFine                                 : 'overdue_mid'
199         },
200
201         'book'                                          : {
202                 SIPMediaType                    : '001',
203                 magneticMedia                   : 'f',
204                 durationRule                    : '14_days_2_renew',
205                 recurringFinesRule      : '10_cent_per_day',
206                 maxFine                                 : 'overdue_mid'
207         },
208
209         'cd'                            : {
210                 SIPMediaType                    : '006',
211                 magneticMedia                   : 'f',
212                 durationRule                    : '14_days_2_renew',
213                 recurringFinesRule      : '10_cent_per_day',
214                 maxFine                                 : 'overdue_mid'
215         },
216
217         'dvd'                                                   : {
218                 SIPMediaType                    : '006',
219                 magneticMedia                   : 'f',
220                 durationRule                    : '7_days_0_renew',
221                 recurringFinesRule      : '50_cent_per_day',
222                 maxFine                                 : 'overdue_mid'
223         },
224
225         'dvd-long'                                                      : {
226                 SIPMediaType                    : '006',
227                 magneticMedia                   : 'f',
228                 durationRule                    : '14_days_2_renew',
229                 recurringFinesRule      : '10_cent_per_day',
230                 maxFine                                 : 'overdue_mid'
231         },
232
233
234         'e-book' : {
235                 SIPMediaType                    : '001',
236                 magneticMedia                   : 'f',
237                 durationRule                    : '3_days_1_renew',
238                 recurringFinesRule      : '50_cent_per_day',
239                 maxFine                                 : 'overdue_mid'
240         },
241
242         'equipment' : { 
243                 SIPMediaType                    : '000',
244                 magneticMedia                   : 'f',
245                 durationRule                    : '3_days_1_renew',
246                 recurringFinesRule      : '50_cent_per_day',
247                 maxFine                                 : 'overdue_mid'
248         },
249
250         'filmstrip'                                     : {
251                 SIPMediaType                    : '000',
252                 magneticMedia                   : 'f',
253                 durationRule                    : '14_days_2_renew',
254                 recurringFinesRule      : '10_cent_per_day',
255                 maxFine                                 : 'overdue_mid'
256         },
257
258         'kit' : {
259                 SIPMediaType                    : '000',
260                 magneticMedia                   : 'f',
261                 durationRule                    : '14_days_2_renew',
262                 recurringFinesRule      : '10_cent_per_day',
263                 maxFine                                 : 'overdue_mid'
264         },
265
266         'magazine'      : {
267                 SIPMediaType                    : '002',
268                 magneticMedia                   : 'f',
269                 durationRule                    : '14_days_2_renew',
270                 recurringFinesRule      : '10_cent_per_day',
271                 maxFine                                 : 'overdue_mid'
272         },
273
274         'map' : {
275                 SIPMediaType                    : '000',
276                 magneticMedia                   : 'f',
277                 durationRule                    : '3_days_1_renew',
278                 recurringFinesRule      : '50_cent_per_day',
279                 maxFine                                 : 'overdue_mid'
280         },
281
282         'microform' : {
283                 SIPMediaType                    : '000',
284                 magneticMedia                   : 'f',
285                 durationRule                    : '14_days_2_renew',
286                 recurringFinesRule      : '10_cent_per_day',
287                 maxFine                                 : 'overdue_mid'
288         },
289
290         'music' : {
291                 SIPMediaType                    : '004',
292                 magneticMedia                   : 'f',
293                 durationRule                    : '14_days_2_renew',
294                 recurringFinesRule      : '10_cent_per_day',
295                 maxFine                                 : 'overdue_mid'
296         },
297
298         'record'                                                : {
299                 SIPMediaType                    : '000',
300                 magneticMedia                   : 'f',
301                 durationRule                    : '14_days_2_renew',
302                 recurringFinesRule      : '10_cent_per_day',
303                 maxFine                                 : 'overdue_mid'
304         },
305
306         'software' : {
307                 SIPMediaType                    : '006',
308                 magneticMedia                   : 'f',
309                 durationRule                    : '7_days_2_renew',
310                 recurringFinesRule      : '10_cent_per_day',
311                 maxFine                                 : 'overdue_mid'
312         },
313
314         'talking book'                          : {  
315                 SIPMediaType                    : '006',
316                 magneticMedia                   : 'f',
317                 durationRule                    : 'unlimited',
318         },
319
320         'toy'                                                   : {
321                 SIPMediaType                    : '000',
322                 magneticMedia                   : 'f',
323                 durationRule                    : '14_days_2_renew',
324                 recurringFinesRule      : '10_cent_per_day',
325                 maxFine                                 : 'overdue_mid'
326         },
327
328         'video' : {
329                 SIPMediaType                    : '005',
330                 magneticMedia                   : 'f',
331                 durationRule                    : '7_days_0_renew',
332                 recurringFinesRule      : '10_cent_per_day',
333                 maxFine                                 : 'overdue_mid'
334         },
335
336         'video-long'    : {
337                 SIPMediaType                    : '005',
338                 magneticMedia                   : 'f',
339                 durationRule                    : '14_days_2_renew',
340                 recurringFinesRule      : '10_cent_per_day',
341                 maxFine                                 : 'overdue_mid'
342         },
343
344         'facbestslr'    : {
345                 SIPMediaType                    : '001',
346                 magneticMedia                   : 'f',
347                 durationRule                    : '7_days_2_renew',
348                 recurringFinesRule      : '10_cent_per_day',
349                 maxFine                                 : 'overdue_mid'
350         },
351
352 }
353
354
355 /* Set up rules for legacy types */
356 CIRC_MOD_MAP['DEPOSIT']         = CIRC_MOD_MAP['book'];
357 CIRC_MOD_MAP['E-AUDIO']         = CIRC_MOD_MAP['book'];
358 CIRC_MOD_MAP['EQUIP']           = CIRC_MOD_MAP['book'];
359 CIRC_MOD_MAP['FACNEWBK']        = CIRC_MOD_MAP['book'];
360 CIRC_MOD_MAP['MAG-CIRC']        = CIRC_MOD_MAP['book'];
361 CIRC_MOD_MAP['MAG-NOCIRC'] = CIRC_MOD_MAP['book'];
362 CIRC_MOD_MAP['NEW-AV']          = CIRC_MOD_MAP['book'];
363 CIRC_MOD_MAP['NEW-BOOK']        = CIRC_MOD_MAP['book'];
364 CIRC_MOD_MAP['NEWSPAPER']       = CIRC_MOD_MAP['book'];
365 CIRC_MOD_MAP['NILS-ITEM']       = CIRC_MOD_MAP['book'];
366 CIRC_MOD_MAP['OUTREACH']        = CIRC_MOD_MAP['book'];
367 CIRC_MOD_MAP['PAMPHLET']        = CIRC_MOD_MAP['book'];
368 CIRC_MOD_MAP['PAPERBACK']       = CIRC_MOD_MAP['book'];
369 CIRC_MOD_MAP['REALIA']          = CIRC_MOD_MAP['book'];
370 CIRC_MOD_MAP['RESERVE']         = CIRC_MOD_MAP['book'];
371 CIRC_MOD_MAP['STATE-BOOK'] = {
372         SIPMediaType                    : '001',
373         magneticMedia                   : 'f',
374         durationRule                    : '35_days_1_renew',
375         recurringFinesRule      : "10_cent_per_day",
376         maxFine                                 : "overdue_mid"
377 };
378 CIRC_MOD_MAP['STATE-MFRM'] =  {
379         SIPMediaType                    : '001',
380         magneticMedia                   : 'f',
381         durationRule                    : '14_days_2_renew',
382         recurringFinesRule      : "10_cent_per_day",
383         maxFine                                 : "overdue_mid"
384 };
385
386
387
388
389 /* this will set defaults even if no one asked for them */
390 log_debug("Calling getItemConfig() to force defaults..");
391 getItemConfig();
392 log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
393
394
395 function getItemConfig() {
396
397         /* ----------------------------------------------------------------------------------- 
398                 If a circ_modifier is defined on the copy and we have config info for the
399                 provided circ_modifier, use that config.  Otherwise fall back on the MARC item type
400                 ----------------------------------------------------------------------------------- */
401         var marcType    = getMARCItemType();
402         var circMod             = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
403         var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
404         
405         var config;
406         
407         if( circMod && CIRC_MOD_MAP[circMod] ) {
408                 /* if we have a config for the given circ_modifier, use it */
409                 log_debug("a circ_mod config exists for the copy: " + circMod);
410                 config = CIRC_MOD_MAP[circMod];
411         
412         } else {
413                 /* otherwise, fall back on the MARC item type */
414         
415                 if( circMod ) {
416                         log_debug("no circ_mod config found for "
417                                 +circMod+", falling back to MARC");
418                 }
419                 config = MARC_ITEM_TYPE_MAP[marcType];
420         }
421
422         /* if no config could be found, default to 'book' */
423         if(!config) {
424                 log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
425                 config = CIRC_MOD_MAP['book'];
426         }
427
428         config.maxFine = setMaxFineByCircLocation();
429
430         /* go ahead and set some default result 
431                 data (which may be overidden) */
432         for( var i in config ) {
433                 log_debug("item_config setting result defaults: "+i+" = " +config[i]);
434                 result[i] = config[i];
435         }
436
437         return config;
438 }
439
440
441 function setMaxFineByCircLocation() {
442         var max_libs = [ 'ARL', 'DTRL', 'SJRLS' ];
443         var mid_libs = [ 'CHRL', 'ECGR', 'FRRLS', 'HCLS', 'OCRL', 'OHOOP', 'OKRL', 'PMRLS', 'PPL', 'STRL' ];
444
445         var cl = (volume && volume.id != -1) ? volume.owning_lib : currentLocation.id;
446         var max_fine = null;
447
448         for( var i = 0; i < max_libs.length; i++ ) {
449                 var org = max_libs[i];
450                 if( isOrgDescendent(org, cl) ) {
451                         log_debug("found max-fine ancestor org "+org);
452                         max_fine = 'overdue_max';
453                         break;
454                 }
455         }
456
457         if(!max_fine) {
458                 for( var i = 0; i < mid_libs.length; i++ ) {
459                         var org = mid_libs[i];
460                         if( isOrgDescendent(org, cl) ) {
461                                 log_debug("found mid-fine ancestor org "+org);
462                                 max_fine = 'overdue_mid';
463                                 break;
464                         }
465                 }
466         }
467
468         if(!max_fine) max_fine = 'overdue_min';
469
470         log_info("setMaxFineByCircLocation() set max_fine to "+ max_fine);
471
472         return max_fine;
473 }
474
475