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