]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/javascript/backend/circ/circ_item_config.js
More cleanup of the Evergreen directory. This change replaces the Open-ILS version...
[Evergreen.git] / Evergreen / 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      : '50_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_1_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         'dvd-mid'                                                       : {
234                 SIPMediaType                    : '006',
235                 magneticMedia                   : 'f',
236                 durationRule                    : '7_days_2_renew',
237                 recurringFinesRule          : '50_cent_per_day',
238                 maxFine                                 : 'overdue_mid'
239         },
240
241         'e-book' : {
242                 SIPMediaType                    : '001',
243                 magneticMedia                   : 'f',
244                 durationRule                    : '3_days_1_renew',
245                 recurringFinesRule      : '50_cent_per_day',
246                 maxFine                                 : 'overdue_mid'
247         },
248
249         'equipment' : { 
250                 SIPMediaType                    : '000',
251                 magneticMedia                   : 'f',
252                 durationRule                    : '1_day_0_renew', /* make me 1 day, 0 renewal when possible */
253                 recurringFinesRule      : '50_cent_per_day',
254                 maxFine                                 : 'overdue_mid'
255         },
256
257         'equip-long' : { 
258                 SIPMediaType                    : '000',
259                 magneticMedia                   : 'f',
260                 durationRule                    : '3_days_1_renew',
261                 recurringFinesRule      : '50_cent_per_day',
262                 maxFine                                 : 'overdue_mid'
263         },
264
265         'filmstrip'                                     : {
266                 SIPMediaType                    : '000',
267                 magneticMedia                   : 'f',
268                 durationRule                    : '14_days_2_renew',
269                 recurringFinesRule      : '10_cent_per_day',
270                 maxFine                                 : 'overdue_mid'
271         },
272
273         'kit' : {
274                 SIPMediaType                    : '000',
275                 magneticMedia                   : 'f',
276                 durationRule                    : '14_days_2_renew',
277                 recurringFinesRule      : '10_cent_per_day',
278                 maxFine                                 : 'overdue_mid'
279         },
280
281         'magazine'      : {
282                 SIPMediaType                    : '002',
283                 magneticMedia                   : 'f',
284                 durationRule                    : '14_days_2_renew',
285                 recurringFinesRule      : '10_cent_per_day',
286                 maxFine                                 : 'overdue_mid'
287         },
288
289         'map' : {
290                 SIPMediaType                    : '000',
291                 magneticMedia                   : 'f',
292                 durationRule                    : '3_days_1_renew',
293                 recurringFinesRule      : '50_cent_per_day',
294                 maxFine                                 : 'overdue_mid'
295         },
296
297         'microform' : {
298                 SIPMediaType                    : '000',
299                 magneticMedia                   : 'f',
300                 durationRule                    : '14_days_2_renew',
301                 recurringFinesRule      : '10_cent_per_day',
302                 maxFine                                 : 'overdue_mid'
303         },
304
305         'music' : {
306                 SIPMediaType                    : '004',
307                 magneticMedia                   : 'f',
308                 durationRule                    : '14_days_2_renew',
309                 recurringFinesRule      : '10_cent_per_day',
310                 maxFine                                 : 'overdue_mid'
311         },
312
313         'record'                                                : {
314                 SIPMediaType                    : '000',
315                 magneticMedia                   : 'f',
316                 durationRule                    : '14_days_2_renew',
317                 recurringFinesRule      : '10_cent_per_day',
318                 maxFine                                 : 'overdue_mid'
319         },
320
321         'software' : {
322                 SIPMediaType                    : '006',
323                 magneticMedia                   : 'f',
324                 durationRule                    : '7_days_2_renew',
325                 recurringFinesRule      : '10_cent_per_day',
326                 maxFine                                 : 'overdue_mid'
327         },
328
329         'softwrlong' : {
330                 SIPMediaType                    : '006',
331                 magneticMedia                   : 'f',
332                 durationRule                    : '14_days_2_renew',
333                 recurringFinesRule      : '10_cent_per_day',
334                 maxFine                                 : 'overdue_mid'
335         },
336
337         'talking book'                          : {  
338                 SIPMediaType                    : '006',
339                 magneticMedia                   : 'f',
340                 durationRule                    : 'unlimited',
341         },
342
343         'toy'                                                   : {
344                 SIPMediaType                    : '000',
345                 magneticMedia                   : 'f',
346                 durationRule                    : '14_days_2_renew',
347                 recurringFinesRule      : '10_cent_per_day',
348                 maxFine                                 : 'overdue_mid'
349         },
350
351         'video' : {
352                 SIPMediaType                    : '005',
353                 magneticMedia                   : 'f',
354                 durationRule                    : '7_days_0_renew',
355                 recurringFinesRule      : '50_cent_per_day',
356                 maxFine                                 : 'overdue_mid'
357         },
358
359         'video-long'    : {
360                 SIPMediaType                    : '005',
361                 magneticMedia                   : 'f',
362                 durationRule                    : '14_days_2_renew',
363                 recurringFinesRule          : '10_cent_per_day',
364                 maxFine                                 : 'overdue_mid'
365         },
366
367         'video-mid'     : {
368                 SIPMediaType                    : '005',
369                 magneticMedia                   : 'f',
370                 durationRule                    : '7_days_2_renew',
371                 recurringFinesRule          : '50_cent_per_day',
372                 maxFine                                 : 'overdue_mid'
373         },
374
375
376         'facbestslr'    : {
377                 SIPMediaType                    : '001',
378                 magneticMedia                   : 'f',
379                 durationRule                    : '7_days_2_renew',
380                 recurringFinesRule          : '10_cent_per_day',
381                 maxFine                                 : 'overdue_mid'
382         },
383
384         'eventpass'     : {
385                 SIPMediaType                    : '001',
386                 magneticMedia                   : 'f',
387                 durationRule                    : '7_day_1_renew',
388                 recurringFinesRule          : '3_dollar_per_day',
389                 maxFine                                 : 'overdue_mid'
390         },
391 }
392
393
394 /* Set up rules for legacy types */
395 CIRC_MOD_MAP['DEPOSIT']         = CIRC_MOD_MAP['book'];
396 CIRC_MOD_MAP['E-AUDIO']         = CIRC_MOD_MAP['book'];
397 CIRC_MOD_MAP['FACNEWBK']        = CIRC_MOD_MAP['book'];
398 CIRC_MOD_MAP['MAG-CIRC']        = CIRC_MOD_MAP['book'];
399 CIRC_MOD_MAP['MAG-NOCIRC'] = CIRC_MOD_MAP['book'];
400 CIRC_MOD_MAP['NEW-BOOK']        = CIRC_MOD_MAP['book'];
401 CIRC_MOD_MAP['NEWSPAPER']       = CIRC_MOD_MAP['book'];
402 CIRC_MOD_MAP['OUTREACH']        = CIRC_MOD_MAP['book'];
403 CIRC_MOD_MAP['PAMPHLET']        = CIRC_MOD_MAP['book'];
404 CIRC_MOD_MAP['PAPERBACK']       = CIRC_MOD_MAP['book'];
405 CIRC_MOD_MAP['RESERVE']         = CIRC_MOD_MAP['book'];
406 CIRC_MOD_MAP['STATE-BOOK'] = {
407         SIPMediaType                    : '001',
408         magneticMedia                   : 'f',
409         durationRule                    : '35_days_1_renew',
410         recurringFinesRule      : "10_cent_per_day",
411         maxFine                                 : "overdue_mid"
412 };
413 CIRC_MOD_MAP['STATE-MFRM'] =  {
414         SIPMediaType                    : '001',
415         magneticMedia                   : 'f',
416         durationRule                    : '14_days_2_renew',
417         recurringFinesRule      : "10_cent_per_day",
418         maxFine                                 : "overdue_mid"
419 };
420
421
422
423
424 /* this will set defaults even if no one asked for them */
425 log_debug("Calling getItemConfig() to force defaults..");
426 getItemConfig();
427 log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
428
429
430 function getItemConfig() {
431
432         /* ----------------------------------------------------------------------------------- 
433                 If a circ_modifier is defined on the copy and we have config info for the
434                 provided circ_modifier, use that config.  Otherwise fall back on the MARC item type
435                 ----------------------------------------------------------------------------------- */
436         var marcType    = getMARCItemType();
437         var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
438         //var circMod           = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
439         var circMod             = copy.circ_modifier;
440         
441         var config = null;
442
443    if( circMod ) {
444       config = CIRC_MOD_MAP[circMod];
445       if(!config) 
446          config = CIRC_MOD_MAP[circMod.toLowerCase()]
447       if(config)
448                    log_info("a circ_mod config exists for the copy with mod: " + circMod);
449    }
450
451    if(!config) {
452                 /* otherwise, fall back on the MARC item type */
453                 if( circMod ) 
454                         log_info("no circ_mod config found for " +circMod+", falling back to MARC");
455                 config = MARC_ITEM_TYPE_MAP[marcType];
456         }
457
458         /* if no config could be found, default to 'book' */
459         if(!config) {
460                 log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
461                 config = CIRC_MOD_MAP['book'];
462         }
463
464         config.maxFine = setMaxFineByCircLocation();
465
466         /* go ahead and set some default result 
467                 data (which may be overidden) */
468         for( var i in config ) {
469                 log_debug("item_config setting result defaults: "+i+" = " +config[i]);
470                 result[i] = config[i];
471         }
472
473         return config;
474 }
475
476
477 function setMaxFineByCircLocation() {
478         var max_libs = [ 'DTRL', 'SJRLS' ];
479         var mid_libs = [ 'ARL', 'CHRL', 'ECGR', 'FRRLS', 'HCLS', 'OCRL', 'OHOOP', 'OKRL', 'PMRLS', 'PPL', 'STRL' ];
480
481         var cl = (volume && volume.id != -1) ? volume.owning_lib : currentLocation.id;
482         var max_fine = null;
483
484         for( var i = 0; i < max_libs.length; i++ ) {
485                 var org = max_libs[i];
486                 if( isOrgDescendent(org, cl) ) {
487                         log_debug("found max-fine ancestor org "+org);
488                         max_fine = 'overdue_max';
489                         break;
490                 }
491         }
492
493         if(!max_fine) {
494                 for( var i = 0; i < mid_libs.length; i++ ) {
495                         var org = mid_libs[i];
496                         if( isOrgDescendent(org, cl) ) {
497                                 log_debug("found mid-fine ancestor org "+org);
498                                 max_fine = 'overdue_mid';
499                                 break;
500                         }
501                 }
502         }
503
504         if(!max_fine) max_fine = 'overdue_min';
505
506         log_info("setMaxFineByCircLocation() set max_fine to "+ max_fine);
507
508         return max_fine;
509 }
510
511