]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_duration.js
added an exception for Trustee so they won't get circ fines
[Evergreen.git] / Open-ILS / 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 /* statelib has some special circ rules */
48
49 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) {
50
51         result.durationRule                     = '35_days_1_renew';
52         result.recurringFinesRule       = "10_cent_per_day";
53         result.maxFine                                  = "overdue_mid";
54
55         /* reference, microfiche, microfilm */
56         if(     isTrue(copy.ref)        || 
57                         itemForm == 'a' || 
58                         itemForm == 'b' ) {
59
60                 result.durationRule             = '14_days_2_renew';
61         }       
62 }
63
64
65 /* and so does OCRL */
66
67 if( isOrgDescendent('OCRL', copy.circ_lib.id) && copy.circ_modifier == 'VIDEO') {
68         result.durationRule             = '7_days_0_renew';
69         result.recurringFinesRule       = '10_cent_per_day';
70 }
71
72
73 checkDurationExceptions();
74
75 log_debug(result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine );
76
77 } go();
78
79
80
81 function checkDurationExceptions() {
82         log_debug("Checking duration rule exceptions for profile  "+patronProfile);
83
84         if(     isGroupDescendant('Staff', patronProfile) || 
85                         isGroupDescendant('Trustee', patronProfile) ||
86                         isGroupDescendant('Outreach', patronProfile) ) {
87
88                 result.recurringFinesRule       = "staff";
89                 result.maxFine                                  = "staff";
90         }
91
92         if( isGroupDescendant('Outreach', patronProfile) ) {
93                 log_info("Outreach user found, setting duration to 2 months");
94                 result.durationRule = '2_months_2_renew';
95         }
96 }
97
98