]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/javascript/backend/circ/circ_duration.js
9c3892249a51d6ffd513a4bc35466fa5c089333d
[Evergreen.git] / Evergreen / src / javascript / backend / circ / circ_duration.js
1 function go(){
2
3 load_lib('circ/circ_item_config.js');
4 log_vars('circ_duration');
5
6
7 /* treat pre-cat copies like vanilla books */
8 if( isTrue(isPrecat) ) {
9         log_info("pre-cat copy getting duration defaults...");
10         result.durationRule                     = '14_days_2_renew';
11         result.recurringFinesRule       = '10_cent_per_day';
12         result.maxFine                                  = 'overdue_mid';
13         checkDurationExceptions();
14         return;
15 }
16
17
18 /* grab the config from the config script */
19 var config = getItemConfig();
20 var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
21
22
23 /* ----------------------------------------------------------------------------- 
24         Now set the rule values based on the config.  If there is no configured info
25         on this copy, fall back on defaults.
26         ----------------------------------------------------------------------------- */
27 if( config ) {
28
29         log_debug("circ_duration found a config for the copy");
30         result.durationRule                     = config.durationRule;
31         result.recurringFinesRule       = config.recurringFinesRule;
32         result.maxFine                                  = config.maxFine;
33
34 } else {
35
36         result.durationRule                     = '14_days_2_renew';
37         result.recurringFinesRule       = "10_cent_per_day";
38         result.maxFine                                  = "overdue_mid";
39 }
40
41
42
43 /* ----------------------------------------------------------------------------- 
44         Add custom rules here.  
45         ----------------------------------------------------------------------------- */
46
47 var circMod             = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
48
49 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) {
50         if( circMod == 'book' )
51                 result.durationRule = '35_days_1_renew';
52         if(isTrue(copy.ref))
53                 result.durationRule     = '14_days_2_renew';
54
55 } else if( isOrgDescendent('NCLS', copy.circ_lib.id) && ( circMod == 'dvd' || circMod == 'video' ) ) 
56         result.recurringFinesRule       = '10_cent_per_day';
57
58
59 checkDurationExceptions();
60
61 log_info('final duration results: ' + result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine );
62
63 } go();
64
65
66
67 function checkDurationExceptions() {
68         log_debug("Checking duration rule exceptions for profile  "+patronProfile);
69
70         if(     isGroupDescendant('Staff', patronProfile) || 
71                         isGroupDescendant('Trustee', patronProfile) ||
72                         isGroupDescendant('Outreach', patronProfile) ) {
73
74                 result.recurringFinesRule       = "staff";
75                 result.maxFine                                  = "staff";
76         }
77
78         if( isGroupDescendant('Outreach', patronProfile) ) {
79                 log_info("Outreach user found, setting duration to 2 months");
80                 result.durationRule = '2_months_2_renew';
81         }
82 }
83